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.thrift;
019
020import org.apache.hadoop.hbase.metrics.ExceptionTrackingSource;
021import org.apache.hadoop.hbase.metrics.JvmPauseMonitorSource;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * Interface of a class that will export metrics about Thrift to hadoop's metrics2.
026 */
027@InterfaceAudience.Private
028public interface MetricsThriftServerSource extends ExceptionTrackingSource, JvmPauseMonitorSource {
029
030  String BATCH_GET_KEY = "batchGet";
031  String BATCH_MUTATE_KEY = "batchMutate";
032  String TIME_IN_QUEUE_KEY = "timeInQueue";
033  String THRIFT_CALL_KEY = "thriftCall";
034  String SLOW_THRIFT_CALL_KEY = "slowThriftCall";
035  String CALL_QUEUE_LEN_KEY = "callQueueLen";
036  String ACTIVE_WORKER_COUNT_KEY = "numActiveWorkers";
037
038  /**
039   * Add how long an operation was in the queue. n
040   */
041  void incTimeInQueue(long time);
042
043  /**
044   * Set the call queue length.
045   * @param len Time
046   */
047  void setCallQueueLen(int len);
048
049  /**
050   * Add how many keys were in a batch get.
051   * @param diff Num Keys
052   */
053  void incNumRowKeysInBatchGet(int diff);
054
055  /**
056   * Add how many keys were in a batch mutate.
057   * @param diff Num Keys
058   */
059  void incNumRowKeysInBatchMutate(int diff);
060
061  /**
062   * Add how long a method took
063   * @param name Method name
064   * @param time Time
065   */
066  void incMethodTime(String name, long time);
067
068  /**
069   * Add how long a call took
070   * @param time Time
071   */
072  void incCall(long time);
073
074  /**
075   * Increment how long a slow call took.
076   * @param time Time
077   */
078  void incSlowCall(long time);
079
080  /**
081   * Increment number of active thrift workers.
082   */
083  void incActiveWorkerCount();
084
085  /**
086   * Decrement number of active thrift workers.
087   */
088  void decActiveWorkerCount();
089}