HBASE-15435 Add WAL (in bytes) written metric (Alicia Ying Shu)
Conflicts: hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSource.java hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/wal/MetricsWALSourceImpl.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java
This commit is contained in:
parent
75547a42b9
commit
95421d276e
|
@ -62,6 +62,8 @@ public interface MetricsWALSource extends BaseSource {
|
|||
String LOW_REPLICA_ROLL_REQUESTED = "lowReplicaRollRequest";
|
||||
String LOW_REPLICA_ROLL_REQUESTED_DESC =
|
||||
"How many times a log roll was requested due to too few DN's in the write pipeline.";
|
||||
String WRITTEN_BYTES = "writtenBytes";
|
||||
String WRITTEN_BYTES_DESC = "Size (in bytes) of the data written to the WAL.";
|
||||
|
||||
/**
|
||||
* Add the append size.
|
||||
|
@ -92,4 +94,7 @@ public interface MetricsWALSource extends BaseSource {
|
|||
|
||||
void incrementLowReplicationLogRoll();
|
||||
|
||||
void incrementWrittenBytes(long val);
|
||||
|
||||
long getWrittenBytes();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSo
|
|||
private final MutableFastCounter slowAppendCount;
|
||||
private final MutableFastCounter logRollRequested;
|
||||
private final MutableFastCounter lowReplicationLogRollRequested;
|
||||
private final MutableFastCounter writtenBytes;
|
||||
|
||||
public MetricsWALSourceImpl() {
|
||||
this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT);
|
||||
|
@ -62,6 +63,7 @@ public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSo
|
|||
this.getMetricsRegistry().newCounter(ROLL_REQUESTED, ROLL_REQUESTED_DESC, 0L);
|
||||
lowReplicationLogRollRequested = this.getMetricsRegistry()
|
||||
.newCounter(LOW_REPLICA_ROLL_REQUESTED, LOW_REPLICA_ROLL_REQUESTED_DESC, 0L);
|
||||
writtenBytes = this.getMetricsRegistry().newCounter(WRITTEN_BYTES, WRITTEN_BYTES_DESC, 0l);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,4 +100,15 @@ public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSo
|
|||
public void incrementLowReplicationLogRoll() {
|
||||
lowReplicationLogRollRequested.incr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementWrittenBytes(long val) {
|
||||
writtenBytes.incr(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWrittenBytes() {
|
||||
return writtenBytes.value();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class MetricsWAL extends WALActionsListener.Base {
|
|||
source.incrementAppendCount();
|
||||
source.incrementAppendTime(time);
|
||||
source.incrementAppendSize(size);
|
||||
source.incrementWrittenBytes(size);
|
||||
|
||||
if (time > 1000) {
|
||||
source.incrementSlowAppendCount();
|
||||
|
|
|
@ -52,4 +52,15 @@ public class TestMetricsWAL {
|
|||
metricsWAL.postSync(nanos, 1);
|
||||
verify(source, times(1)).incrementSyncTime(145);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWalWrittenInBytes() throws Exception {
|
||||
MetricsWALSource source = mock(MetricsWALSourceImpl.class);
|
||||
MetricsWAL metricsWAL = new MetricsWAL(source);
|
||||
metricsWAL.postAppend(100, 900);
|
||||
metricsWAL.postAppend(200, 2000);
|
||||
verify(source, times(1)).incrementWrittenBytes(100);
|
||||
verify(source, times(1)).incrementWrittenBytes(200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue