Search in sources :

Example 1 with TaskExecutorMemoryConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration in project flink by apache.

the class ResourceManagerTaskExecutorTest method testDelayedRegisterTaskExecutor.

/**
 * Test delayed registration of task executor where the delay is introduced during connection
 * from resource manager to the registering task executor.
 */
@Test
public void testDelayedRegisterTaskExecutor() throws Exception {
    final Time fastTimeout = Time.milliseconds(1L);
    try {
        final OneShotLatch startConnection = new OneShotLatch();
        final OneShotLatch finishConnection = new OneShotLatch();
        // first registration is with blocking connection
        rpcService.setRpcGatewayFutureFunction(rpcGateway -> CompletableFuture.supplyAsync(() -> {
            startConnection.trigger();
            try {
                finishConnection.await();
            } catch (InterruptedException ignored) {
            }
            return rpcGateway;
        }, TestingUtils.defaultExecutor()));
        TaskExecutorRegistration taskExecutorRegistration = new TaskExecutorRegistration(taskExecutorGateway.getAddress(), taskExecutorResourceID, dataPort, jmxPort, hardwareDescription, new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), DEFAULT_SLOT_PROFILE, DEFAULT_SLOT_PROFILE);
        CompletableFuture<RegistrationResponse> firstFuture = rmGateway.registerTaskExecutor(taskExecutorRegistration, fastTimeout);
        try {
            firstFuture.get();
            fail("Should have failed because connection to taskmanager is delayed beyond timeout");
        } catch (Exception e) {
            final Throwable cause = ExceptionUtils.stripExecutionException(e);
            assertThat(cause, instanceOf(TimeoutException.class));
            assertThat(cause.getMessage(), containsString("ResourceManagerGateway.registerTaskExecutor"));
        }
        startConnection.await();
        // second registration after timeout is with no delay, expecting it to be succeeded
        rpcService.resetRpcGatewayFutureFunction();
        CompletableFuture<RegistrationResponse> secondFuture = rmGateway.registerTaskExecutor(taskExecutorRegistration, TIMEOUT);
        RegistrationResponse response = secondFuture.get();
        assertTrue(response instanceof TaskExecutorRegistrationSuccess);
        // on success, send slot report for taskmanager registration
        final SlotReport slotReport = new SlotReport(new SlotStatus(new SlotID(taskExecutorResourceID, 0), ResourceProfile.ANY));
        rmGateway.sendSlotReport(taskExecutorResourceID, ((TaskExecutorRegistrationSuccess) response).getRegistrationId(), slotReport, TIMEOUT).get();
        // let the remaining part of the first registration proceed
        finishConnection.trigger();
        Thread.sleep(1L);
        // verify that the latest registration is valid not being unregistered by the delayed
        // one
        final TaskManagerInfoWithSlots taskManagerInfoWithSlots = rmGateway.requestTaskManagerDetailsInfo(taskExecutorResourceID, TIMEOUT).get();
        assertThat(taskManagerInfoWithSlots.getTaskManagerInfo().getResourceId(), equalTo(taskExecutorResourceID));
        assertThat(taskManagerInfoWithSlots.getTaskManagerInfo().getNumberSlots(), equalTo(1));
    } finally {
        rpcService.resetRpcGatewayFutureFunction();
    }
}
Also used : SlotStatus(org.apache.flink.runtime.taskexecutor.SlotStatus) SlotReport(org.apache.flink.runtime.taskexecutor.SlotReport) TaskExecutorMemoryConfiguration(org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration) TaskExecutorRegistrationSuccess(org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess) Time(org.apache.flink.api.common.time.Time) FlinkException(org.apache.flink.util.FlinkException) FencingTokenException(org.apache.flink.runtime.rpc.exceptions.FencingTokenException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) SlotID(org.apache.flink.runtime.clusterframework.types.SlotID) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse) Test(org.junit.Test)

Example 2 with TaskExecutorMemoryConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration in project flink by apache.

the class ResourceManagerPartitionLifecycleTest method registerTaskExecutor.

public static void registerTaskExecutor(ResourceManagerGateway resourceManagerGateway, ResourceID taskExecutorId, String taskExecutorAddress) throws Exception {
    final TaskExecutorRegistration taskExecutorRegistration = new TaskExecutorRegistration(taskExecutorAddress, taskExecutorId, 1234, 23456, new HardwareDescription(42, 1337L, 1337L, 0L), new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), ResourceProfile.ZERO, ResourceProfile.ZERO);
    final CompletableFuture<RegistrationResponse> registrationFuture = resourceManagerGateway.registerTaskExecutor(taskExecutorRegistration, TestingUtils.TIMEOUT);
    assertThat(registrationFuture.get(), instanceOf(RegistrationResponse.Success.class));
}
Also used : HardwareDescription(org.apache.flink.runtime.instance.HardwareDescription) TaskExecutorMemoryConfiguration(org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse)

