HBASE-5411 Add more metrics for ThriftMetrics (Scott Chen)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1244977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-02-16 13:56:40 +00:00
parent fe2a3d022b
commit 628e5cd9f2
2 changed files with 25 additions and 3 deletions

View File

@ -54,6 +54,10 @@ public class ThriftMetrics implements Updater {
private final MetricsIntValue callQueueLen =
new MetricsIntValue("callQueueLen", registry);
private final MetricsTimeVaryingRate numRowKeysInBatchGet =
new MetricsTimeVaryingRate("numRowKeysInBatchGet", registry);
private final MetricsTimeVaryingRate numRowKeysInBatchMutate =
new MetricsTimeVaryingRate("numRowKeysInBatchMutate", registry);
private final MetricsTimeVaryingRate timeInQueue =
new MetricsTimeVaryingRate("timeInQueue", registry);
private MetricsTimeVaryingRate thriftCall =
@ -84,6 +88,14 @@ public class ThriftMetrics implements Updater {
callQueueLen.set(len);
}
public void incNumRowKeysInBatchGet(int diff) {
numRowKeysInBatchGet.inc(diff);
}
public void incNumRowKeysInBatchMutate(int diff) {
numRowKeysInBatchMutate.inc(diff);
}
public void incMethodTime(String name, int time) {
MetricsTimeVaryingRate methodTimeMetrc = getMethodTimeMetrics(name);
if (methodTimeMetrc == null) {

View File

@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
@ -69,8 +68,8 @@ import org.apache.hadoop.hbase.thrift.generated.AlreadyExists;
import org.apache.hadoop.hbase.thrift.generated.BatchMutation;
import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
import org.apache.hadoop.hbase.thrift.generated.Hbase;
import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
import org.apache.hadoop.hbase.thrift.generated.IOError;
import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
import org.apache.hadoop.hbase.thrift.generated.Mutation;
import org.apache.hadoop.hbase.thrift.generated.TCell;
import org.apache.hadoop.hbase.thrift.generated.TRegionInfo;
@ -227,8 +226,8 @@ public class ThriftServerRunner implements Runnable {
this.conf = HBaseConfiguration.create(conf);
this.listenPort = conf.getInt(PORT_CONF_KEY, DEFAULT_LISTEN_PORT);
this.metrics = new ThriftMetrics(listenPort, conf, Hbase.Iface.class);
handler.initMetrics(metrics);
this.handler = HbaseHandlerMetricsProxy.newInstance(handler, metrics, conf);
}
/*
@ -395,6 +394,7 @@ public class ThriftServerRunner implements Runnable {
// nextScannerId and scannerMap are used to manage scanner state
protected int nextScannerId = 0;
protected HashMap<Integer, ResultScanner> scannerMap = null;
private ThriftMetrics metrics = null;
private static ThreadLocal<Map<String, HTable>> threadLocalTables =
new ThreadLocal<Map<String, HTable>>() {
@ -773,6 +773,9 @@ public class ThriftServerRunner implements Runnable {
try {
List<Get> gets = new ArrayList<Get>(rows.size());
HTable table = getTable(tableName);
if (metrics != null) {
metrics.incNumRowKeysInBatchGet(rows.size());
}
for (ByteBuffer row : rows) {
Get get = new Get(getBytes(row));
addAttributes(get, attributes);
@ -908,6 +911,9 @@ public class ThriftServerRunner implements Runnable {
Delete delete = new Delete(getBytes(row));
addAttributes(delete, attributes);
if (metrics != null) {
metrics.incNumRowKeysInBatchMutate(mutations.size());
}
// I apologize for all this mess :)
for (Mutation m : mutations) {
@ -1315,6 +1321,10 @@ public class ThriftServerRunner implements Runnable {
throw new IOError(e.getMessage());
}
}
private void initMetrics(ThriftMetrics metrics) {
this.metrics = metrics;
}
}
/**
* Adds all the attributes into the Operation object