use of org.apache.flink.runtime.operators.testutils.DummyCheckpointInvokable in project flink by apache.
the class StreamTaskNetworkInputTest method testSnapshotAfterEndOfPartition.
@Test
public void testSnapshotAfterEndOfPartition() throws Exception {
int numInputChannels = 1;
int channelId = 0;
int checkpointId = 0;
VerifyRecordsDataOutput<Long> output = new VerifyRecordsDataOutput<>();
LongSerializer inSerializer = LongSerializer.INSTANCE;
StreamTestSingleInputGate<Long> inputGate = new StreamTestSingleInputGate<>(numInputChannels, 0, inSerializer, 1024);
StreamTaskInput<Long> input = new StreamTaskNetworkInput<>(new CheckpointedInputGate(inputGate.getInputGate(), SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", new DummyCheckpointInvokable(), SystemClock.getInstance(), false, inputGate.getInputGate()), new SyncMailboxExecutor()), inSerializer, ioManager, new StatusWatermarkValve(numInputChannels), 0);
inputGate.sendEvent(new CheckpointBarrier(checkpointId, 0L, CheckpointOptions.forCheckpointWithDefaultLocation().toUnaligned()), channelId);
inputGate.sendElement(new StreamRecord<>(42L), channelId);
assertHasNextElement(input, output);
assertHasNextElement(input, output);
assertEquals(1, output.getNumberOfEmittedRecords());
// send EndOfPartitionEvent and ensure that deserializer has been released
inputGate.sendEvent(EndOfPartitionEvent.INSTANCE, channelId);
input.emitNext(output);
// now snapshot all inflight buffers
CompletableFuture<Void> completableFuture = input.prepareSnapshot(ChannelStateWriter.NO_OP, checkpointId);
completableFuture.join();
}
use of org.apache.flink.runtime.operators.testutils.DummyCheckpointInvokable in project flink by apache.
the class AlignedCheckpointsMassiveRandomTest method testWithTwoChannelsAndRandomBarriers.
@Test
public void testWithTwoChannelsAndRandomBarriers() throws Exception {
NetworkBufferPool networkBufferPool1 = null;
NetworkBufferPool networkBufferPool2 = null;
try {
networkBufferPool1 = new NetworkBufferPool(100, PAGE_SIZE);
networkBufferPool2 = new NetworkBufferPool(100, PAGE_SIZE);
BufferPool pool1 = networkBufferPool1.createBufferPool(100, 100);
BufferPool pool2 = networkBufferPool2.createBufferPool(100, 100);
RandomGeneratingInputGate myIG = new RandomGeneratingInputGate(new BufferPool[] { pool1, pool2 }, new BarrierGenerator[] { new CountBarrier(100000), new RandomBarrier(100000) });
CheckpointedInputGate checkpointedInputGate = new CheckpointedInputGate(myIG, SingleCheckpointBarrierHandler.aligned("Testing: No task associated", new DummyCheckpointInvokable(), SystemClock.getInstance(), myIG.getNumberOfInputChannels(), (callable, duration) -> () -> {
}, true, myIG), new SyncMailboxExecutor());
for (int i = 0; i < 2000000; i++) {
BufferOrEvent boe = checkpointedInputGate.pollNext().get();
if (boe.isBuffer()) {
boe.getBuffer().recycleBuffer();
}
}
} finally {
if (networkBufferPool1 != null) {
networkBufferPool1.destroyAllBufferPools();
networkBufferPool1.destroy();
}
if (networkBufferPool2 != null) {
networkBufferPool2.destroyAllBufferPools();
networkBufferPool2.destroy();
}
}
}
Aggregations