Search in sources :

Example 1 with AccumulatorResultsErroneous

use of org.apache.flink.runtime.messages.accumulators.AccumulatorResultsErroneous in project flink by apache.

the class ClusterClient method getAccumulators.

/**
	 * Requests and returns the accumulators for the given job identifier. Accumulators can be
	 * requested while a is running or after it has finished.
	 * @param jobID The job identifier of a job.
	 * @param loader The class loader for deserializing the accumulator results.
	 * @return A Map containing the accumulator's name and its value.
	 */
public Map<String, Object> getAccumulators(JobID jobID, ClassLoader loader) throws Exception {
    ActorGateway jobManagerGateway = getJobManagerGateway();
    Future<Object> response;
    try {
        response = jobManagerGateway.ask(new RequestAccumulatorResults(jobID), timeout);
    } catch (Exception e) {
        throw new Exception("Failed to query the job manager gateway for accumulators.", e);
    }
    Object result = Await.result(response, timeout);
    if (result instanceof AccumulatorResultsFound) {
        Map<String, SerializedValue<Object>> serializedAccumulators = ((AccumulatorResultsFound) result).result();
        return AccumulatorHelper.deserializeAccumulators(serializedAccumulators, loader);
    } else if (result instanceof AccumulatorResultsErroneous) {
        throw ((AccumulatorResultsErroneous) result).cause();
    } else {
        throw new Exception("Failed to fetch accumulators for the job " + jobID + ".");
    }
}
Also used : RequestAccumulatorResults(org.apache.flink.runtime.messages.accumulators.RequestAccumulatorResults) AccumulatorResultsFound(org.apache.flink.runtime.messages.accumulators.AccumulatorResultsFound) AccumulatorResultsErroneous(org.apache.flink.runtime.messages.accumulators.AccumulatorResultsErroneous) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) SerializedValue(org.apache.flink.util.SerializedValue) JobRetrievalException(org.apache.flink.runtime.client.JobRetrievalException) URISyntaxException(java.net.URISyntaxException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) IOException(java.io.IOException) CompilerException(org.apache.flink.optimizer.CompilerException)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 CompilerException (org.apache.flink.optimizer.CompilerException)1 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)1 JobRetrievalException (org.apache.flink.runtime.client.JobRetrievalException)1 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)1 AccumulatorResultsErroneous (org.apache.flink.runtime.messages.accumulators.AccumulatorResultsErroneous)1 AccumulatorResultsFound (org.apache.flink.runtime.messages.accumulators.AccumulatorResultsFound)1 RequestAccumulatorResults (org.apache.flink.runtime.messages.accumulators.RequestAccumulatorResults)1 SerializedValue (org.apache.flink.util.SerializedValue)1