Search in sources :

Example 11 with AccessExecutionJobVertex

use of org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex in project flink by apache.

the class JobDetailsHandler method createJobDetailsJson.

public static String createJobDetailsJson(AccessExecutionGraph graph, @Nullable MetricFetcher fetcher) throws IOException {
    final StringWriter writer = new StringWriter();
    final JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);
    final long now = System.currentTimeMillis();
    gen.writeStartObject();
    // basic info
    gen.writeStringField("jid", graph.getJobID().toString());
    gen.writeStringField("name", graph.getJobName());
    gen.writeBooleanField("isStoppable", graph.isStoppable());
    gen.writeStringField("state", graph.getState().name());
    // times and duration
    final long jobStartTime = graph.getStatusTimestamp(JobStatus.CREATED);
    final long jobEndTime = graph.getState().isGloballyTerminalState() ? graph.getStatusTimestamp(graph.getState()) : -1L;
    gen.writeNumberField("start-time", jobStartTime);
    gen.writeNumberField("end-time", jobEndTime);
    gen.writeNumberField("duration", (jobEndTime > 0 ? jobEndTime : now) - jobStartTime);
    gen.writeNumberField("now", now);
    // timestamps
    gen.writeObjectFieldStart("timestamps");
    for (JobStatus status : JobStatus.values()) {
        gen.writeNumberField(status.name(), graph.getStatusTimestamp(status));
    }
    gen.writeEndObject();
    // job vertices
    int[] jobVerticesPerState = new int[ExecutionState.values().length];
    gen.writeArrayFieldStart("vertices");
    for (AccessExecutionJobVertex ejv : graph.getVerticesTopologically()) {
        int[] tasksPerState = new int[ExecutionState.values().length];
        long startTime = Long.MAX_VALUE;
        long endTime = 0;
        boolean allFinished = true;
        for (AccessExecutionVertex vertex : ejv.getTaskVertices()) {
            final ExecutionState state = vertex.getExecutionState();
            tasksPerState[state.ordinal()]++;
            // take the earliest start time
            long started = vertex.getStateTimestamp(ExecutionState.DEPLOYING);
            if (started > 0) {
                startTime = Math.min(startTime, started);
            }
            allFinished &= state.isTerminal();
            endTime = Math.max(endTime, vertex.getStateTimestamp(state));
        }
        long duration;
        if (startTime < Long.MAX_VALUE) {
            if (allFinished) {
                duration = endTime - startTime;
            } else {
                endTime = -1L;
                duration = now - startTime;
            }
        } else {
            startTime = -1L;
            endTime = -1L;
            duration = -1L;
        }
        ExecutionState jobVertexState = ExecutionJobVertex.getAggregateJobVertexState(tasksPerState, ejv.getParallelism());
        jobVerticesPerState[jobVertexState.ordinal()]++;
        gen.writeStartObject();
        gen.writeStringField("id", ejv.getJobVertexId().toString());
        gen.writeStringField("name", ejv.getName());
        gen.writeNumberField("parallelism", ejv.getParallelism());
        gen.writeStringField("status", jobVertexState.name());
        gen.writeNumberField("start-time", startTime);
        gen.writeNumberField("end-time", endTime);
        gen.writeNumberField("duration", duration);
        gen.writeObjectFieldStart("tasks");
        for (ExecutionState state : ExecutionState.values()) {
            gen.writeNumberField(state.name(), tasksPerState[state.ordinal()]);
        }
        gen.writeEndObject();
        MutableIOMetrics counts = new MutableIOMetrics();
        for (AccessExecutionVertex vertex : ejv.getTaskVertices()) {
            counts.addIOMetrics(vertex.getCurrentExecutionAttempt(), fetcher, graph.getJobID().toString(), ejv.getJobVertexId().toString());
        }
        counts.writeIOMetricsAsJson(gen);
        gen.writeEndObject();
    }
    gen.writeEndArray();
    gen.writeObjectFieldStart("status-counts");
    for (ExecutionState state : ExecutionState.values()) {
        gen.writeNumberField(state.name(), jobVerticesPerState[state.ordinal()]);
    }
    gen.writeEndObject();
    gen.writeFieldName("plan");
    gen.writeRawValue(graph.getJsonPlan());
    gen.writeEndObject();
    gen.close();
    return writer.toString();
}
Also used : JobStatus(org.apache.flink.runtime.jobgraph.JobStatus) AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) ExecutionState(org.apache.flink.runtime.execution.ExecutionState) MutableIOMetrics(org.apache.flink.runtime.webmonitor.utils.MutableIOMetrics) StringWriter(java.io.StringWriter) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) AccessExecutionVertex(org.apache.flink.runtime.executiongraph.AccessExecutionVertex)

Example 12 with AccessExecutionJobVertex

use of org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex in project flink by apache.

the class SubtasksTimesHandlerTest method testArchiver.

@Test
public void testArchiver() throws Exception {
    JsonArchivist archivist = new SubtasksTimesHandler.SubtasksTimesJsonArchivist();
    AccessExecutionGraph originalJob = ArchivedJobGenerationUtils.getTestJob();
    AccessExecutionJobVertex originalTask = ArchivedJobGenerationUtils.getTestTask();
    AccessExecution originalAttempt = ArchivedJobGenerationUtils.getTestAttempt();
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(originalJob);
    Assert.assertEquals(1, archives.size());
    ArchivedJson archive = archives.iterator().next();
    Assert.assertEquals("/jobs/" + originalJob.getJobID() + "/vertices/" + originalTask.getJobVertexId() + "/subtasktimes", archive.getPath());
    compareSubtaskTimes(originalTask, originalAttempt, archive.getJson());
}
Also used : AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) AccessExecution(org.apache.flink.runtime.executiongraph.AccessExecution) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) Test(org.junit.Test)

Example 13 with AccessExecutionJobVertex

use of org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex in project flink by apache.

the class JobVertexAccumulatorsHandlerTest method testJsonGeneration.

@Test
public void testJsonGeneration() throws Exception {
    AccessExecutionJobVertex originalTask = ArchivedJobGenerationUtils.getTestTask();
    String json = JobVertexAccumulatorsHandler.createVertexAccumulatorsJson(originalTask);
    compareAccumulators(originalTask, json);
}
Also used : AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) Test(org.junit.Test)

Example 14 with AccessExecutionJobVertex

use of org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex in project flink by apache.

the class JobVertexDetailsHandlerTest method testArchiver.

@Test
public void testArchiver() throws Exception {
    JsonArchivist archivist = new JobVertexDetailsHandler.JobVertexDetailsJsonArchivist();
    AccessExecutionGraph originalJob = ArchivedJobGenerationUtils.getTestJob();
    AccessExecutionJobVertex originalTask = ArchivedJobGenerationUtils.getTestTask();
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(originalJob);
    Assert.assertEquals(1, archives.size());
    ArchivedJson archive = archives.iterator().next();
    Assert.assertEquals("/jobs/" + originalJob.getJobID() + "/vertices/" + originalTask.getJobVertexId(), archive.getPath());
    compareVertexDetails(originalTask, archive.getJson());
}
Also used : AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) Test(org.junit.Test)

Example 15 with AccessExecutionJobVertex

use of org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex in project flink by apache.

the class JobVertexTaskManagersHandlerTest method testArchiver.

@Test
public void testArchiver() throws Exception {
    JsonArchivist archivist = new JobVertexTaskManagersHandler.JobVertexTaskManagersJsonArchivist();
    AccessExecutionGraph originalJob = ArchivedJobGenerationUtils.getTestJob();
    AccessExecutionJobVertex originalTask = ArchivedJobGenerationUtils.getTestTask();
    AccessExecutionVertex originalSubtask = ArchivedJobGenerationUtils.getTestSubtask();
    Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(originalJob);
    Assert.assertEquals(1, archives.size());
    ArchivedJson archive = archives.iterator().next();
    Assert.assertEquals("/jobs/" + originalJob.getJobID() + "/vertices/" + originalTask.getJobVertexId() + "/taskmanagers", archive.getPath());
    compareVertexTaskManagers(originalTask, originalSubtask, archive.getJson());
}
Also used : AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) AccessExecutionVertex(org.apache.flink.runtime.executiongraph.AccessExecutionVertex) Test(org.junit.Test)

Aggregations

AccessExecutionJobVertex (org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex)18 Test (org.junit.Test)13 AccessExecutionGraph (org.apache.flink.runtime.executiongraph.AccessExecutionGraph)8 ArchivedJson (org.apache.flink.runtime.webmonitor.history.ArchivedJson)7 JsonArchivist (org.apache.flink.runtime.webmonitor.history.JsonArchivist)7 AccessExecution (org.apache.flink.runtime.executiongraph.AccessExecution)5 AccessExecutionVertex (org.apache.flink.runtime.executiongraph.AccessExecutionVertex)5 JobStatus (org.apache.flink.runtime.jobgraph.JobStatus)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)2 StringWriter (java.io.StringWriter)2 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ArchivedExecutionJobVertex (org.apache.flink.runtime.executiongraph.ArchivedExecutionJobVertex)1 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)1 IOMetrics (org.apache.flink.runtime.executiongraph.IOMetrics)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 JobDetails (org.apache.flink.runtime.messages.webmonitor.JobDetails)1 OperatorBackPressureStats (org.apache.flink.runtime.webmonitor.OperatorBackPressureStats)1 MutableIOMetrics (org.apache.flink.runtime.webmonitor.utils.MutableIOMetrics)1