org.apache.flink.runtime.rest.messages.EmptyRequestBody Java Examples

The following examples show how to use org.apache.flink.runtime.rest.messages.EmptyRequestBody. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Flink-CEPplus   Author: ljygz   File: RestServerEndpointITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testVersioning() throws Exception {
	CompletableFuture<EmptyResponseBody> unspecifiedVersionResponse = restClient.sendRequest(
		serverAddress.getHostName(),
		serverAddress.getPort(),
		TestVersionHeaders.INSTANCE,
		EmptyMessageParameters.getInstance(),
		EmptyRequestBody.getInstance(),
		Collections.emptyList()
	);

	unspecifiedVersionResponse.get(5, TimeUnit.SECONDS);

	CompletableFuture<EmptyResponseBody> specifiedVersionResponse = restClient.sendRequest(
		serverAddress.getHostName(),
		serverAddress.getPort(),
		TestVersionHeaders.INSTANCE,
		EmptyMessageParameters.getInstance(),
		EmptyRequestBody.getInstance(),
		Collections.emptyList(),
		RestAPIVersion.V1
	);

	specifiedVersionResponse.get(5, TimeUnit.SECONDS);
}
 
Example #2
Source Project: flink   Author: flink-tpc-ds   File: JobVertexDetailsHandler.java    License: Apache License 2.0 6 votes vote down vote up
public JobVertexDetailsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobVertexDetailsInfo, JobVertexMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor,
		MetricFetcher metricFetcher) {
	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);
	this.metricFetcher = metricFetcher;
}
 
Example #3
Source Project: Flink-CEPplus   Author: ljygz   File: JarDeleteHandlerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFailedDelete() throws Exception {
	makeJarDirReadOnly();

	final HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> request = createRequest(TEST_JAR_NAME);
	try {
		jarDeleteHandler.handleRequest(request, restfulGateway).get();
	} catch (final ExecutionException e) {
		final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause());
		assertThat(throwable, instanceOf(RestHandlerException.class));

		final RestHandlerException restHandlerException = (RestHandlerException) throwable;
		assertThat(restHandlerException.getMessage(), containsString("Failed to delete jar"));
		assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
	}
}
 
Example #4
Source Project: flink   Author: flink-tpc-ds   File: JobExecutionResultHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(
		@Nonnull final HandlerRequest<EmptyRequestBody, JobMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {

	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	final CompletableFuture<JobStatus> jobStatusFuture = gateway.requestJobStatus(jobId, timeout);

	return jobStatusFuture.thenCompose(
		jobStatus -> {
			if (jobStatus.isGloballyTerminalState()) {
				return gateway
					.requestJobResult(jobId, timeout)
					.thenApply(JobExecutionResultResponseBody::created);
			} else {
				return CompletableFuture.completedFuture(
					JobExecutionResultResponseBody.inProgress());
			}
		}).exceptionally(throwable -> {
			throw propagateException(throwable);
		});
}
 
Example #5
Source Project: Flink-CEPplus   Author: ljygz   File: MetricsAvailabilityITCase.java    License: Apache License 2.0 6 votes vote down vote up
private static Collection<ResourceID> getTaskManagerIds(final RestClient restClient) throws Exception {
	final TaskManagersHeaders headers = TaskManagersHeaders.getInstance();

	final TaskManagersInfo response = fetchMetric(() ->
			restClient.sendRequest(
				HOST,
				PORT,
				headers,
				EmptyMessageParameters.getInstance(),
				EmptyRequestBody.getInstance()),
		taskManagersInfo -> !taskManagersInfo.getTaskManagerInfos().isEmpty());

	return response.getTaskManagerInfos().stream()
		.map(TaskManagerInfo::getResourceId)
		.collect(Collectors.toList());
}
 
Example #6
Source Project: flink   Author: flink-tpc-ds   File: AbstractTaskManagerFileHandler.java    License: Apache License 2.0 6 votes vote down vote up
protected AbstractTaskManagerFileHandler(
		@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		@Nonnull Time timeout,
		@Nonnull Map<String, String> responseHeaders,
		@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, M> untypedResponseMessageHeaders,
		@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
		@Nonnull TransientBlobService transientBlobService,
		@Nonnull Time cacheEntryDuration) {
	super(leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders);

	this.resourceManagerGatewayRetriever = Preconditions.checkNotNull(resourceManagerGatewayRetriever);

	this.transientBlobService = Preconditions.checkNotNull(transientBlobService);

	this.fileBlobKeys = CacheBuilder
		.newBuilder()
		.expireAfterWrite(cacheEntryDuration.toMilliseconds(), TimeUnit.MILLISECONDS)
		.removalListener(this::removeBlob)
		.build(
			new CacheLoader<ResourceID, CompletableFuture<TransientBlobKey>>() {
				@Override
				public CompletableFuture<TransientBlobKey> load(ResourceID resourceId) throws Exception {
					return loadTaskManagerFile(resourceId);
				}
		});
}
 
Example #7
Source Project: flink   Author: flink-tpc-ds   File: JobDetailsHandler.java    License: Apache License 2.0 6 votes vote down vote up
public JobDetailsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobDetailsInfo, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor,
		MetricFetcher metricFetcher) {
	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);

	this.metricFetcher = Preconditions.checkNotNull(metricFetcher);
}
 
Example #8
Source Project: flink   Author: flink-tpc-ds   File: AbstractMetricsHandlerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetMetrics() throws Exception {
	final CompletableFuture<MetricCollectionResponseBody> completableFuture =
		testMetricsHandler.handleRequest(
			new HandlerRequest<>(
				EmptyRequestBody.getInstance(),
				new TestMessageParameters(),
				Collections.emptyMap(),
				Collections.singletonMap(METRICS_FILTER_QUERY_PARAM, Collections.singletonList(TEST_METRIC_NAME))),
			mockDispatcherGateway);

	assertTrue(completableFuture.isDone());

	final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get();
	assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1));

	final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next();
	assertThat(metric.getId(), equalTo(TEST_METRIC_NAME));
	assertThat(metric.getValue(), equalTo(Integer.toString(TEST_METRIC_VALUE)));
}
 
Example #9
Source Project: Flink-CEPplus   Author: ljygz   File: JobPlanHandler.java    License: Apache License 2.0 6 votes vote down vote up
public JobPlanHandler(
	GatewayRetriever<? extends RestfulGateway> leaderRetriever,
	Time timeout,
	Map<String, String> headers,
	MessageHeaders<EmptyRequestBody, JobPlanInfo, JobMessageParameters> messageHeaders,
	ExecutionGraphCache executionGraphCache,
	Executor executor) {

	super(
		leaderRetriever,
		timeout,
		headers,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #10
Source Project: Flink-CEPplus   Author: ljygz   File: JobExceptionsHandler.java    License: Apache License 2.0 6 votes vote down vote up
public JobExceptionsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobExceptionsInfo, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {

	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #11
Source Project: Flink-CEPplus   Author: ljygz   File: JobIdsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobIdsWithStatusOverview> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request,
		@Nonnull RestfulGateway gateway) throws RestHandlerException {

	return gateway.requestMultipleJobDetails(timeout).thenApply(
		multipleJobDetails -> new JobIdsWithStatusOverview(
			multipleJobDetails
				.getJobs()
				.stream()
				.map(
					jobDetails ->
						new JobIdsWithStatusOverview.JobIdWithStatus(
							jobDetails.getJobId(),
							jobDetails.getStatus()))
				.collect(Collectors.toList())
		)
	);
}
 
Example #12
Source Project: Flink-CEPplus   Author: ljygz   File: RestClientMultipartTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFileMultipart() throws Exception {
	Collection<FileUpload> files = MULTIPART_UPLOAD_RESOURCE.getFilesToUpload().stream()
		.map(file -> new FileUpload(file.toPath(), "application/octet-stream")).collect(Collectors.toList());

	CompletableFuture<EmptyResponseBody> responseFuture = restClient.sendRequest(
		MULTIPART_UPLOAD_RESOURCE.getServerSocketAddress().getHostName(),
		MULTIPART_UPLOAD_RESOURCE.getServerSocketAddress().getPort(),
		MULTIPART_UPLOAD_RESOURCE.getFileHandler().getMessageHeaders(),
		EmptyMessageParameters.getInstance(),
		EmptyRequestBody.getInstance(),
		files
	);

	responseFuture.get();
}
 
Example #13
Source Project: Flink-CEPplus   Author: ljygz   File: JobVertexBackPressureHandlerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAbsentBackPressure() throws Exception {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT.toString());
	pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
}
 
Example #14
Source Project: flink   Author: flink-tpc-ds   File: AbstractExecutionGraphHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<R> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, M> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
	JobID jobId = request.getPathParameter(JobIDPathParameter.class);

	CompletableFuture<AccessExecutionGraph> executionGraphFuture = executionGraphCache.getExecutionGraph(jobId, gateway);

	return executionGraphFuture.thenApplyAsync(
		executionGraph -> {
			try {
				return handleRequest(request, executionGraph);
			} catch (RestHandlerException rhe) {
				throw new CompletionException(rhe);
			}
		}, executor)
		.exceptionally(throwable -> {
			throwable = ExceptionUtils.stripCompletionException(throwable);
			if (throwable instanceof FlinkJobNotFoundException) {
				throw new CompletionException(
					new NotFoundException(String.format("Job %s not found", jobId), throwable));
			} else {
				throw new CompletionException(throwable);
			}
		});
}
 
