use of org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult in project flink by apache.
the class JobAccumulatorsHandler method createJobAccumulatorsJson.
public static String createJobAccumulatorsJson(AccessExecutionGraph graph) throws IOException {
StringWriter writer = new StringWriter();
JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);
StringifiedAccumulatorResult[] allAccumulators = graph.getAccumulatorResultsStringified();
gen.writeStartObject();
gen.writeArrayFieldStart("job-accumulators");
// empty for now
gen.writeEndArray();
gen.writeArrayFieldStart("user-task-accumulators");
for (StringifiedAccumulatorResult acc : allAccumulators) {
gen.writeStartObject();
gen.writeStringField("name", acc.getName());
gen.writeStringField("type", acc.getType());
gen.writeStringField("value", acc.getValue());
gen.writeEndObject();
}
gen.writeEndArray();
gen.writeEndObject();
gen.close();
return writer.toString();
}
use of org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult in project flink by apache.
the class JobVertexAccumulatorsHandler method createVertexAccumulatorsJson.
public static String createVertexAccumulatorsJson(AccessExecutionJobVertex jobVertex) throws IOException {
StringWriter writer = new StringWriter();
JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);
StringifiedAccumulatorResult[] accs = jobVertex.getAggregatedUserAccumulatorsStringified();
gen.writeStartObject();
gen.writeStringField("id", jobVertex.getJobVertexId().toString());
gen.writeArrayFieldStart("user-accumulators");
for (StringifiedAccumulatorResult acc : accs) {
gen.writeStartObject();
gen.writeStringField("name", acc.getName());
gen.writeStringField("type", acc.getType());
gen.writeStringField("value", acc.getValue());
gen.writeEndObject();
}
gen.writeEndArray();
gen.writeEndObject();
gen.close();
return writer.toString();
}
use of org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult in project flink by apache.
the class ArchivedExecutionGraphBuilder method build.
public ArchivedExecutionGraph build() {
Preconditions.checkNotNull(tasks, "Tasks must not be null.");
JobID jobID = this.jobID != null ? this.jobID : new JobID();
String jobName = this.jobName != null ? this.jobName : "job_" + RANDOM.nextInt();
return new ArchivedExecutionGraph(jobID, jobName, tasks, verticesInCreationOrder != null ? verticesInCreationOrder : new ArrayList<>(tasks.values()), stateTimestamps != null ? stateTimestamps : new long[JobStatus.values().length], state != null ? state : JobStatus.FINISHED, failureCause != null ? failureCause : "(null)", jsonPlan != null ? jsonPlan : "{\"jobid\":\"" + jobID + "\", \"name\":\"" + jobName + "\", \"nodes\":[]}", archivedUserAccumulators != null ? archivedUserAccumulators : new StringifiedAccumulatorResult[0], serializedUserAccumulators != null ? serializedUserAccumulators : Collections.<String, SerializedValue<Object>>emptyMap(), archivedExecutionConfig != null ? archivedExecutionConfig : new ArchivedExecutionConfigBuilder().build(), isStoppable, null, null);
}
use of org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult in project flink by apache.
the class JobVertexAccumulatorsHandlerTest method compareAccumulators.
private static void compareAccumulators(AccessExecutionJobVertex originalTask, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalTask.getJobVertexId().toString(), result.get("id").asText());
ArrayNode accs = (ArrayNode) result.get("user-accumulators");
StringifiedAccumulatorResult[] expectedAccs = originalTask.getAggregatedUserAccumulatorsStringified();
ArchivedJobGenerationUtils.compareStringifiedAccumulators(expectedAccs, accs);
}
use of org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult in project flink by apache.
the class ArchivedExecutionGraphTest method compareStringifiedAccumulators.
private static void compareStringifiedAccumulators(StringifiedAccumulatorResult[] runtimeAccs, StringifiedAccumulatorResult[] archivedAccs) {
assertEquals(runtimeAccs.length, archivedAccs.length);
for (int x = 0; x < runtimeAccs.length; x++) {
StringifiedAccumulatorResult runtimeResult = runtimeAccs[x];
StringifiedAccumulatorResult archivedResult = archivedAccs[x];
assertEquals(runtimeResult.getName(), archivedResult.getName());
assertEquals(runtimeResult.getType(), archivedResult.getType());
assertEquals(runtimeResult.getValue(), archivedResult.getValue());
}
}
Aggregations