Search in sources :

Example 86 with FlinkException

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());
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 87 with FlinkException

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);
    }
}
Also used : Task(org.apache.flink.runtime.taskmanager.Task) InstanceID(org.apache.flink.runtime.instance.InstanceID) LocalUnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation) UnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.UnresolvedTaskManagerLocation) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterInformation(org.apache.flink.runtime.entrypoint.ClusterInformation) FlinkException(org.apache.flink.util.FlinkException) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) TestingResourceManagerGateway(org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway) LocalUnresolvedTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse) Test(org.junit.Test)

Example 88 with FlinkException

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);
    }
}
Also used : HeartbeatServices(org.apache.flink.runtime.heartbeat.HeartbeatServices) TestingHeartbeatServices(org.apache.flink.runtime.heartbeat.TestingHeartbeatServices) Task(org.apache.flink.runtime.taskmanager.Task) RegistrationTimeoutException(org.apache.flink.runtime.taskexecutor.exceptions.RegistrationTimeoutException) FlinkException(org.apache.flink.util.FlinkException) CompletableFuture(java.util.concurrent.CompletableFuture) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TestingResourceManagerGateway(org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) Failure(org.apache.flink.runtime.registration.RegistrationResponse.Failure) Test(org.junit.Test)

Example 89 with FlinkException

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."));
}
Also used : FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 90 with FlinkException

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());
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) FlinkJobNotFoundException(org.apache.flink.runtime.messages.FlinkJobNotFoundException) Time(org.apache.flink.api.common.time.Time) ExecutionException(java.util.concurrent.ExecutionException) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Aggregations

FlinkException (org.apache.flink.util.FlinkException)197 Test (org.junit.Test)91 CompletableFuture (java.util.concurrent.CompletableFuture)59 IOException (java.io.IOException)38 ExecutionException (java.util.concurrent.ExecutionException)26 ArrayList (java.util.ArrayList)25 JobID (org.apache.flink.api.common.JobID)24 Collection (java.util.Collection)22 CompletionException (java.util.concurrent.CompletionException)22 Configuration (org.apache.flink.configuration.Configuration)21 TimeoutException (java.util.concurrent.TimeoutException)19 FutureUtils (org.apache.flink.util.concurrent.FutureUtils)19 Time (org.apache.flink.api.common.time.Time)16 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)16 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)16 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)15 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)14 Collections (java.util.Collections)13 List (java.util.List)13 ExecutorService (java.util.concurrent.ExecutorService)13