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 */
018
019package org.apache.hadoop.hbase.regionserver;
020
021import java.util.Map;
022
023import org.apache.hadoop.metrics2.MetricsCollector;
024import org.apache.yetus.audience.InterfaceAudience;
025
026@InterfaceAudience.Private
027public interface MetricsUserSource extends Comparable<MetricsUserSource> {
028
029  //These client metrics will be reported through clusterStatus and hbtop only
030  interface ClientMetrics {
031    void incrementReadRequest();
032
033    void incrementWriteRequest();
034
035    String getHostName();
036
037    long getReadRequestsCount();
038
039    long getWriteRequestsCount();
040
041    void incrementFilteredReadRequests();
042
043    long getFilteredReadRequests();
044  }
045
046  String getUser();
047
048  void register();
049
050  void deregister();
051
052  void updatePut(long t);
053
054  void updateDelete(long t);
055
056  void updateGet(long t);
057
058  void updateIncrement(long t);
059
060  void updateAppend(long t);
061
062  void updateReplay(long t);
063
064  void updateScanTime(long t);
065
066  void getMetrics(MetricsCollector metricsCollector, boolean all);
067
068  /**
069   * Metrics collected at client level for a user(needed for reporting through clusterStatus
070   * and  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   *
078   * @param hostName hostname of the client
079   * @return Instance of ClientMetrics
080   */
081  ClientMetrics getOrCreateMetricsClient(String hostName);
082}