use of org.apache.flink.runtime.operators.lifecycle.event.TestCommandAckEvent in project flink by apache.
the class OneInputTestStreamOperator method ack.
private void ack(TestCommand cmd) {
LOG.info("Executed command: {}", cmd);
eventQueue.add(new TestCommandAckEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), cmd));
}
use of org.apache.flink.runtime.operators.lifecycle.event.TestCommandAckEvent in project flink by apache.
the class TestJobExecutor method waitForFailover.
private void waitForFailover(BlockingQueue<TestEvent> queue) throws Exception {
int timeoutMs = 10_000;
Deadline deadline = Deadline.fromNow(Duration.ofMillis(timeoutMs));
String operatorId = null;
int subtaskId = -1;
int attemptNumber = -1;
while (deadline.hasTimeLeft()) {
TestEvent e = queue.poll(deadline.timeLeft().toMillis(), MILLISECONDS);
if (e instanceof TestCommandAckEvent) {
TestCommandAckEvent ack = (TestCommandAckEvent) e;
if (ack.getCommand() == FAIL) {
operatorId = ack.operatorId;
subtaskId = ack.subtaskIndex;
attemptNumber = ack.getAttemptNumber();
}
} else if (e instanceof OperatorStartedEvent && operatorId != null) {
OperatorStartedEvent started = (OperatorStartedEvent) e;
if (started.operatorId.equals(operatorId) && started.subtaskIndex == subtaskId && started.getAttemptNumber() >= attemptNumber) {
return;
}
}
}
throw new TimeoutException("No subtask restarted in " + timeoutMs + "ms");
}
Aggregations