Example #15
Source Project: Flink-CEPplus   Author: ljygz   File: AggregatingSubtasksMetricsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedSubtaskMetricsParameters> request) {
	JobID jobID = request.getPathParameter(JobIDPathParameter.class);
	JobVertexID taskID = request.getPathParameter(JobVertexIdPathParameter.class);

	Collection<String> subtaskRanges = request.getQueryParameter(SubtasksFilterQueryParameter.class);
	if (subtaskRanges.isEmpty()) {
		MetricStore.TaskMetricStore taskMetricStore = store.getTaskMetricStore(jobID.toString(), taskID.toString());
		if (taskMetricStore != null) {
			return taskMetricStore.getAllSubtaskMetricStores();
		} else {
			return Collections.emptyList();
		}
	} else {
		Iterable<Integer> subtasks = getIntegerRangeFromString(subtaskRanges);
		Collection<MetricStore.ComponentMetricStore> subtaskStores = new ArrayList<>(8);
		for (int subtask : subtasks) {
			MetricStore.ComponentMetricStore subtaskMetricStore = store.getSubtaskMetricStore(jobID.toString(), taskID.toString(), subtask);
			if (subtaskMetricStore != null) {
				subtaskStores.add(subtaskMetricStore);
			}
		}
		return subtaskStores;
	}
}
 
Example #16
Source Project: Flink-CEPplus   Author: ljygz   File: JobVertexAccumulatorsHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected JobVertexAccumulatorsInfo handleRequest(
		HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
		AccessExecutionJobVertex jobVertex) throws RestHandlerException {

	StringifiedAccumulatorResult[] accs = jobVertex.getAggregatedUserAccumulatorsStringified();
	ArrayList<UserAccumulator> userAccumulatorList = new ArrayList<>(accs.length);

	for (StringifiedAccumulatorResult acc : accs) {
		userAccumulatorList.add(
			new UserAccumulator(
				acc.getName(),
				acc.getType(),
				acc.getValue()));
	}

	return new JobVertexAccumulatorsInfo(jobVertex.getJobVertexId().toString(), userAccumulatorList);
}
 
Example #17
Source Project: flink   Author: flink-tpc-ds   File: JobExecutionResultHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = TestingRestfulGateway.newBuilder().build();

	jobExecutionResultHandler = new JobExecutionResultHandler(
		() -> CompletableFuture.completedFuture(testingRestfulGateway),
		Time.seconds(10),
		Collections.emptyMap());

	testRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JobMessageParameters(),
		Collections.singletonMap("jobid", TEST_JOB_ID.toString()),
		Collections.emptyMap());
}
 
Example #18
Source Project: flink   Author: flink-tpc-ds   File: CheckpointConfigHandler.java    License: Apache License 2.0 5 votes vote down vote up
public CheckpointConfigHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, CheckpointConfigInfo, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {
	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #19
Source Project: flink   Author: flink-tpc-ds   File: SubtaskExecutionAttemptAccumulatorsHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new Abstract job vertex handler.
 *
 * @param leaderRetriever     the leader retriever
 * @param timeout             the timeout
 * @param responseHeaders     the response headers
 * @param messageHeaders      the message headers
 * @param executionGraphCache the execution graph cache
 * @param executor            the executor
 */
public SubtaskExecutionAttemptAccumulatorsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, SubtaskExecutionAttemptAccumulatorsInfo, SubtaskAttemptMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {

	super(leaderRetriever, timeout, responseHeaders, messageHeaders, executionGraphCache, executor);
}
 
Example #20
Source Project: Flink-CEPplus   Author: ljygz   File: JarSubmissionITCase.java    License: Apache License 2.0 5 votes vote down vote up
private static JarListInfo listJars(JarListHandler handler, RestfulGateway restfulGateway) throws Exception {
	HandlerRequest<EmptyRequestBody, EmptyMessageParameters> listRequest = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		EmptyMessageParameters.getInstance());
	return handler.handleRequest(listRequest, restfulGateway)
		.get();
}
 