Example 3 with TaskExecutorMemoryConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration in project flink by apache.

the class ResourceManagerTaskExecutorTest method testDisconnectTaskExecutor.

/**
 * Tests that a TaskExecutor can disconnect from the {@link ResourceManager}.
 */
@Test
public void testDisconnectTaskExecutor() throws Exception {
    final int numberSlots = 10;
    final TaskExecutorRegistration taskExecutorRegistration = new TaskExecutorRegistration(taskExecutorGateway.getAddress(), taskExecutorResourceID, dataPort, jmxPort, hardwareDescription, new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), DEFAULT_SLOT_PROFILE, DEFAULT_SLOT_PROFILE.multiply(numberSlots));
    final RegistrationResponse registrationResponse = rmGateway.registerTaskExecutor(taskExecutorRegistration, TIMEOUT).get();
    assertThat(registrationResponse, instanceOf(TaskExecutorRegistrationSuccess.class));
    final InstanceID registrationId = ((TaskExecutorRegistrationSuccess) registrationResponse).getRegistrationId();
    final Collection<SlotStatus> slots = createSlots(numberSlots);
    final SlotReport slotReport = new SlotReport(slots);
    rmGateway.sendSlotReport(taskExecutorResourceID, registrationId, slotReport, TIMEOUT).get();
    final ResourceOverview resourceOverview = rmGateway.requestResourceOverview(TIMEOUT).get();
    assertThat(resourceOverview.getNumberTaskManagers(), is(1));
    assertThat(resourceOverview.getNumberRegisteredSlots(), is(numberSlots));
    rmGateway.disconnectTaskManager(taskExecutorResourceID, new FlinkException("testDisconnectTaskExecutor"));
    final ResourceOverview afterDisconnectResourceOverview = rmGateway.requestResourceOverview(TIMEOUT).get();
    assertThat(afterDisconnectResourceOverview.getNumberTaskManagers(), is(0));
    assertThat(afterDisconnectResourceOverview.getNumberRegisteredSlots(), is(0));
}
Also used : InstanceID(org.apache.flink.runtime.instance.InstanceID) SlotStatus(org.apache.flink.runtime.taskexecutor.SlotStatus) SlotReport(org.apache.flink.runtime.taskexecutor.SlotReport) TaskExecutorMemoryConfiguration(org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration) TaskExecutorRegistrationSuccess(org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 4 with TaskExecutorMemoryConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration in project flink by apache.

the class ResourceManagerTest method registerTaskExecutor.

private void registerTaskExecutor(ResourceManagerGateway resourceManagerGateway, ResourceID taskExecutorId, String taskExecutorAddress) throws Exception {
    TaskExecutorRegistration taskExecutorRegistration = new TaskExecutorRegistration(taskExecutorAddress, taskExecutorId, dataPort, jmxPort, hardwareDescription, new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), ResourceProfile.ZERO, ResourceProfile.ZERO);
    final CompletableFuture<RegistrationResponse> registrationFuture = resourceManagerGateway.registerTaskExecutor(taskExecutorRegistration, TestingUtils.TIMEOUT);
    assertThat(registrationFuture.get(), instanceOf(RegistrationResponse.Success.class));
}
Also used : TaskExecutorMemoryConfiguration(org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse)

Aggregations

RegistrationResponse (org.apache.flink.runtime.registration.RegistrationResponse)4 TaskExecutorMemoryConfiguration (org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration)4 SlotReport (org.apache.flink.runtime.taskexecutor.SlotReport)2 SlotStatus (org.apache.flink.runtime.taskexecutor.SlotStatus)2 TaskExecutorRegistrationSuccess (org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess)2 FlinkException (org.apache.flink.util.FlinkException)2 Test (org.junit.Test)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Time (org.apache.flink.api.common.time.Time)1 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)1 SlotID (org.apache.flink.runtime.clusterframework.types.SlotID)1 HardwareDescription (org.apache.flink.runtime.instance.HardwareDescription)1 InstanceID (org.apache.flink.runtime.instance.InstanceID)1 FencingTokenException (org.apache.flink.runtime.rpc.exceptions.FencingTokenException)1