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();
}
Aggregations