Example #21
Source Project: Flink-CEPplus   Author: ljygz   File: JarUploadHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static HandlerRequest<EmptyRequestBody, EmptyMessageParameters> createRequest(
		final Path uploadedFile) throws HandlerRequestException, IOException {
	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		EmptyMessageParameters.getInstance(),
		Collections.emptyMap(),
		Collections.emptyMap(),
		Collections.singleton(uploadedFile.toFile()));
}
 
Example #22
Source Project: Flink-CEPplus   Author: ljygz   File: AggregatingMetricsHandlerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAggregation() throws Exception {
	Map<String, List<String>> queryParams = new HashMap<>(4);
	queryParams.put("get", Collections.singletonList("abc.metric1"));
	queryParams.put("agg", Collections.singletonList("min"));

	HandlerRequest<EmptyRequestBody, P> request = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		handler.getMessageHeaders().getUnresolvedMessageParameters(),
		pathParameters,
		queryParams
	);

	AggregatedMetricsResponseBody response = handler.handleRequest(request, MOCK_DISPATCHER_GATEWAY)
		.get();

	Collection<AggregatedMetric> aggregatedMetrics = response.getMetrics();

	assertEquals(1, aggregatedMetrics.size());
	AggregatedMetric aggregatedMetric = aggregatedMetrics.iterator().next();

	assertEquals("abc.metric1", aggregatedMetric.getId());
	assertEquals(1.0, aggregatedMetric.getMin(), 0.1);
	assertNull(aggregatedMetric.getMax());
	assertNull(aggregatedMetric.getSum());
	assertNull(aggregatedMetric.getAvg());
}
 
Example #23
Source Project: flink   Author: flink-tpc-ds   File: RestServerEndpointITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<EmptyResponseBody> handleRequest(@Nonnull final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request, @Nonnull final RestfulGateway gateway) throws RestHandlerException {
	Collection<Path> uploadedFiles = request.getUploadedFiles().stream().map(File::toPath).collect(Collectors.toList());
	if (uploadedFiles.size() != 1) {
		throw new RestHandlerException("Expected 1 file, received " + uploadedFiles.size() + '.', HttpResponseStatus.BAD_REQUEST);
	}

	try {
		lastUploadedFileContents = Files.readAllBytes(uploadedFiles.iterator().next());
	} catch (IOException e) {
		throw new RestHandlerException("Could not read contents of uploaded file.", HttpResponseStatus.INTERNAL_SERVER_ERROR, e);
	}
	return CompletableFuture.completedFuture(EmptyResponseBody.getInstance());
}
 
Example #24
Source Project: Flink-CEPplus   Author: ljygz   File: SubtaskExecutionAttemptAccumulatorsHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new Abstract job vertex handler.
 *
 * @param leaderRetriever     the leader retriever
 * @param timeout             the timeout
 * @param responseHeaders     the response headers
 * @param messageHeaders      the message headers
 * @param executionGraphCache the execution graph cache
 * @param executor            the executor
 */
public SubtaskExecutionAttemptAccumulatorsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, SubtaskExecutionAttemptAccumulatorsInfo, SubtaskAttemptMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {

	super(leaderRetriever, timeout, responseHeaders, messageHeaders, executionGraphCache, executor);
}
 
