use of org.apache.flink.runtime.rest.messages.JobAccumulatorsInfo in project flink by apache.
the class JobAccumulatorsHandler method createJobAccumulatorsInfo.
private static JobAccumulatorsInfo createJobAccumulatorsInfo(AccessExecutionGraph graph, boolean includeSerializedValue) {
StringifiedAccumulatorResult[] stringifiedAccs = graph.getAccumulatorResultsStringified();
List<JobAccumulatorsInfo.UserTaskAccumulator> userTaskAccumulators = new ArrayList<>(stringifiedAccs.length);
for (StringifiedAccumulatorResult acc : stringifiedAccs) {
userTaskAccumulators.add(new JobAccumulatorsInfo.UserTaskAccumulator(acc.getName(), acc.getType(), acc.getValue()));
}
JobAccumulatorsInfo accumulatorsInfo;
if (includeSerializedValue) {
Map<String, SerializedValue<OptionalFailure<Object>>> serializedUserTaskAccumulators = graph.getAccumulatorsSerialized();
accumulatorsInfo = new JobAccumulatorsInfo(Collections.emptyList(), userTaskAccumulators, serializedUserTaskAccumulators);
} else {
accumulatorsInfo = new JobAccumulatorsInfo(Collections.emptyList(), userTaskAccumulators, Collections.emptyMap());
}
return accumulatorsInfo;
}
use of org.apache.flink.runtime.rest.messages.JobAccumulatorsInfo in project flink by apache.
the class RestClusterClient method getAccumulators.
@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);
}
});
}
Aggregations