use of org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots in project flink by apache.
the class TaskManagerDetailsHandlerTest method testTaskManagerMetricsInfoExtraction.
@Test
public void testTaskManagerMetricsInfoExtraction() throws RestHandlerException, ExecutionException, InterruptedException, JsonProcessingException, HandlerRequestException {
initializeMetricStore(metricFetcher.getMetricStore());
resourceManagerGateway.setRequestTaskManagerDetailsInfoFunction(taskManagerId -> CompletableFuture.completedFuture(new TaskManagerInfoWithSlots(createEmptyTaskManagerInfo(), Collections.emptyList())));
HandlerRequest<EmptyRequestBody> request = createRequest();
TaskManagerDetailsInfo taskManagerDetailsInfo = testInstance.handleRequest(request, resourceManagerGateway).get();
TaskManagerMetricsInfo actual = taskManagerDetailsInfo.getTaskManagerMetricsInfo();
TaskManagerMetricsInfo expected = new TaskManagerMetricsInfo(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 20L, Collections.emptyList());
ObjectMapper objectMapper = new ObjectMapper();
String actualJson = objectMapper.writeValueAsString(actual);
String expectedJson = objectMapper.writeValueAsString(expected);
assertThat(actualJson, is(expectedJson));
}
use of org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots in project flink by apache.
the class TaskManagerDetailsInfoTest method getTestResponseInstance.
@Override
protected TaskManagerDetailsInfo getTestResponseInstance() throws Exception {
final TaskManagerInfoWithSlots taskManagerInfoWithSlots = new TaskManagerInfoWithSlots(TaskManagerInfoTest.createRandomTaskManagerInfo(), Collections.singletonList(new SlotInfo(new JobID(), ResourceProfile.ANY)));
final TaskManagerMetricsInfo taskManagerMetricsInfo = createRandomTaskManagerMetricsInfo();
return new TaskManagerDetailsInfo(taskManagerInfoWithSlots, taskManagerMetricsInfo);
}
use of org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots in project flink by apache.
the class TaskManagerDetailsHandler method handleRequest.
@Override
protected CompletableFuture<TaskManagerDetailsInfo> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody> request, @Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
final ResourceID taskManagerResourceId = request.getPathParameter(TaskManagerIdPathParameter.class);
CompletableFuture<TaskManagerInfoWithSlots> taskManagerInfoWithSlotsFuture = gateway.requestTaskManagerDetailsInfo(taskManagerResourceId, timeout);
metricFetcher.update();
return taskManagerInfoWithSlotsFuture.thenApply((taskManagerInfoWithSlots) -> {
final MetricStore.TaskManagerMetricStore tmMetrics = metricStore.getTaskManagerMetricStore(taskManagerResourceId.getResourceIdString());
final TaskManagerMetricsInfo taskManagerMetricsInfo;
if (tmMetrics != null) {
log.debug("Create metrics info for TaskManager {}.", taskManagerResourceId.getStringWithMetadata());
taskManagerMetricsInfo = createTaskManagerMetricsInfo(tmMetrics);
} else {
log.debug("No metrics for TaskManager {}.", taskManagerResourceId.getStringWithMetadata());
taskManagerMetricsInfo = TaskManagerMetricsInfo.empty();
}
return new TaskManagerDetailsInfo(taskManagerInfoWithSlots, taskManagerMetricsInfo);
}).exceptionally((Throwable throwable) -> {
final Throwable strippedThrowable = ExceptionUtils.stripExecutionException(throwable);
if (strippedThrowable instanceof UnknownTaskExecutorException) {
throw new CompletionException(new RestHandlerException("Could not find TaskExecutor " + taskManagerResourceId + '.', HttpResponseStatus.NOT_FOUND, strippedThrowable));
} else {
throw new CompletionException(strippedThrowable);
}
});
}
Aggregations