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

The following examples show how to use org.apache.flink.runtime.rest.messages.JobMessageParameters. 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 File: RestClusterClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, JobMessageParameters> request,
		@Nonnull DispatcherGateway gateway) throws RestHandlerException {
	if (jobExecutionResults.hasNext()) {
		lastJobExecutionResult = jobExecutionResults.next();
	}
	checkState(lastJobExecutionResult != null);
	if (lastJobExecutionResult instanceof JobExecutionResultResponseBody) {
		return CompletableFuture.completedFuture((JobExecutionResultResponseBody) lastJobExecutionResult);
	} else if (lastJobExecutionResult instanceof RestHandlerException) {
		return FutureUtils.completedExceptionally((RestHandlerException) lastJobExecutionResult);
	} else {
		throw new AssertionError();
	}
}
 
Example #2
Source File: JobExceptionsHandler.java    From Flink-CEPplus with 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 #3
Source File: JobPlanHandler.java    From Flink-CEPplus with 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 #4
Source File: JobConfigHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public JobConfigHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobConfigInfo, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {

	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #5
Source File: JobExecutionResultHandler.java    From Flink-CEPplus with 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 #6
Source File: JobDetailsHandler.java    From Flink-CEPplus with 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 #7
Source File: RestClusterClientTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, JobMessageParameters> request,
		@Nonnull DispatcherGateway gateway) throws RestHandlerException {
	if (jobExecutionResults.hasNext()) {
		lastJobExecutionResult = jobExecutionResults.next();
	}
	checkState(lastJobExecutionResult != null);
	if (lastJobExecutionResult instanceof JobExecutionResultResponseBody) {
		return CompletableFuture.completedFuture((JobExecutionResultResponseBody) lastJobExecutionResult);
	} else if (lastJobExecutionResult instanceof RestHandlerException) {
		return FutureUtils.completedExceptionally((RestHandlerException) lastJobExecutionResult);
	} else {
		throw new AssertionError();
	}
}
 
Example #8
Source File: JobPlanHandler.java    From flink with 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 #9
Source File: JobConfigHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
public JobConfigHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobConfigInfo, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {

	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #10
Source File: JobDetailsHandler.java    From flink with 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 #11
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CompletableFuture<JobExecutionResultResponseBody> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, JobMessageParameters> request,
		@Nonnull DispatcherGateway gateway) throws RestHandlerException {
	if (jobExecutionResults.hasNext()) {
		lastJobExecutionResult = jobExecutionResults.next();
	}
	checkState(lastJobExecutionResult != null);
	if (lastJobExecutionResult instanceof JobExecutionResultResponseBody) {
		return CompletableFuture.completedFuture((JobExecutionResultResponseBody) lastJobExecutionResult);
	} else if (lastJobExecutionResult instanceof RestHandlerException) {
		return FutureUtils.completedExceptionally((RestHandlerException) lastJobExecutionResult);
	} else {
		throw new AssertionError();
	}
}
 
Example #12
Source File: JobPlanHandler.java    From flink with 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 #13
Source File: JobConfigHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
public JobConfigHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobConfigInfo, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {

	super(
		leaderRetriever,
		timeout,
		responseHeaders,
		messageHeaders,
		executionGraphCache,
		executor);
}
 
Example #14
Source File: JobExecutionResultHandler.java    From flink with 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 #15
Source File: JobExecutionResultHandler.java    From flink with 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 #16
Source File: JobExceptionsHandler.java    From flink with 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 #17
Source File: JobDetailsHandler.java    From flink with 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 #18
Source File: RestClusterClient.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Requests the job details.
 *
 * @param jobId The job id
 * @return Job details
 */
public CompletableFuture<JobDetailsInfo> getJobDetails(JobID jobId) {
	final JobDetailsHeaders detailsHeaders = JobDetailsHeaders.getInstance();
	final JobMessageParameters  params = new JobMessageParameters();
	params.jobPathParameter.resolve(jobId);

	return sendRequest(
		detailsHeaders,
		params);
}
 
Example #19
Source File: RestClusterClient.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Requests the job details.
 *
 * @param jobId The job id
 * @return Job details
 */
public CompletableFuture<JobDetailsInfo> getJobDetails(JobID jobId) {
	final JobDetailsHeaders detailsHeaders = JobDetailsHeaders.getInstance();
	final JobMessageParameters  params = new JobMessageParameters();
	params.jobPathParameter.resolve(jobId);

	return sendRequest(
		detailsHeaders,
		params);
}
 
Example #20
Source File: RestClusterClient.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Requests the {@link JobResult} for the given {@link JobID}. The method retries multiple
 * times to poll the {@link JobResult} before giving up.
 *
 * @param jobId specifying the job for which to retrieve the {@link JobResult}
 * @return Future which is completed with the {@link JobResult} once the job has completed or
 * with a failure if the {@link JobResult} could not be retrieved.
 */
