@Override public void logRollRequested(boolean underReplicated) { source.incrementLogRollRequested(); if (underReplicated) { source.incrementLowReplicationLogRoll(); } } }
@Override public void postSync(final long timeInNanos, final int handlerSyncs) { source.incrementSyncTime(timeInNanos/1000000L); }
@Override public long getNumWALSlowAppend() { return metricsWALSource.getSlowAppendCount(); }
@Override public void postAppend(final long size, final long time, final WALKey logkey, final WALEdit logEdit) throws IOException { source.incrementAppendCount(); source.incrementAppendTime(time); source.incrementAppendSize(size); source.incrementWrittenBytes(size); if (time > 1000) { source.incrementSlowAppendCount(); LOG.warn(String.format("%s took %d ms appending an edit to wal; len~=%s", Thread.currentThread().getName(), time, StringUtils.humanReadableInt(size))); } }
@Test public void testWalWrittenInBytes() throws Exception { MetricsWALSource source = mock(MetricsWALSourceImpl.class); MetricsWAL metricsWAL = new MetricsWAL(source); metricsWAL.postAppend(100, 900, null, null); metricsWAL.postAppend(200, 2000, null, null); verify(source, times(1)).incrementWrittenBytes(100); verify(source, times(1)).incrementWrittenBytes(200); }
@Override public void postAppend(final long size, final long time) { source.incrementAppendCount(); source.incrementAppendTime(time); source.incrementAppendSize(size); if (time > 1000) { source.incrementSlowAppendCount(); LOG.warn(String.format("%s took %d ms appending an edit to wal; len~=%s", Thread.currentThread().getName(), time, StringUtils.humanReadableInt(size))); } }
@Test public void testWalWrittenInBytes() throws Exception { MetricsWALSource source = mock(MetricsWALSourceImpl.class); MetricsWAL metricsWAL = new MetricsWAL(source); metricsWAL.postAppend(100, 900, null, null); metricsWAL.postAppend(200, 2000, null, null); verify(source, times(1)).incrementWrittenBytes(100); verify(source, times(1)).incrementWrittenBytes(200); }
@Test public void testLogRollRequested() throws Exception { MetricsWALSource source = mock(MetricsWALSourceImpl.class); MetricsWAL metricsWAL = new MetricsWAL(source); metricsWAL.logRollRequested(false); metricsWAL.logRollRequested(true); // Log roll was requested twice verify(source, times(2)).incrementLogRollRequested(); // One was because of low replication on the hlog. verify(source, times(1)).incrementLowReplicationLogRoll(); }
@Test public void testPostSync() throws Exception { long nanos = TimeUnit.MILLISECONDS.toNanos(145); MetricsWALSource source = mock(MetricsWALSourceImpl.class); MetricsWAL metricsWAL = new MetricsWAL(source); metricsWAL.postSync(nanos, 1); verify(source, times(1)).incrementSyncTime(145); }
@Test public void testSlowAppend() throws Exception { MetricsWALSource source = new MetricsWALSourceImpl(); MetricsWAL metricsWAL = new MetricsWAL(source); // One not so slow append (< 1000) metricsWAL.postAppend(1, 900, null, null); // Two slow appends (> 1000) metricsWAL.postAppend(1, 1010, null, null); metricsWAL.postAppend(1, 2000, null, null); assertEquals(2, source.getSlowAppendCount()); }
@Override public void logRollRequested(boolean underReplicated) { source.incrementLogRollRequested(); if (underReplicated) { source.incrementLowReplicationLogRoll(); } } }
@Override public void postSync(final long timeInNanos, final int handlerSyncs) { source.incrementSyncTime(timeInNanos/1000000L); }
@Test public void testSlowAppend() throws Exception { MetricsWALSource source = new MetricsWALSourceImpl(); MetricsWAL metricsWAL = new MetricsWAL(source); // One not so slow append (< 1000) metricsWAL.postAppend(1, 900, null, null); // Two slow appends (> 1000) metricsWAL.postAppend(1, 1010, null, null); metricsWAL.postAppend(1, 2000, null, null); assertEquals(2, source.getSlowAppendCount()); }
@Test public void testLogRollRequested() throws Exception { MetricsWALSource source = mock(MetricsWALSourceImpl.class); MetricsWAL metricsWAL = new MetricsWAL(source); metricsWAL.logRollRequested(false); metricsWAL.logRollRequested(true); // Log roll was requested twice verify(source, times(2)).incrementLogRollRequested(); // One was because of low replication on the hlog. verify(source, times(1)).incrementLowReplicationLogRoll(); }
@Test public void testPostSync() throws Exception { long nanos = TimeUnit.MILLISECONDS.toNanos(145); MetricsWALSource source = mock(MetricsWALSourceImpl.class); MetricsWAL metricsWAL = new MetricsWAL(source); metricsWAL.postSync(nanos, 1); verify(source, times(1)).incrementSyncTime(145); }