001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.client.metrics; 019 020import org.apache.commons.lang3.builder.EqualsBuilder; 021import org.apache.commons.lang3.builder.HashCodeBuilder; 022import org.apache.hadoop.hbase.ServerName; 023import org.apache.yetus.audience.InterfaceAudience; 024import org.apache.yetus.audience.InterfaceStability; 025 026/** 027 * POJO for capturing region level details when region level scan metrics are enabled. <br> 028 * <br> 029 * Currently, encoded region name and server name (host name, ports and startcode) are captured as 030 * region details. <br> 031 * <br> 032 * Instance of this class serves as key in the Map returned by 033 * {@link ServerSideScanMetrics#collectMetricsByRegion()} or 034 * {@link ServerSideScanMetrics#collectMetricsByRegion(boolean)}. 035 */ 036@InterfaceAudience.Public 037@InterfaceStability.Evolving 038public class ScanMetricsRegionInfo { 039 /** 040 * Users should only compare against this constant by reference and should not make any 041 * assumptions regarding content of the constant. 042 */ 043 public static final ScanMetricsRegionInfo EMPTY_SCAN_METRICS_REGION_INFO = 044 new ScanMetricsRegionInfo(null, null); 045 046 private final String encodedRegionName; 047 private final ServerName serverName; 048 049 ScanMetricsRegionInfo(String encodedRegionName, ServerName serverName) { 050 this.encodedRegionName = encodedRegionName; 051 this.serverName = serverName; 052 } 053 054 @Override 055 public boolean equals(Object obj) { 056 if (!(obj instanceof ScanMetricsRegionInfo)) { 057 return false; 058 } 059 ScanMetricsRegionInfo other = (ScanMetricsRegionInfo) obj; 060 return new EqualsBuilder().append(encodedRegionName, other.encodedRegionName) 061 .append(serverName, other.serverName).isEquals(); 062 } 063 064 @Override 065 public int hashCode() { 066 return new HashCodeBuilder(17, 37).append(encodedRegionName).append(serverName).toHashCode(); 067 } 068 069 @Override 070 public String toString() { 071 return getClass().getSimpleName() + "[encodedRegionName=" + encodedRegionName + ",serverName=" 072 + serverName + "]"; 073 } 074 075 public String getEncodedRegionName() { 076 return encodedRegionName; 077 } 078 079 public ServerName getServerName() { 080 return serverName; 081 } 082}