@Override
public CompletableFuture<JobResult> requestJobResult(@Nonnull JobID jobId) {
	return pollResourceAsync(
		() -> {
			final JobMessageParameters messageParameters = new JobMessageParameters();
			messageParameters.jobPathParameter.resolve(jobId);
			return sendRequest(
				JobExecutionResultHeaders.getInstance(),
				messageParameters);
		});
}
 
Example #21
Source File: CheckpointConfigHandler.java    From Flink-CEPplus with 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 #22
Source File: CheckpointingStatisticsHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
public CheckpointingStatisticsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, CheckpointingStatistics, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders, executionGraphCache, executor);
}
 
Example #23
Source File: CheckpointConfigHandler.java    From flink with 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 #24
Source File: CheckpointingStatisticsHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public CheckpointingStatisticsHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, CheckpointingStatistics, JobMessageParameters> messageHeaders,
		ExecutionGraphCache executionGraphCache,
		Executor executor) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders, executionGraphCache, executor);
}
 
Example #25
Source File: JobExecutionResultHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().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 #26
Source File: JobConfigHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void handleRequest_executionConfigWithSecretValues_excludesSecretValuesFromResponse() throws HandlerRequestException {
	final JobConfigHandler jobConfigHandler = new JobConfigHandler(
		() -> null,
		TestingUtils.TIMEOUT(),
		Collections.emptyMap(),
		JobConfigHeaders.getInstance(),
		new DefaultExecutionGraphCache(TestingUtils.TIMEOUT(), TestingUtils.TIMEOUT()),
		TestingUtils.defaultExecutor());

	final Map<String, String> globalJobParameters = new HashMap<>();
	globalJobParameters.put("foobar", "barfoo");
	globalJobParameters.put("bar.secret.foo", "my secret");
	globalJobParameters.put("password.to.my.safe", "12345");

	final ArchivedExecutionConfig archivedExecutionConfig = new ArchivedExecutionConfigBuilder()
		.setGlobalJobParameters(globalJobParameters)
		.build();
	final AccessExecutionGraph archivedExecutionGraph = new ArchivedExecutionGraphBuilder()
		.setArchivedExecutionConfig(archivedExecutionConfig)
		.build();
	final HandlerRequest<EmptyRequestBody, JobMessageParameters> handlerRequest = createRequest(archivedExecutionGraph.getJobID());

	final JobConfigInfo jobConfigInfoResponse = jobConfigHandler.handleRequest(handlerRequest, archivedExecutionGraph);

	final Map<String, String> filteredGlobalJobParameters = filterSecretValues(globalJobParameters);

	assertThat(jobConfigInfoResponse.getExecutionConfigInfo().getGlobalJobParameters(), is(equalTo(filteredGlobalJobParameters)));
}
 
Example #27
Source File: JobConfigHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private HandlerRequest<EmptyRequestBody, JobMessageParameters> createRequest(JobID jobId) throws HandlerRequestException {
	final Map<String, String> pathParameters = new HashMap<>();
	pathParameters.put(JobIDPathParameter.KEY, jobId.toString());

	return new HandlerRequest<>(
		EmptyRequestBody.getInstance(),
		new JobMessageParameters(),
		pathParameters,
		Collections.emptyMap());
}
 
Example #28
Source File: RestClusterClient.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Requests the job details.
 *
 * @param jobId The job id
 * @return Job details
 */
public CompletableFuture<JobDetailsInfo> getJobDetails(JobID jobId) {
	final JobDetailsHeaders detailsHeaders = JobDetailsHeaders.getInstance();
	final JobMessageParameters  params = new JobMessageParameters();
	params.jobPathParameter.resolve(jobId);

	return sendRequest(
		detailsHeaders,
		params);
}
 
Example #29
Source File: RestClusterClient.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Requests the {@link JobResult} for the given {@link JobID}. The method retries multiple
 * times to poll the {@link JobResult} before giving up.
 *
 * @param jobId specifying the job for which to retrieve the {@link JobResult}
 * @return Future which is completed with the {@link JobResult} once the job has completed or
 * with a failure if the {@link JobResult} could not be retrieved.
 */
@Override
public CompletableFuture<JobResult> requestJobResult(@Nonnull JobID jobId) {
	return pollResourceAsync(
		() -> {
			final JobMessageParameters messageParameters = new JobMessageParameters();
			messageParameters.jobPathParameter.resolve(jobId);
			return sendRequest(
				JobExecutionResultHeaders.getInstance(),
				messageParameters);
		});
}
 
Example #30
Source File: JobExecutionResultHandlerTest.java    From flink with 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());
}