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:
parent
fe2a3d022b
commit
628e5cd9f2
|
@ -54,6 +54,10 @@ public class ThriftMetrics implements Updater {
|
||||||
|
|
||||||
private final MetricsIntValue callQueueLen =
|
private final MetricsIntValue callQueueLen =
|
||||||
new MetricsIntValue("callQueueLen", registry);
|
new MetricsIntValue("callQueueLen", registry);
|
||||||
|
private final MetricsTimeVaryingRate numRowKeysInBatchGet =
|
||||||
|
new MetricsTimeVaryingRate("numRowKeysInBatchGet", registry);
|
||||||
|
private final MetricsTimeVaryingRate numRowKeysInBatchMutate =
|
||||||
|
new MetricsTimeVaryingRate("numRowKeysInBatchMutate", registry);
|
||||||
private final MetricsTimeVaryingRate timeInQueue =
|
private final MetricsTimeVaryingRate timeInQueue =
|
||||||
new MetricsTimeVaryingRate("timeInQueue", registry);
|
new MetricsTimeVaryingRate("timeInQueue", registry);
|
||||||
private MetricsTimeVaryingRate thriftCall =
|
private MetricsTimeVaryingRate thriftCall =
|
||||||
|
@ -84,6 +88,14 @@ public class ThriftMetrics implements Updater {
|
||||||
callQueueLen.set(len);
|
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) {
|
public void incMethodTime(String name, int time) {
|
||||||
MetricsTimeVaryingRate methodTimeMetrc = getMethodTimeMetrics(name);
|
MetricsTimeVaryingRate methodTimeMetrc = getMethodTimeMetrics(name);
|
||||||
if (methodTimeMetrc == null) {
|
if (methodTimeMetrc == null) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
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.BatchMutation;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
|
import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.Hbase;
|
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.IOError;
|
||||||
|
import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.Mutation;
|
import org.apache.hadoop.hbase.thrift.generated.Mutation;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.TCell;
|
import org.apache.hadoop.hbase.thrift.generated.TCell;
|
||||||
import org.apache.hadoop.hbase.thrift.generated.TRegionInfo;
|
import org.apache.hadoop.hbase.thrift.generated.TRegionInfo;
|
||||||
|
@ -227,8 +226,8 @@ public class ThriftServerRunner implements Runnable {
|
||||||
this.conf = HBaseConfiguration.create(conf);
|
this.conf = HBaseConfiguration.create(conf);
|
||||||
this.listenPort = conf.getInt(PORT_CONF_KEY, DEFAULT_LISTEN_PORT);
|
this.listenPort = conf.getInt(PORT_CONF_KEY, DEFAULT_LISTEN_PORT);
|
||||||
this.metrics = new ThriftMetrics(listenPort, conf, Hbase.Iface.class);
|
this.metrics = new ThriftMetrics(listenPort, conf, Hbase.Iface.class);
|
||||||
|
handler.initMetrics(metrics);
|
||||||
this.handler = HbaseHandlerMetricsProxy.newInstance(handler, metrics, conf);
|
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
|
// nextScannerId and scannerMap are used to manage scanner state
|
||||||
protected int nextScannerId = 0;
|
protected int nextScannerId = 0;
|
||||||
protected HashMap<Integer, ResultScanner> scannerMap = null;
|
protected HashMap<Integer, ResultScanner> scannerMap = null;
|
||||||
|
private ThriftMetrics metrics = null;
|
||||||
|
|
||||||
private static ThreadLocal<Map<String, HTable>> threadLocalTables =
|
private static ThreadLocal<Map<String, HTable>> threadLocalTables =
|
||||||
new ThreadLocal<Map<String, HTable>>() {
|
new ThreadLocal<Map<String, HTable>>() {
|
||||||
|
@ -773,6 +773,9 @@ public class ThriftServerRunner implements Runnable {
|
||||||
try {
|
try {
|
||||||
List<Get> gets = new ArrayList<Get>(rows.size());
|
List<Get> gets = new ArrayList<Get>(rows.size());
|
||||||
HTable table = getTable(tableName);
|
HTable table = getTable(tableName);
|
||||||
|
if (metrics != null) {
|
||||||
|
metrics.incNumRowKeysInBatchGet(rows.size());
|
||||||
|
}
|
||||||
for (ByteBuffer row : rows) {
|
for (ByteBuffer row : rows) {
|
||||||
Get get = new Get(getBytes(row));
|
Get get = new Get(getBytes(row));
|
||||||
addAttributes(get, attributes);
|
addAttributes(get, attributes);
|
||||||
|
@ -908,6 +911,9 @@ public class ThriftServerRunner implements Runnable {
|
||||||
|
|
||||||
Delete delete = new Delete(getBytes(row));
|
Delete delete = new Delete(getBytes(row));
|
||||||
addAttributes(delete, attributes);
|
addAttributes(delete, attributes);
|
||||||
|
if (metrics != null) {
|
||||||
|
metrics.incNumRowKeysInBatchMutate(mutations.size());
|
||||||
|
}
|
||||||
|
|
||||||
// I apologize for all this mess :)
|
// I apologize for all this mess :)
|
||||||
for (Mutation m : mutations) {
|
for (Mutation m : mutations) {
|
||||||
|
@ -1315,6 +1321,10 @@ public class ThriftServerRunner implements Runnable {
|
||||||
throw new IOError(e.getMessage());
|
throw new IOError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initMetrics(ThriftMetrics metrics) {
|
||||||
|
this.metrics = metrics;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Adds all the attributes into the Operation object
|
* Adds all the attributes into the Operation object
|
||||||
|
|
Loading…
Reference in New Issue