use of org.apache.flink.runtime.taskexecutor.TaskExecutorGateway 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.TaskExecutorGateway in project flink by apache.
the class JobMasterTestUtils method registerTaskExecutorAndOfferSlots.
public static void registerTaskExecutorAndOfferSlots(TestingRpcService rpcService, JobMasterGateway jobMasterGateway, JobID jobId, int numSlots, TaskExecutorGateway taskExecutorGateway, Time testingTimeout) throws ExecutionException, InterruptedException {
final UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
jobMasterGateway.registerTaskManager(jobId, TaskManagerRegistrationInformation.create(taskExecutorGateway.getAddress(), unresolvedTaskManagerLocation, TestingUtils.zeroUUID()), testingTimeout).get();
Collection<SlotOffer> slotOffers = IntStream.range(0, numSlots).mapToObj(index -> new SlotOffer(new AllocationID(), index, ResourceProfile.ANY)).collect(Collectors.toList());
jobMasterGateway.offerSlots(unresolvedTaskManagerLocation.getResourceID(), slotOffers, testingTimeout).get();
}
use of org.apache.flink.runtime.taskexecutor.TaskExecutorGateway 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.TaskExecutorGateway 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.TaskExecutorGateway 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);
}
Aggregations