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