class TaskManagerDetailsHandler extends AbstractResourceManagerHandler<RestfulGateway, EmptyRequestBody, TaskManagerDetailsInfo, TaskManagerMessageParameters> {

	@Override
	protected CompletableFuture<TaskManagerDetailsInfo> handleRequest(
			@Nonnull HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> request,
			@Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
		final ResourceID taskManagerResourceId = request.getPathParameter(TaskManagerIdPathParameter
			.class);

		CompletableFuture<TaskManagerInfo> taskManagerInfoFuture = gateway.requestTaskManagerInfo(taskManagerResourceId, timeout);

		metricFetcher.update();

		return taskManagerInfoFuture.thenApply(
			(TaskManagerInfo taskManagerInfo) -> {
				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(
					taskManagerInfo,
					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);
					}
				}
			);
	}

	public  TaskManagerDetailsHandler(
			GatewayRetriever<? extends RestfulGateway> leaderRetriever,
			Time timeout,
			Map<String, String> responseHeaders,
			MessageHeaders<EmptyRequestBody, TaskManagerDetailsInfo, TaskManagerMessageParameters> messageHeaders,
			GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
			MetricFetcher metricFetcher);

}