Java Code Examples for org.apache.flink.runtime.rest.messages.JobAccumulatorsHeaders

The following examples show how to use org.apache.flink.runtime.rest.messages.JobAccumulatorsHeaders. These examples are extracted from open source projects. 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   Source File: RestClusterClient.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Map<String, Object>> getAccumulators(JobID jobID, ClassLoader loader) {
	final JobAccumulatorsHeaders accumulatorsHeaders = JobAccumulatorsHeaders.getInstance();
	final JobAccumulatorsMessageParameters accMsgParams = accumulatorsHeaders.getUnresolvedMessageParameters();
	accMsgParams.jobPathParameter.resolve(jobID);
	accMsgParams.includeSerializedAccumulatorsParameter.resolve(Collections.singletonList(true));

	CompletableFuture<JobAccumulatorsInfo> responseFuture = sendRequest(
		accumulatorsHeaders,
		accMsgParams);

	return responseFuture
		.thenApply(JobAccumulatorsInfo::getSerializedUserAccumulators)
		.thenApply(accumulators -> {
			try {
				return AccumulatorHelper.deserializeAndUnwrapAccumulators(accumulators, loader);
			} catch (Exception e) {
				throw new CompletionException("Cannot deserialize and unwrap accumulators properly.", e);
			}
		});
}
 
Example 2
Source Project: Flink-CEPplus   Source File: RestClusterClient.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, OptionalFailure<Object>> getAccumulators(final JobID jobID, ClassLoader loader) throws Exception {
	final JobAccumulatorsHeaders accumulatorsHeaders = JobAccumulatorsHeaders.getInstance();
	final JobAccumulatorsMessageParameters accMsgParams = accumulatorsHeaders.getUnresolvedMessageParameters();
	accMsgParams.jobPathParameter.resolve(jobID);
	accMsgParams.includeSerializedAccumulatorsParameter.resolve(Collections.singletonList(true));

	CompletableFuture<JobAccumulatorsInfo> responseFuture = sendRequest(
		accumulatorsHeaders,
		accMsgParams);

	Map<String, OptionalFailure<Object>> result = Collections.emptyMap();

	try {
		result = responseFuture.thenApply((JobAccumulatorsInfo accumulatorsInfo) -> {
			try {
				return AccumulatorHelper.deserializeAccumulators(
					accumulatorsInfo.getSerializedUserAccumulators(),
					loader);
			} catch (Exception e) {
				throw new CompletionException(
					new FlinkException(
						String.format("Deserialization of accumulators for job %s failed.", jobID),
						e));
			}
		}).get(timeout.toMillis(), TimeUnit.MILLISECONDS);
	} catch (ExecutionException ee) {
		ExceptionUtils.rethrowException(ExceptionUtils.stripExecutionException(ee));
	}

	return result;
}
 
Example 3
Source Project: flink   Source File: RestClusterClient.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, OptionalFailure<Object>> getAccumulators(final JobID jobID, ClassLoader loader) throws Exception {
	final JobAccumulatorsHeaders accumulatorsHeaders = JobAccumulatorsHeaders.getInstance();
	final JobAccumulatorsMessageParameters accMsgParams = accumulatorsHeaders.getUnresolvedMessageParameters();
	accMsgParams.jobPathParameter.resolve(jobID);
	accMsgParams.includeSerializedAccumulatorsParameter.resolve(Collections.singletonList(true));

	CompletableFuture<JobAccumulatorsInfo> responseFuture = sendRequest(
		accumulatorsHeaders,
		accMsgParams);

	Map<String, OptionalFailure<Object>> result = Collections.emptyMap();

	try {
		result = responseFuture.thenApply((JobAccumulatorsInfo accumulatorsInfo) -> {
			try {
				return AccumulatorHelper.deserializeAccumulators(
					accumulatorsInfo.getSerializedUserAccumulators(),
					loader);
			} catch (Exception e) {
				throw new CompletionException(
					new FlinkException(
						String.format("Deserialization of accumulators for job %s failed.", jobID),
						e));
			}
		}).get(timeout.toMillis(), TimeUnit.MILLISECONDS);
	} catch (ExecutionException ee) {
		ExceptionUtils.rethrowException(ExceptionUtils.stripExecutionException(ee));
	}

	return result;
}
 
Example 4
Source Project: Flink-CEPplus   Source File: RestClusterClientTest.java    License: Apache License 2.0 4 votes vote down vote up
public TestAccumulatorHandler() {
	super(JobAccumulatorsHeaders.getInstance());
}
 
Example 5
Source Project: flink   Source File: RestClusterClientTest.java    License: Apache License 2.0 4 votes vote down vote up
public TestAccumulatorHandler() {
	super(JobAccumulatorsHeaders.getInstance());
}
 
Example 6
Source Project: flink   Source File: RestClusterClientTest.java    License: Apache License 2.0 4 votes vote down vote up
public TestAccumulatorHandler() {
	super(JobAccumulatorsHeaders.getInstance());
}