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
043  /** Returns the user name */
044  byte[] getUserName();
045
046  /** Returns the number of read requests made by user */
047  long getReadRequestCount();
048
049  /** Returns the number of write requests made by user */
050  long getWriteRequestCount();
051
052  /**
053   * Returns the number of write requests and read requests and coprocessor service requests made by
054   * the user
055   */
056  default long getRequestCount() {
057    return getReadRequestCount() + getWriteRequestCount();
058  }
059
060  /** Returns the user name as a string */
061  default String getNameAsString() {
062    return Bytes.toStringBinary(getUserName());
063  }
064
065  /** Returns metrics per client(hostname) */
066  Map<String, ClientMetrics> getClientMetrics();
067
068  /** Returns count of filtered read requests for a user */
069  long getFilteredReadRequests();
070}