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.
040   * @param time the time to add
041   */
042  void incTimeInQueue(long time);
043
044  /**
045   * Set the call queue length.
046   * @param len Time
047   */
048  void setCallQueueLen(int len);
049
050  /**
051   * Add how many keys were in a batch get.
052   * @param diff Num Keys
053   */
054  void incNumRowKeysInBatchGet(int diff);
055
056  /**
057   * Add how many keys were in a batch mutate.
058   * @param diff Num Keys
059   */
060  void incNumRowKeysInBatchMutate(int diff);
061
062  /**
063   * Add how long a method took
064   * @param name Method name
065   * @param time Time
066   */
067  void incMethodTime(String name, long time);
068
069  /**
070   * Add how long a call took
071   * @param time Time
072   */
073  void incCall(long time);
074
075  /**
076   * Increment how long a slow call took.
077   * @param time Time
078   */
079  void incSlowCall(long time);
080
081  /**
082   * Increment number of active thrift workers.
083   */
084  void incActiveWorkerCount();
085
086  /**
087   * Decrement number of active thrift workers.
088   */
089  void decActiveWorkerCount();
090}