use of org.apache.flink.runtime.taskexecutor.TaskExecutorThreadInfoGateway in project flink by apache.
the class ThreadInfoRequestCoordinatorTest method createMockTaskManagerGateway.
private static CompletableFuture<TaskExecutorThreadInfoGateway> createMockTaskManagerGateway(CompletionType completionType) {
final CompletableFuture<TaskThreadInfoResponse> responseFuture = new CompletableFuture<>();
switch(completionType) {
case SUCCESSFULLY:
ThreadInfoSample sample = JvmUtils.createThreadInfoSample(Thread.currentThread().getId(), 100).get();
responseFuture.complete(new TaskThreadInfoResponse(Collections.singletonList(sample)));
break;
case EXCEPTIONALLY:
responseFuture.completeExceptionally(new RuntimeException("Request failed."));
break;
case TIMEOUT:
executorService.schedule(() -> responseFuture.completeExceptionally(new TimeoutException(REQUEST_TIMEOUT_MESSAGE)), REQUEST_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
break;
case NEVER_COMPLETE:
// do nothing
break;
default:
throw new RuntimeException("Unknown completion type.");
}
final TaskExecutorThreadInfoGateway executorGateway = (taskExecutionAttemptId, requestParams, timeout) -> responseFuture;
return CompletableFuture.completedFuture(executorGateway);
}
use of org.apache.flink.runtime.taskexecutor.TaskExecutorThreadInfoGateway 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.TaskExecutorThreadInfoGateway in project flink by apache.
the class JobVertexThreadInfoTrackerTest method createMockResourceManagerGateway.
private static CompletableFuture<ResourceManagerGateway> createMockResourceManagerGateway() {
// ignored in TestingThreadInfoRequestCoordinator
Function<ResourceID, CompletableFuture<TaskExecutorThreadInfoGateway>> function = (resourceID) -> CompletableFuture.completedFuture(null);
TestingResourceManagerGateway testingResourceManagerGateway = new TestingResourceManagerGateway();
testingResourceManagerGateway.setRequestTaskExecutorGatewayFunction(function);
return CompletableFuture.completedFuture(testingResourceManagerGateway);
}
Aggregations