HBASE-15435 Add WAL (in bytes) written metric (Alicia Ying Shu)
This commit is contained in:
parent
6628d2df11
commit
a979d85582
|
@ -62,6 +62,8 @@ public interface MetricsWALSource extends BaseSource {
|
||||||
String LOW_REPLICA_ROLL_REQUESTED = "lowReplicaRollRequest";
|
String LOW_REPLICA_ROLL_REQUESTED = "lowReplicaRollRequest";
|
||||||
String LOW_REPLICA_ROLL_REQUESTED_DESC =
|
String LOW_REPLICA_ROLL_REQUESTED_DESC =
|
||||||
"How many times a log roll was requested due to too few DN's in the write pipeline.";
|
"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.
|
* Add the append size.
|
||||||
|
@ -93,4 +95,8 @@ public interface MetricsWALSource extends BaseSource {
|
||||||
void incrementLowReplicationLogRoll();
|
void incrementLowReplicationLogRoll();
|
||||||
|
|
||||||
long getSlowAppendCount();
|
long getSlowAppendCount();
|
||||||
|
|
||||||
|
void incrementWrittenBytes(long val);
|
||||||
|
|
||||||
|
long getWrittenBytes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSo
|
||||||
private final MutableFastCounter slowAppendCount;
|
private final MutableFastCounter slowAppendCount;
|
||||||
private final MutableFastCounter logRollRequested;
|
private final MutableFastCounter logRollRequested;
|
||||||
private final MutableFastCounter lowReplicationLogRollRequested;
|
private final MutableFastCounter lowReplicationLogRollRequested;
|
||||||
|
private final MutableFastCounter writtenBytes;
|
||||||
|
|
||||||
public MetricsWALSourceImpl() {
|
public MetricsWALSourceImpl() {
|
||||||
this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT);
|
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);
|
this.getMetricsRegistry().newCounter(ROLL_REQUESTED, ROLL_REQUESTED_DESC, 0L);
|
||||||
lowReplicationLogRollRequested = this.getMetricsRegistry()
|
lowReplicationLogRollRequested = this.getMetricsRegistry()
|
||||||
.newCounter(LOW_REPLICA_ROLL_REQUESTED, LOW_REPLICA_ROLL_REQUESTED_DESC, 0L);
|
.newCounter(LOW_REPLICA_ROLL_REQUESTED, LOW_REPLICA_ROLL_REQUESTED_DESC, 0L);
|
||||||
|
writtenBytes = this.getMetricsRegistry().newCounter(WRITTEN_BYTES, WRITTEN_BYTES_DESC, 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,4 +105,15 @@ public class MetricsWALSourceImpl extends BaseSourceImpl implements MetricsWALSo
|
||||||
public long getSlowAppendCount() {
|
public long getSlowAppendCount() {
|
||||||
return slowAppendCount.value();
|
return slowAppendCount.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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.incrementAppendCount();
|
||||||
source.incrementAppendTime(time);
|
source.incrementAppendTime(time);
|
||||||
source.incrementAppendSize(size);
|
source.incrementAppendSize(size);
|
||||||
|
source.incrementWrittenBytes(size);
|
||||||
|
|
||||||
if (time > 1000) {
|
if (time > 1000) {
|
||||||
source.incrementSlowAppendCount();
|
source.incrementSlowAppendCount();
|
||||||
|
|
|
@ -66,4 +66,15 @@ public class TestMetricsWAL {
|
||||||
metricsWAL.postAppend(1, 2000);
|
metricsWAL.postAppend(1, 2000);
|
||||||
assertEquals(2, source.getSlowAppendCount());
|
assertEquals(2, source.getSlowAppendCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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