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.regionserver;
019
020import java.util.Map;
021import org.apache.hadoop.metrics2.MetricsCollector;
022import org.apache.yetus.audience.InterfaceAudience;
023
024@InterfaceAudience.Private
025public interface MetricsUserSource extends Comparable<MetricsUserSource> {
026
027  // These client metrics will be reported through clusterStatus and hbtop only
028  interface ClientMetrics {
029    void incrementReadRequest();
030
031    void incrementWriteRequest();
032
033    String getHostName();
034
035    long getReadRequestsCount();
036
037    long getWriteRequestsCount();
038
039    void incrementFilteredReadRequests();
040
041    long getFilteredReadRequests();
042
043    String getHostAddress();
044
045    String getUserName();
046
047    String getClientVersion();
048
049    String getServiceName();
050  }
051
052  String getUser();
053
054  void register();
055
056  void deregister();
057
058  void updatePut(long t);
059
060  void updateDelete(long t);
061
062  void updateGet(long time, long blockBytesScanned);
063
064  void updateIncrement(long time, long blockBytesScanned);
065
066  void updateAppend(long time, long blockBytesScanned);
067
068  void updateReplay(long t);
069
070  void updateScan(long time, long blockBytesScanned);
071
072  void updateCheckAndMutate(long blockBytesScanned);
073
074  void getMetrics(MetricsCollector metricsCollector, boolean all);
075
076  /**
077   * Metrics collected at client level for a user(needed for reporting through clusterStatus and
078   * hbtop currently)
079   * @return metrics per hostname
080   */
081  Map<String, ClientMetrics> getClientMetrics();
082
083  /**
084   * Create a instance of ClientMetrics if not present otherwise return the previous one
085   * @param hostName hostname of the client
086   * @return Instance of ClientMetrics
087   */
088  ClientMetrics getOrCreateMetricsClient(String hostName, String hostAddress, String userName,
089    String clientVersion, String serviceName);
090}