use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent in project flink by apache.
the class MultiInputTestOperator method snapshotState.
@Override
public void snapshotState(StateSnapshotContext context) throws Exception {
eventQueue.add(new CheckpointStartedEvent(operatorId, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), context.getCheckpointId()));
super.snapshotState(context);
}
use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent in project flink by apache.
the class FinishingValidator method validateOperatorLifecycle.
@Override
public void validateOperatorLifecycle(TestJobWithDescription job, String operatorId, int subtaskIndex, List<TestEvent> operatorEvents) {
boolean opFinished = false;
Set<Long> finalCheckpointCandidates = new HashSet<>();
for (TestEvent ev : operatorEvents) {
if (ev instanceof OperatorFinishedEvent) {
opFinished = true;
} else if (ev instanceof CheckpointStartedEvent) {
if (opFinished) {
finalCheckpointCandidates.add(((CheckpointStartedEvent) ev).checkpointID);
}
} else if (ev instanceof CheckpointCompletedEvent) {
if (finalCheckpointCandidates.contains(((CheckpointCompletedEvent) ev).checkpointID)) {
return;
}
} else if (opFinished) {
fail(format("Unexpected event after operator %s[%d] finished: %s", operatorId, subtaskIndex, ev));
}
}
assertTrue(format("Operator %s[%d] wasn't finished (events: %s)", operatorId, subtaskIndex, operatorEvents), opFinished);
fail(format("Operator %s[%d] was finished but didn't finish the checkpoint after that;" + "checkpoints started after finish: %s (events (excluding watermarks): %s)", operatorId, subtaskIndex, finalCheckpointCandidates, operatorEvents.stream().filter(ev -> !(ev instanceof WatermarkReceivedEvent)).collect(toList())));
}
use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent in project flink by apache.
the class OneInputTestStreamOperator method snapshotState.
@Override
public void snapshotState(StateSnapshotContext context) throws Exception {
if (receivedCommands.remove(DELAY_SNAPSHOT)) {
Thread.sleep(10);
}
if (receivedCommands.remove(FAIL_SNAPSHOT)) {
ackAndFail(FAIL_SNAPSHOT);
}
eventQueue.add(new CheckpointStartedEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), context.getCheckpointId()));
super.snapshotState(context);
}
use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent in project flink by apache.
the class SameCheckpointValidator method validateOperatorLifecycle.
@Override
public void validateOperatorLifecycle(TestJobWithDescription job, String operatorId, int subtaskIndex, List<TestEvent> operatorEvents) {
boolean started = false;
boolean finished = false;
for (TestEvent ev : operatorEvents) {
if (ev instanceof CheckpointStartedEvent) {
if (lastCheckpointID == ((CheckpointStartedEvent) ev).checkpointID) {
assertFalse(format("Operator %s[%d] started checkpoint %d twice", operatorId, subtaskIndex, lastCheckpointID), started);
started = true;
}
} else if (ev instanceof CheckpointCompletedEvent) {
if (lastCheckpointID == ((CheckpointCompletedEvent) ev).checkpointID) {
assertTrue(format("Operator %s[%d] finished checkpoint %d before starting", operatorId, subtaskIndex, lastCheckpointID), started);
assertFalse(format("Operator %s[%d] finished checkpoint %d twice", operatorId, subtaskIndex, lastCheckpointID), finished);
finished = true;
}
}
}
assertTrue(format("Operator %s[%d] didn't finish checkpoint %d (events: %s)", operatorId, subtaskIndex, lastCheckpointID, operatorEvents), finished);
}
use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent in project flink by apache.
the class TwoInputTestStreamOperator method snapshotState.
@Override
public void snapshotState(StateSnapshotContext context) throws Exception {
collectEvent(new CheckpointStartedEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), context.getCheckpointId()));
super.snapshotState(context);
}
Aggregations