use of org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder in project flink by apache.
the class JobMasterQueryableStateTest method registerSlotsRequiredForJobExecution.
private static void registerSlotsRequiredForJobExecution(JobMasterGateway jobMasterGateway, JobID jobId) throws ExecutionException, InterruptedException {
final OneShotLatch oneTaskSubmittedLatch = new OneShotLatch();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setSubmitTaskConsumer((taskDeploymentDescriptor, jobMasterId) -> {
oneTaskSubmittedLatch.trigger();
return CompletableFuture.completedFuture(Acknowledge.get());
}).createTestingTaskExecutorGateway();
JobMasterTestUtils.registerTaskExecutorAndOfferSlots(rpcService, jobMasterGateway, jobId, PARALLELISM, taskExecutorGateway, testingTimeout);
oneTaskSubmittedLatch.await();
}
use of org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder in project flink by apache.
the class ResourceManagerTest method testRequestTaskManagerInfo.
/**
* Tests that we can retrieve the correct {@link TaskManagerInfo} from the {@link
* ResourceManager}.
*/
@Test
public void testRequestTaskManagerInfo() throws Exception {
final ResourceID taskManagerId = ResourceID.generate();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setAddress(UUID.randomUUID().toString()).createTestingTaskExecutorGateway();
rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
resourceManager = new ResourceManagerBuilder().buildAndStart();
final ResourceManagerGateway resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
registerTaskExecutor(resourceManagerGateway, taskManagerId, taskExecutorGateway.getAddress());
CompletableFuture<TaskManagerInfoWithSlots> taskManagerInfoFuture = resourceManagerGateway.requestTaskManagerDetailsInfo(taskManagerId, TestingUtils.TIMEOUT);
TaskManagerInfoWithSlots taskManagerInfoWithSlots = taskManagerInfoFuture.get();
TaskManagerInfo taskManagerInfo = taskManagerInfoWithSlots.getTaskManagerInfo();
assertEquals(taskManagerId, taskManagerInfo.getResourceId());
assertEquals(hardwareDescription, taskManagerInfo.getHardwareDescription());
assertEquals(taskExecutorGateway.getAddress(), taskManagerInfo.getAddress());
assertEquals(dataPort, taskManagerInfo.getDataPort());
assertEquals(jmxPort, taskManagerInfo.getJmxPort());
assertEquals(0, taskManagerInfo.getNumberSlots());
assertEquals(0, taskManagerInfo.getNumberAvailableSlots());
assertThat(taskManagerInfoWithSlots.getAllocatedSlots(), is(empty()));
}
use of org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder in project flink by apache.
the class ResourceManagerTest method testDisconnectTaskManager.
@Test
public void testDisconnectTaskManager() throws Exception {
final ResourceID taskExecutorId = ResourceID.generate();
final CompletableFuture<Exception> disconnectFuture = new CompletableFuture<>();
final CompletableFuture<ResourceID> stopWorkerFuture = new CompletableFuture<>();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setDisconnectResourceManagerConsumer(disconnectFuture::complete).createTestingTaskExecutorGateway();
rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
resourceManager = new ResourceManagerBuilder().withStopWorkerFunction(stopWorkerFuture::complete).buildAndStart();
registerTaskExecutor(resourceManager, taskExecutorId, taskExecutorGateway.getAddress());
resourceManager.disconnectTaskManager(taskExecutorId, new FlinkException("Test exception"));
assertThat(disconnectFuture.get(), instanceOf(FlinkException.class));
assertThat(stopWorkerFuture.get(), is(taskExecutorId));
}
use of org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder in project flink by apache.
the class ResourceManagerTest method testRequestTaskExecutorGateway.
/**
* Tests that we can retrieve the correct {@link TaskExecutorGateway} from the {@link
* ResourceManager}.
*/
@Test
public void testRequestTaskExecutorGateway() throws Exception {
final ResourceID taskManagerId = ResourceID.generate();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setAddress(UUID.randomUUID().toString()).createTestingTaskExecutorGateway();
rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
resourceManager = new ResourceManagerBuilder().buildAndStart();
final ResourceManagerGateway resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
registerTaskExecutor(resourceManagerGateway, taskManagerId, taskExecutorGateway.getAddress());
CompletableFuture<TaskExecutorThreadInfoGateway> taskExecutorGatewayFuture = resourceManagerGateway.requestTaskExecutorThreadInfoGateway(taskManagerId, TestingUtils.TIMEOUT);
TaskExecutorThreadInfoGateway taskExecutorGatewayResult = taskExecutorGatewayFuture.get();
assertEquals(taskExecutorGateway, taskExecutorGatewayResult);
}
use of org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder in project flink by apache.
the class ResourceManagerTest method testTaskExecutorBecomesUnreachableTriggersDisconnect.
@Test
public void testTaskExecutorBecomesUnreachableTriggersDisconnect() throws Exception {
final ResourceID taskExecutorId = ResourceID.generate();
final CompletableFuture<Exception> disconnectFuture = new CompletableFuture<>();
final CompletableFuture<ResourceID> stopWorkerFuture = new CompletableFuture<>();
final TaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setAddress(UUID.randomUUID().toString()).setDisconnectResourceManagerConsumer(disconnectFuture::complete).setHeartbeatResourceManagerFunction(resourceId -> FutureUtils.completedExceptionally(new RecipientUnreachableException("sender", "recipient", "task executor is unreachable"))).createTestingTaskExecutorGateway();
rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
runHeartbeatTargetBecomesUnreachableTest(builder -> builder.withStopWorkerFunction((worker) -> {
stopWorkerFuture.complete(worker);
return true;
}), resourceManagerGateway -> registerTaskExecutor(resourceManagerGateway, taskExecutorId, taskExecutorGateway.getAddress()), resourceManagerResourceId -> {
assertThat(disconnectFuture.get(), instanceOf(ResourceManagerException.class));
assertThat(stopWorkerFuture.get(), is(taskExecutorId));
});
}
Aggregations