use of org.apache.flink.util.FlinkException in project flink by apache.
the class DispatcherResourceManagerComponentTest method unexpectedResourceManagerTermination_failsFatally.
@Test
public void unexpectedResourceManagerTermination_failsFatally() {
final CompletableFuture<Void> terminationFuture = new CompletableFuture<>();
final TestingFatalErrorHandler fatalErrorHandler = new TestingFatalErrorHandler();
final TestingResourceManagerService resourceManagerService = TestingResourceManagerService.newBuilder().setTerminationFuture(terminationFuture).build();
createDispatcherResourceManagerComponent(fatalErrorHandler, resourceManagerService);
final FlinkException expectedException = new FlinkException("Expected test exception.");
terminationFuture.completeExceptionally(expectedException);
final Throwable error = fatalErrorHandler.getException();
assertThat(error, containsCause(expectedException));
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class DispatcherResourceManagerComponentTest method unexpectedResourceManagerTermination_ifNotRunning_doesNotFailFatally.
@Test
public void unexpectedResourceManagerTermination_ifNotRunning_doesNotFailFatally() {
final TestingFatalErrorHandler fatalErrorHandler = new TestingFatalErrorHandler();
final CompletableFuture<Void> terminationFuture = new CompletableFuture<>();
final TestingResourceManagerService resourceManagerService = TestingResourceManagerService.newBuilder().setTerminationFuture(terminationFuture).withManualTerminationFutureCompletion().build();
final DispatcherResourceManagerComponent dispatcherResourceManagerComponent = createDispatcherResourceManagerComponent(fatalErrorHandler, resourceManagerService);
dispatcherResourceManagerComponent.closeAsync();
final FlinkException expectedException = new FlinkException("Expected test exception.");
terminationFuture.completeExceptionally(expectedException);
final CompletableFuture<Throwable> errorFuture = fatalErrorHandler.getErrorFuture();
assertThat(errorFuture, willNotComplete(Duration.ofMillis(10L)));
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class SupervisorActorTest method completesTerminationFutureExceptionallyIfActorFails.
@Test
public void completesTerminationFutureExceptionallyIfActorFails() throws Exception {
final ActorSystem actorSystem = actorSystemResource.getActorSystem();
final ActorRef supervisor = SupervisorActor.startSupervisorActor(actorSystem, actorSystem.getDispatcher());
final SupervisorActor.ActorRegistration actorRegistration = startAkkaRpcActor(supervisor, "foobar");
final CompletableFuture<Void> terminationFuture = actorRegistration.getTerminationFuture();
assertThat(terminationFuture.isDone(), is(false));
final CompletableFuture<Terminated> actorSystemTerminationFuture = actorSystem.getWhenTerminated().toCompletableFuture();
final FlinkException cause = new FlinkException("Test cause.");
actorRegistration.getActorRef().tell(Fail.exceptionally(cause), ActorRef.noSender());
try {
terminationFuture.get();
fail("Expected the termination future being completed exceptionally");
} catch (ExecutionException expected) {
ExceptionUtils.findThrowable(expected, e -> e.equals(cause)).orElseThrow(() -> new FlinkException("Unexpected exception", expected));
}
// make sure that the supervisor actor has stopped --> terminating the actor system
actorSystemTerminationFuture.join();
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class SupervisorActorTest method completesTerminationFutureExceptionallyIfActorStopsExceptionally.
@Test
public void completesTerminationFutureExceptionallyIfActorStopsExceptionally() throws Exception {
final ActorSystem actorSystem = actorSystemResource.getActorSystem();
final ActorRef supervisor = SupervisorActor.startSupervisorActor(actorSystem, actorSystem.getDispatcher());
final SupervisorActor.ActorRegistration actorRegistration = startAkkaRpcActor(supervisor, "foobar");
final CompletableFuture<Void> terminationFuture = actorRegistration.getTerminationFuture();
assertThat(terminationFuture.isDone(), is(false));
final FlinkException cause = new FlinkException("Test cause.");
actorRegistration.getActorRef().tell(TerminateWithFutureCompletion.exceptionally(cause), ActorRef.noSender());
try {
terminationFuture.get();
fail("Expected the termination future being completed exceptionally");
} catch (ExecutionException expected) {
ExceptionUtils.findThrowable(expected, e -> e.equals(cause)).orElseThrow(() -> new FlinkException("Unexpected exception", expected));
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class OperatorCoordinatorHolder method completeCheckpointOnceEventsAreDone.
private void completeCheckpointOnceEventsAreDone(final long checkpointId, final CompletableFuture<byte[]> checkpointFuture, final byte[] checkpointResult) {
final Collection<CompletableFuture<?>> pendingEvents = unconfirmedEvents.getCurrentIncompleteAndReset();
if (pendingEvents.isEmpty()) {
checkpointFuture.complete(checkpointResult);
return;
}
LOG.info("Coordinator checkpoint {} for coordinator {} is awaiting {} pending events", checkpointId, operatorId, pendingEvents.size());
final CompletableFuture<?> conjunct = FutureUtils.waitForAll(pendingEvents);
conjunct.whenComplete((success, failure) -> {
if (failure == null) {
checkpointFuture.complete(checkpointResult);
} else {
// if we reach this situation, then anyways the checkpoint cannot
// complete because
// (a) the target task really is down
// (b) we have a potentially lost RPC message and need to
// do a task failover for the receiver to restore consistency
checkpointFuture.completeExceptionally(new FlinkException("Failing OperatorCoordinator checkpoint because some OperatorEvents " + "before this checkpoint barrier were not received by the target tasks."));
}
});
}
Aggregations