class AbstractMetricsHandler extends AbstractJsonRequestHandler {

	@Override
	public CompletableFuture<String> handleJsonRequest(Map<String, String> pathParams, Map<String, String> queryParams, JobManagerGateway jobManagerGateway) {
		return CompletableFuture.supplyAsync(
			() -> {
				fetcher.update();
				String requestedMetricsList = queryParams.get(PARAMETER_METRICS);
				try {
					return requestedMetricsList != null
						? getMetricsValues(pathParams, requestedMetricsList)
						: getAvailableMetricsList(pathParams);
				} catch (IOException e) {
					throw new CompletionException(new FlinkException("Could not retrieve metrics.", e));
				}
			},
			executor);

	}

	public  AbstractMetricsHandler(Executor executor, MetricFetcher fetcher);

}