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