use of org.apache.flink.runtime.messages.TaskThreadInfoResponse 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.messages.TaskThreadInfoResponse in project flink by apache.
the class TaskExecutor method requestThreadInfoSamples.
// ======================================================================
// RPC methods
// ======================================================================
@Override
public CompletableFuture<TaskThreadInfoResponse> requestThreadInfoSamples(final ExecutionAttemptID taskExecutionAttemptId, final ThreadInfoSamplesRequest requestParams, final Time timeout) {
final Task task = taskSlotTable.getTask(taskExecutionAttemptId);
if (task == null) {
return FutureUtils.completedExceptionally(new IllegalStateException(String.format("Cannot sample task %s. " + "Task is not known to the task manager.", taskExecutionAttemptId)));
}
final CompletableFuture<List<ThreadInfoSample>> stackTracesFuture = threadInfoSampleService.requestThreadInfoSamples(SampleableTaskAdapter.fromTask(task), requestParams);
return stackTracesFuture.thenApply(TaskThreadInfoResponse::new);
}
Aggregations