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 java.util.Map;
021import org.apache.hadoop.hbase.util.Bytes;
022import org.apache.yetus.audience.InterfaceAudience;
023import org.apache.yetus.audience.InterfaceStability;
024
025/**
026 * Encapsulates per-user load metrics.
027 */
028@InterfaceAudience.Public
029@InterfaceStability.Evolving
030public interface UserMetrics {
031
032  interface ClientMetrics {
033
034    String getHostName();
035
036    long getReadRequestsCount();
037
038    long getWriteRequestsCount();
039
040    long getFilteredReadRequestsCount();
041
042    String getHostAddress();
043
044    String getUserName();
045
046    String getClientVersion();
047
048    String getServiceName();
049  }
050
051  /** Returns the user name */
052  byte[] getUserName();
053
054  /** Returns the number of read requests made by user */
055  long getReadRequestCount();
056
057  /** Returns the number of write requests made by user */
058  long getWriteRequestCount();
059
060  /**
061   * Returns the number of write requests and read requests and coprocessor service requests made by
062   * the user
063   */
064  default long getRequestCount() {
065    return getReadRequestCount() + getWriteRequestCount();
066  }
067
068  /** Returns the user name as a string */
069  default String getNameAsString() {
070    return Bytes.toStringBinary(getUserName());
071  }
072
073  /** Returns metrics per client(hostname) */
074  Map<String, ClientMetrics> getClientMetrics();
075
076  /** Returns count of filtered read requests for a user */
077  long getFilteredReadRequests();
078}