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; 019 020import edu.umd.cs.findbugs.annotations.Nullable; 021import java.util.Collections; 022import java.util.List; 023import java.util.Map; 024import java.util.Set; 025import org.apache.hadoop.hbase.replication.ReplicationLoadSink; 026import org.apache.hadoop.hbase.replication.ReplicationLoadSource; 027import org.apache.yetus.audience.InterfaceAudience; 028 029/** 030 * This class is used for exporting current state of load on a RegionServer. 031 */ 032@InterfaceAudience.Public 033public interface ServerMetrics { 034 035 ServerName getServerName(); 036 037 /** Returns the version number of a regionserver. */ 038 default int getVersionNumber() { 039 return 0; 040 } 041 042 /** Returns the string type version of a regionserver. */ 043 default String getVersion() { 044 return "0.0.0"; 045 } 046 047 /** Returns the number of requests per second. */ 048 long getRequestCountPerSecond(); 049 050 /** Returns total Number of requests from the start of the region server. */ 051 long getRequestCount(); 052 053 /** Returns total Number of read requests from the start of the region server. */ 054 long getReadRequestsCount(); 055 056 /** Returns total Number of write requests from the start of the region server. */ 057 long getWriteRequestsCount(); 058 059 /** Returns the amount of used heap */ 060 Size getUsedHeapSize(); 061 062 /** Returns the maximum allowable size of the heap */ 063 Size getMaxHeapSize(); 064 065 int getInfoServerPort(); 066 067 /** 068 * Call directly from client such as hbase shell 069 * @return the list of ReplicationLoadSource 070 */ 071 List<ReplicationLoadSource> getReplicationLoadSourceList(); 072 073 /** 074 * Call directly from client such as hbase shell 075 * @return a map of ReplicationLoadSource list per peer id 076 */ 077 Map<String, List<ReplicationLoadSource>> getReplicationLoadSourceMap(); 078 079 /** 080 * Call directly from client such as hbase shell 081 */ 082 @Nullable 083 ReplicationLoadSink getReplicationLoadSink(); 084 085 /** Returns region load metrics */ 086 Map<byte[], RegionMetrics> getRegionMetrics(); 087 088 /** Returns metrics per user */ 089 Map<byte[], UserMetrics> getUserMetrics(); 090 091 /** 092 * Return the RegionServer-level and Region-level coprocessors 093 * @return string set of loaded RegionServer-level and Region-level coprocessors 094 */ 095 Set<String> getCoprocessorNames(); 096 097 /** Returns the timestamp (server side) of generating this metrics */ 098 long getReportTimestamp(); 099 100 /** Returns the last timestamp (server side) of generating this metrics */ 101 long getLastReportTimestamp(); 102 103 /** 104 * Called directly from clients such as the hbase shell 105 * @return the active monitored tasks 106 */ 107 @Nullable 108 List<ServerTask> getTasks(); 109 110 /** 111 * Returns the region cache information for the regions hosted on this server 112 * @return map of region encoded name and the size of the region cached on this region server 113 * rounded to MB 114 */ 115 Map<String, Integer> getRegionCachedInfo(); 116 117 /** 118 * The available cache space on this region server (bytes), if reported in the server load. 119 */ 120 default long getCacheFreeSize() { 121 return 0L; 122 } 123 124 /** 125 * Returns the region cold data information for the regions hosted on this server. Here, cold data 126 * refers only to region data that is classified as cold by the DataTieringManager according to 127 * the configured priority logic. These data should be kept out of block cache. 128 * @return map of region encoded name and its total cold data size, rounded to MB 129 */ 130 default Map<String, Integer> getRegionColdDataSize() { 131 return Collections.emptyMap(); 132 } 133}