Search in sources :

Example 1 with JobAccumulatorsInfo

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;
}
Also used : StringifiedAccumulatorResult(org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult) ArrayList(java.util.ArrayList) JobAccumulatorsInfo(org.apache.flink.runtime.rest.messages.JobAccumulatorsInfo) SerializedValue(org.apache.flink.util.SerializedValue)

Example 2 with JobAccumulatorsInfo

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);
        }
    });
}
Also used : JobAccumulatorsMessageParameters(org.apache.flink.runtime.rest.messages.JobAccumulatorsMessageParameters) CompletionException(java.util.concurrent.CompletionException) JobAccumulatorsInfo(org.apache.flink.runtime.rest.messages.JobAccumulatorsInfo) JobAccumulatorsHeaders(org.apache.flink.runtime.rest.messages.JobAccumulatorsHeaders) JobSubmissionException(org.apache.flink.runtime.client.JobSubmissionException) ConnectTimeoutException(org.apache.flink.shaded.netty4.io.netty.channel.ConnectTimeoutException) FlinkException(org.apache.flink.util.FlinkException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) RestClientException(org.apache.flink.runtime.rest.util.RestClientException) CompletionException(java.util.concurrent.CompletionException) MalformedURLException(java.net.MalformedURLException)

Aggregations

JobAccumulatorsInfo (org.apache.flink.runtime.rest.messages.JobAccumulatorsInfo)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 CompletionException (java.util.concurrent.CompletionException)1 ExecutionException (java.util.concurrent.ExecutionException)1 StringifiedAccumulatorResult (org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult)1 JobSubmissionException (org.apache.flink.runtime.client.JobSubmissionException)1 JobAccumulatorsHeaders (org.apache.flink.runtime.rest.messages.JobAccumulatorsHeaders)1 JobAccumulatorsMessageParameters (org.apache.flink.runtime.rest.messages.JobAccumulatorsMessageParameters)1 RestClientException (org.apache.flink.runtime.rest.util.RestClientException)1 ConnectTimeoutException (org.apache.flink.shaded.netty4.io.netty.channel.ConnectTimeoutException)1 FlinkException (org.apache.flink.util.FlinkException)1 SerializedValue (org.apache.flink.util.SerializedValue)1