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
044  String getUser();
045
046  void register();
047
048  void deregister();
049
050  void updatePut(long t);
051
052  void updateDelete(long t);
053
054  void updateGet(long time, long blockBytesScanned);
055
056  void updateIncrement(long time, long blockBytesScanned);
057
058  void updateAppend(long time, long blockBytesScanned);
059
060  void updateReplay(long t);
061
062  void updateScan(long time, long blockBytesScanned);
063
064  void updateCheckAndMutate(long blockBytesScanned);
065
066  void getMetrics(MetricsCollector metricsCollector, boolean all);
067
068  /**
069   * Metrics collected at client level for a user(needed for reporting through clusterStatus and
070   * hbtop currently)
071   * @return metrics per hostname
072   */
073  Map<String, ClientMetrics> getClientMetrics();
074
075  /**
076   * Create a instance of ClientMetrics if not present otherwise return the previous one
077   * @param hostName hostname of the client
078   * @return Instance of ClientMetrics
079   */
080  ClientMetrics getOrCreateMetricsClient(String hostName);
081}