HBASE-12779 SplitTransaction: Add metrics.

This commit is contained in:
Lars Hofhansl 2015-01-05 17:13:58 -08:00
parent c348cd327b
commit 7774f964e6
8 changed files with 64 additions and 0 deletions

View File

@ -118,6 +118,16 @@ public interface MetricsRegionServerSource extends BaseSource {
*/
void updateSplitTime(long t);
/**
* Increment number of a requested splits
*/
void incrSplitRequest();
/**
* Increment number of successful splits
*/
void incrSplitSuccess();
/**
* Update the flush time histogram
* @param t time it took, in milliseconds
@ -170,6 +180,8 @@ public interface MetricsRegionServerSource extends BaseSource {
String PERCENT_FILES_LOCAL = "percentFilesLocal";
String PERCENT_FILES_LOCAL_DESC =
"The percent of HFiles that are stored on the local hdfs data node.";
String SPLIT_QUEUE_LENGTH = "splitQueueLength";
String SPLIT_QUEUE_LENGTH_DESC = "Length of the queue for splits.";
String COMPACTION_QUEUE_LENGTH = "compactionQueueLength";
String LARGE_COMPACTION_QUEUE_LENGTH = "largeCompactionQueueLength";
String SMALL_COMPACTION_QUEUE_LENGTH = "smallCompactionQueueLength";
@ -257,5 +269,9 @@ public interface MetricsRegionServerSource extends BaseSource {
+ "larger than blockingMemStoreSize";
String SPLIT_KEY = "splitTime";
String SPLIT_REQUEST_KEY = "splitRequestCount";
String SPLIT_REQUEST_DESC = "Number of splits requested";
String SPLIT_SUCCESS_KEY = "splitSuccessCounnt";
String SPLIT_SUCCESS_DESC = "Number of successfully executed splits";
String FLUSH_KEY = "flushTime";
}

View File

@ -153,6 +153,11 @@ public interface MetricsRegionServerWrapper {
*/
int getPercentFileLocal();
/**
* Get the size of the split queue
*/
int getSplitQueueSize();
/**
* Get the size of the compaction queue
*/

View File

@ -48,6 +48,8 @@ public class MetricsRegionServerSourceImpl
private final MutableCounterLong slowGet;
private final MutableCounterLong slowIncrement;
private final MutableCounterLong slowAppend;
private final MutableCounterLong splitRequest;
private final MutableCounterLong splitSuccess;
private final MetricHistogram splitTimeHisto;
private final MetricHistogram flushTimeHisto;
@ -83,6 +85,9 @@ public class MetricsRegionServerSourceImpl
splitTimeHisto = getMetricsRegistry().newHistogram(SPLIT_KEY);
flushTimeHisto = getMetricsRegistry().newHistogram(FLUSH_KEY);
splitRequest = getMetricsRegistry().newCounter(SPLIT_REQUEST_KEY, SPLIT_REQUEST_DESC, 0l);
splitSuccess = getMetricsRegistry().newCounter(SPLIT_SUCCESS_KEY, SPLIT_SUCCESS_DESC, 0l);
}
@Override
@ -140,6 +145,16 @@ public class MetricsRegionServerSourceImpl
slowAppend.incr();
}
@Override
public void incrSplitRequest() {
splitRequest.incr();
}
@Override
public void incrSplitSuccess() {
splitSuccess.incr();
}
@Override
public void updateSplitTime(long t) {
splitTimeHisto.add(t);
@ -198,6 +213,8 @@ public class MetricsRegionServerSourceImpl
rsWrap.getDataInMemoryWithoutWAL())
.addGauge(Interns.info(PERCENT_FILES_LOCAL, PERCENT_FILES_LOCAL_DESC),
rsWrap.getPercentFileLocal())
.addGauge(Interns.info(SPLIT_QUEUE_LENGTH, SPLIT_QUEUE_LENGTH_DESC),
rsWrap.getSplitQueueSize())
.addGauge(Interns.info(COMPACTION_QUEUE_LENGTH, COMPACTION_QUEUE_LENGTH_DESC),
rsWrap.getCompactionQueueSize())
.addGauge(Interns.info(FLUSH_QUEUE_LENGTH, FLUSH_QUEUE_LENGTH_DESC),

View File

@ -413,6 +413,9 @@ public class CompactSplitThread implements CompactionRequestor, PropagatingConfi
return shortCompactions.getQueue().size();
}
public int getSplitQueueSize() {
return splits.getQueue().size();
}
private boolean shouldSplitRegion() {
return (regionSplitLimit > server.getNumberOfOnlineRegions());

View File

@ -99,6 +99,14 @@ public class MetricsRegionServer {
serverSource.updateSplitTime(t);
}
public void incrSplitRequest() {
serverSource.incrSplitRequest();
}
public void incrSplitSuccess() {
serverSource.incrSplitSuccess();
}
public void updateFlushTime(long t) {
serverSource.updateFlushTime(t);
}

View File

@ -178,6 +178,14 @@ class MetricsRegionServerWrapperImpl
return regionServer.rpcServices.requestCount.get();
}
@Override
public int getSplitQueueSize() {
if (this.regionServer.compactSplitThread == null) {
return 0;
}
return this.regionServer.compactSplitThread.getSplitQueueSize();
}
@Override
public int getCompactionQueueSize() {
//The thread could be zero. if so assume there is no queue.

View File

@ -62,6 +62,7 @@ class SplitRequest implements Runnable {
return;
}
boolean success = false;
server.metricsRegionServer.incrSplitRequest();
long startTime = EnvironmentEdgeManager.currentTime();
SplitTransaction st = new SplitTransaction(parent, midKey);
try {
@ -129,6 +130,7 @@ class SplitRequest implements Runnable {
// Update regionserver metrics with the split transaction total running time
server.metricsRegionServer.updateSplitTime(endTime - startTime);
if (success) {
server.metricsRegionServer.incrSplitSuccess();
// Log success
LOG.info("Region split, hbase:meta updated, and report to master. Parent="
+ parent.getRegionNameAsString() + ", new regions: "

View File

@ -255,4 +255,9 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
public long getBlockedRequestsCount() {
return 0;
}
@Override
public int getSplitQueueSize() {
return 0;
}
}