Source:
public void testMetrics() throws Exception { ValidatingCheckpointHandler handler = new ValidatingCheckpointHandler(1); inputGate = createInputGate(3, handler); int bufferSize = 100; long checkpointId = 1; long sleepTime = 10; long checkpointBarrierCreation = System.currentTimeMillis(); Thread.sleep(sleepTime); long alignmentStartNanos = System.nanoTime(); addSequence(inputGate, createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize), createBarrier(checkpointId, 1, checkpointBarrierCreation), createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize), createBarrier(checkpointId, 0), createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize)); Thread.sleep(sleepTime); addSequence(inputGate, createBarrier(checkpointId, 2), createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize), createEndOfPartition(0), createEndOfPartition(1), createEndOfPartition(2)); long startDelay = System.currentTimeMillis() - checkpointBarrierCreation; long alignmentDuration = System.nanoTime() - alignmentStartNanos; assertEquals(checkpointId, inputGate.getCheckpointBarrierHandler().getLatestCheckpointId()); assertThat(inputGate.getCheckpointStartDelayNanos() / 1_000_000, Matchers.greaterThanOrEqualTo(sleepTime)); assertThat(inputGate.getCheckpointStartDelayNanos() / 1_000_000, Matchers.lessThanOrEqualTo(startDelay)); assertTrue(handler.getLastAlignmentDurationNanos().isDone()); assertThat(handler.getLastAlignmentDurationNanos().get() / 1_000_000, Matchers.greaterThanOrEqualTo(sleepTime)); assertThat(handler.getLastAlignmentDurationNanos().get(), Matchers.lessThanOrEqualTo(alignmentDuration)); }

Target:
public void testMetrics() throws Exception { ValidatingCheckpointHandler handler = new ValidatingCheckpointHandler(1); inputGate = createInputGate(3, handler); int bufferSize = 100; long checkpointId = 1; long sleepTime = 10; long checkpointBarrierCreation = System.currentTimeMillis(); Thread.sleep(sleepTime); long alignmentStartNanos = System.nanoTime(); addSequence(inputGate, createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize), createBarrier(checkpointId, 1, checkpointBarrierCreation), createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize), createBarrier(checkpointId, 0), createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize)); long startDelay = System.currentTimeMillis() - checkpointBarrierCreation; Thread.sleep(sleepTime); addSequence(inputGate, createBarrier(checkpointId, 2), createBuffer(0, bufferSize), createBuffer(1, bufferSize), createBuffer(2, bufferSize), createEndOfPartition(0), createEndOfPartition(1), createEndOfPartition(2)); long alignmentDuration = System.nanoTime() - alignmentStartNanos; assertEquals(checkpointId, inputGate.getCheckpointBarrierHandler().getLatestCheckpointId()); assertThat(inputGate.getCheckpointStartDelayNanos() / 1_000_000, Matchers.greaterThanOrEqualTo(sleepTime)); assertThat(inputGate.getCheckpointStartDelayNanos() / 1_000_000, Matchers.lessThanOrEqualTo(startDelay)); assertTrue(handler.getLastAlignmentDurationNanos().isDone()); assertThat(handler.getLastAlignmentDurationNanos().get() / 1_000_000, Matchers.greaterThanOrEqualTo(sleepTime)); assertThat(handler.getLastAlignmentDurationNanos().get(), Matchers.lessThanOrEqualTo(alignmentDuration)); assertTrue(handler.getLastBytesProcessedDuringAlignment().isDone()); assertThat(handler.getLastBytesProcessedDuringAlignment().get(), Matchers.equalTo(6L * bufferSize)); }