Search in sources :

Example 6 with OptionalFailure

use of org.apache.flink.util.OptionalFailure in project flink by apache.

the class JobResultSerializer method serialize.

@Override
public void serialize(final JobResult result, final JsonGenerator gen, final SerializerProvider provider) throws IOException {
    gen.writeStartObject();
    gen.writeFieldName(FIELD_NAME_JOB_ID);
    jobIdSerializer.serialize(result.getJobId(), gen, provider);
    gen.writeFieldName(FIELD_NAME_APPLICATION_STATUS);
    gen.writeString(result.getApplicationStatus().name());
    gen.writeFieldName(FIELD_NAME_ACCUMULATOR_RESULTS);
    gen.writeStartObject();
    final Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = result.getAccumulatorResults();
    for (final Map.Entry<String, SerializedValue<OptionalFailure<Object>>> nameValue : accumulatorResults.entrySet()) {
        final String name = nameValue.getKey();
        final SerializedValue<OptionalFailure<Object>> value = nameValue.getValue();
        gen.writeFieldName(name);
        serializedValueSerializer.serialize(value, gen, provider);
    }
    gen.writeEndObject();
    gen.writeNumberField(FIELD_NAME_NET_RUNTIME, result.getNetRuntime());
    if (result.getSerializedThrowable().isPresent()) {
        gen.writeFieldName(FIELD_NAME_FAILURE_CAUSE);
        final SerializedThrowable serializedThrowable = result.getSerializedThrowable().get();
        serializedThrowableSerializer.serialize(serializedThrowable, gen, provider);
    }
    gen.writeEndObject();
}
Also used : OptionalFailure(org.apache.flink.util.OptionalFailure) SerializedValue(org.apache.flink.util.SerializedValue) Map(java.util.Map) SerializedThrowable(org.apache.flink.util.SerializedThrowable)

Aggregations

OptionalFailure (org.apache.flink.util.OptionalFailure)6 HashMap (java.util.HashMap)3 IntCounter (org.apache.flink.api.common.accumulators.IntCounter)2 SerializedValue (org.apache.flink.util.SerializedValue)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)1 JobID (org.apache.flink.api.common.JobID)1 LongCounter (org.apache.flink.api.common.accumulators.LongCounter)1 Configuration (org.apache.flink.configuration.Configuration)1 StringifiedAccumulatorResult (org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult)1 ArchivedExecution (org.apache.flink.runtime.executiongraph.ArchivedExecution)1 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)1 RestHandlerConfiguration (org.apache.flink.runtime.rest.handler.RestHandlerConfiguration)1 DefaultExecutionGraphCache (org.apache.flink.runtime.rest.handler.legacy.DefaultExecutionGraphCache)1 EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)1 SubtaskAttemptMessageParameters (org.apache.flink.runtime.rest.messages.job.SubtaskAttemptMessageParameters)1 SubtaskExecutionAttemptAccumulatorsInfo (org.apache.flink.runtime.rest.messages.job.SubtaskExecutionAttemptAccumulatorsInfo)1 UserAccumulator (org.apache.flink.runtime.rest.messages.job.UserAccumulator)1