use of org.apache.flink.util.FlinkException in project flink by apache.
the class OperatorEventValveTest method releasedEventsForwardSendFailures.
@Test
public void releasedEventsForwardSendFailures() {
final EventReceivingTasks sender = EventReceivingTasks.createForRunningTasksFailingRpcs(new FlinkException("test"));
final OperatorEventValve valve = new OperatorEventValve();
valve.markForCheckpoint(17L);
valve.tryShutValve(17L);
final CompletableFuture<Acknowledge> future = new CompletableFuture<>();
valve.sendEvent(sender.createSendAction(new TestOperatorEvent(), 10), future);
valve.openValveAndUnmarkCheckpoint();
assertTrue(future.isCompletedExceptionally());
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class TaskExecutorTest method testInitialSlotReportFailure.
/**
* Tests that the {@link TaskExecutor} tries to reconnect if the initial slot report fails.
*/
@Test
public void testInitialSlotReportFailure() throws Exception {
final TaskSlotTable<Task> taskSlotTable = TaskSlotUtils.createTaskSlotTable(1);
final UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder().setTaskSlotTable(taskSlotTable).setUnresolvedTaskManagerLocation(unresolvedTaskManagerLocation).build();
final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices);
taskExecutor.start();
try {
final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway();
final BlockingQueue<CompletableFuture<Acknowledge>> responseQueue = new ArrayBlockingQueue<>(2);
testingResourceManagerGateway.setSendSlotReportFunction(resourceIDInstanceIDSlotReportTuple3 -> {
try {
return responseQueue.take();
} catch (InterruptedException e) {
return FutureUtils.completedExceptionally(e);
}
});
final CompletableFuture<RegistrationResponse> registrationResponse = CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(new InstanceID(), testingResourceManagerGateway.getOwnResourceId(), new ClusterInformation("foobar", 1234)));
final CountDownLatch numberRegistrations = new CountDownLatch(2);
testingResourceManagerGateway.setRegisterTaskExecutorFunction(taskExecutorRegistration -> {
numberRegistrations.countDown();
return registrationResponse;
});
responseQueue.offer(FutureUtils.completedExceptionally(new FlinkException("Test exception")));
responseQueue.offer(CompletableFuture.completedFuture(Acknowledge.get()));
rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway);
resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway.getFencingToken().toUUID());
// wait for the second registration attempt
numberRegistrations.await();
} finally {
RpcUtils.terminateRpcEndpoint(taskExecutor, timeout);
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class TaskExecutorTest method testMaximumRegistrationDurationAfterConnectionLoss.
@Test
public void testMaximumRegistrationDurationAfterConnectionLoss() throws Exception {
configuration.set(TaskManagerOptions.REGISTRATION_TIMEOUT, TimeUtils.parseDuration("100 ms"));
final TaskSlotTable<Task> taskSlotTable = TaskSlotUtils.createTaskSlotTable(1);
final TaskManagerServices taskManagerServices = new TaskManagerServicesBuilder().setTaskSlotTable(taskSlotTable).build();
final TaskExecutor taskExecutor = createTaskExecutor(taskManagerServices, new HeartbeatServices(10L, 10L));
taskExecutor.start();
final CompletableFuture<ResourceID> registrationFuture = new CompletableFuture<>();
final OneShotLatch secondRegistration = new OneShotLatch();
try {
final TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway();
testingResourceManagerGateway.setRegisterTaskExecutorFunction(taskExecutorRegistration -> {
if (registrationFuture.complete(taskExecutorRegistration.getResourceId())) {
return createRegistrationResponse(testingResourceManagerGateway);
} else {
secondRegistration.trigger();
return CompletableFuture.completedFuture(new Failure(new FlinkException("Only the first registration should succeed.")));
}
});
rpc.registerGateway(testingResourceManagerGateway.getAddress(), testingResourceManagerGateway);
resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(), UUID.randomUUID());
final ResourceID registrationResourceId = registrationFuture.get();
assertThat(registrationResourceId, equalTo(taskManagerServices.getUnresolvedTaskManagerLocation().getResourceID()));
secondRegistration.await();
final Throwable error = testingFatalErrorHandler.getErrorFuture().get();
assertThat(error, is(notNullValue()));
assertThat(ExceptionUtils.stripExecutionException(error), instanceOf(RegistrationTimeoutException.class));
testingFatalErrorHandler.clearError();
} finally {
RpcUtils.terminateRpcEndpoint(taskExecutor, timeout);
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class TaskTest method testInvokableInstantiationFailed.
@Test
public void testInvokableInstantiationFailed() throws Exception {
final QueuedNoOpTaskManagerActions taskManagerActions = new QueuedNoOpTaskManagerActions();
final Task task = createTaskBuilder().setTaskManagerActions(taskManagerActions).setInvokable(InvokableNonInstantiable.class).build();
// should fail
task.run();
// verify final state
assertEquals(ExecutionState.FAILED, task.getExecutionState());
assertTrue(task.isCanceledOrFailed());
assertTrue(task.getFailureCause().getMessage().contains("instantiate"));
taskManagerActions.validateListenerMessage(ExecutionState.FAILED, task, new FlinkException("Could not instantiate the task's invokable class."));
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class DefaultExecutionGraphCacheTest method testImmediateCacheInvalidationAfterFailure.
/**
* Tests that a failure in requesting an AccessExecutionGraph from the gateway, will not create
* a cache entry --> another cache request will trigger a new gateway request.
*/
@Test
public void testImmediateCacheInvalidationAfterFailure() throws Exception {
final Time timeout = Time.milliseconds(100L);
final Time timeToLive = Time.hours(1L);
// let's first answer with a JobNotFoundException and then only with the correct result
final CountingRestfulGateway restfulGateway = createCountingRestfulGateway(expectedJobId, FutureUtils.completedExceptionally(new FlinkJobNotFoundException(expectedJobId)), CompletableFuture.completedFuture(expectedExecutionGraphInfo));
try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
CompletableFuture<ExecutionGraphInfo> executionGraphFuture = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
try {
executionGraphFuture.get();
fail("The execution graph future should have been completed exceptionally.");
} catch (ExecutionException ee) {
ee.printStackTrace();
assertTrue(ee.getCause() instanceof FlinkException);
}
CompletableFuture<ExecutionGraphInfo> executionGraphFuture2 = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
assertEquals(expectedExecutionGraphInfo, executionGraphFuture2.get());
}
}
Aggregations