001/**
002 * Copyright The Apache Software Foundation
003 *
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020
021package org.apache.hadoop.hbase;
022
023import java.util.Map;
024
025import org.apache.hadoop.hbase.util.Bytes;
026import org.apache.yetus.audience.InterfaceAudience;
027import org.apache.yetus.audience.InterfaceStability;
028
029/**
030  * Encapsulates per-user load metrics.
031  */
032@InterfaceAudience.Public
033@InterfaceStability.Evolving
034public interface UserMetrics {
035
036  interface ClientMetrics {
037
038    String getHostName();
039
040    long getReadRequestsCount();
041
042    long getWriteRequestsCount();
043
044    long getFilteredReadRequestsCount();
045  }
046
047  /**
048   * @return the user name
049   */
050  byte[] getUserName();
051
052  /**
053   * @return the number of read requests made by user
054   */
055  long getReadRequestCount();
056
057  /**
058   * @return the number of write requests made by user
059   */
060  long getWriteRequestCount();
061
062  /**
063   * @return the number of write requests and read requests and coprocessor
064   *         service requests made by the user
065   */
066  default long getRequestCount() {
067    return getReadRequestCount() + getWriteRequestCount();
068  }
069
070  /**
071   * @return the user name as a string
072   */
073  default String getNameAsString() {
074    return Bytes.toStringBinary(getUserName());
075  }
076
077  /**
078   * @return metrics per client(hostname)
079   */
080  Map<String, ClientMetrics> getClientMetrics();
081
082  /**
083   * @return count of filtered read requests for a user
084   */
085  long getFilteredReadRequests();
086}