Example #25
Source Project: flink   Author: flink-tpc-ds   File: JarUploadHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JarUploadResponseBody> handleRequest(
		@Nonnull final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request,
		@Nonnull final RestfulGateway gateway) throws RestHandlerException {
	Collection<File> uploadedFiles = request.getUploadedFiles();
	if (uploadedFiles.size() != 1) {
		throw new RestHandlerException("Exactly 1 file must be sent, received " + uploadedFiles.size() + '.', HttpResponseStatus.BAD_REQUEST);
	}
	final Path fileUpload = uploadedFiles.iterator().next().toPath();
	return CompletableFuture.supplyAsync(() -> {
		if (!fileUpload.getFileName().toString().endsWith(".jar")) {
			throw new CompletionException(new RestHandlerException(
				"Only Jar files are allowed.",
				HttpResponseStatus.BAD_REQUEST));
		} else {
			final Path destination = jarDir.resolve(UUID.randomUUID() + "_" + fileUpload.getFileName());
			try {
				Files.move(fileUpload, destination);
			} catch (IOException e) {
				throw new CompletionException(new RestHandlerException(
					String.format("Could not move uploaded jar file [%s] to [%s].",
						fileUpload,
						destination),
					HttpResponseStatus.INTERNAL_SERVER_ERROR,
					e));
			}
			return new JarUploadResponseBody(destination
				.normalize()
				.toString());
		}
	}, executor);
}
 
Example #26
Source Project: Flink-CEPplus   Author: ljygz   File: TaskCheckpointStatisticDetailsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected TaskCheckpointStatisticsWithSubtaskDetails handleCheckpointRequest(
		HandlerRequest<EmptyRequestBody, TaskCheckpointMessageParameters> request,
		AbstractCheckpointStats checkpointStats) throws RestHandlerException {

	final JobVertexID jobVertexId = request.getPathParameter(JobVertexIdPathParameter.class);

	final TaskStateStats taskStatistics = checkpointStats.getTaskStateStats(jobVertexId);

	if (taskStatistics == null) {
		throw new NotFoundException("There is no checkpoint statistics for task " + jobVertexId + '.');
	}

	return createCheckpointDetails(checkpointStats, taskStatistics);
}
 
Example #27
Source Project: Flink-CEPplus   Author: ljygz   File: AggregatingMetricsHandlerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAvgAggregation() throws Exception {
	Map<String, List<String>> queryParams = new HashMap<>(4);
	queryParams.put("get", Collections.singletonList("abc.metric1"));
	queryParams.put("agg", Collections.singletonList("avg"));

	HandlerRequest<EmptyRequestBody, P> request = new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		handler.getMessageHeaders().getUnresolvedMessageParameters(),
		pathParameters,
		queryParams
	);

	AggregatedMetricsResponseBody response = handler.handleRequest(request, MOCK_DISPATCHER_GATEWAY)
		.get();

	Collection<AggregatedMetric> aggregatedMetrics = response.getMetrics();

	assertEquals(1, aggregatedMetrics.size());
	AggregatedMetric aggregatedMetric = aggregatedMetrics.iterator().next();

	assertEquals("abc.metric1", aggregatedMetric.getId());
	assertEquals(2.0, aggregatedMetric.getAvg(), 0.1);
	assertNull(aggregatedMetric.getMin());
	assertNull(aggregatedMetric.getMax());
	assertNull(aggregatedMetric.getSum());
}
 
Example #28
Source Project: flink   Author: flink-tpc-ds   File: JobAccumulatorsHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected JobAccumulatorsInfo handleRequest(HandlerRequest<EmptyRequestBody, JobAccumulatorsMessageParameters> request, AccessExecutionGraph graph) throws RestHandlerException {
	List<Boolean> queryParams = request.getQueryParameter(AccumulatorsIncludeSerializedValueQueryParameter.class);

	final boolean includeSerializedValue;
	if (!queryParams.isEmpty()) {
		includeSerializedValue = queryParams.get(0);
	} else {
		includeSerializedValue = false;
	}

	return createJobAccumulatorsInfo(graph, includeSerializedValue);
}
 
Example #29
Source Project: Flink-CEPplus   Author: ljygz   File: ClusterOverviewHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<ClusterOverviewWithVersion> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request, @Nonnull RestfulGateway gateway) {
	CompletableFuture<ClusterOverview> overviewFuture = gateway.requestClusterOverview(timeout);

	return overviewFuture.thenApply(
		statusOverview -> ClusterOverviewWithVersion.fromStatusOverview(statusOverview, version, commitID));
}
 
Example #30
Source Project: flink   Author: flink-tpc-ds   File: AbstractMetricsHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected MetricStore.ComponentMetricStore getComponentMetricStore(
	HandlerRequest<EmptyRequestBody,
		TestMessageParameters> request,
	MetricStore metricStore) {
	return returnComponentMetricStore ? metricStore.getJobManager() : null;
}