use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class CurrentJobsOverviewHandlerTest method testArchiver.
@Test
public void testArchiver() throws Exception {
JsonArchivist archivist = new CurrentJobsOverviewHandler.CurrentJobsOverviewJsonArchivist();
AccessExecutionGraph originalJob = ArchivedJobGenerationUtils.getTestJob();
JobDetails expectedDetails = WebMonitorUtils.createDetailsForJob(originalJob);
Collection<ArchivedJson> archives = archivist.archiveJsonWithPath(originalJob);
Assert.assertEquals(1, archives.size());
ArchivedJson archive = archives.iterator().next();
Assert.assertEquals("/joboverview", archive.getPath());
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(archive.getJson());
ArrayNode running = (ArrayNode) result.get("running");
Assert.assertEquals(0, running.size());
ArrayNode finished = (ArrayNode) result.get("finished");
Assert.assertEquals(1, finished.size());
compareJobOverview(expectedDetails, finished.get(0).toString());
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class CurrentJobsOverviewHandlerTest method compareJobOverview.
private static void compareJobOverview(JobDetails expectedDetails, String answer) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(answer);
Assert.assertEquals(expectedDetails.getJobId().toString(), result.get("jid").asText());
Assert.assertEquals(expectedDetails.getJobName(), result.get("name").asText());
Assert.assertEquals(expectedDetails.getStatus().name(), result.get("state").asText());
Assert.assertEquals(expectedDetails.getStartTime(), result.get("start-time").asLong());
Assert.assertEquals(expectedDetails.getEndTime(), result.get("end-time").asLong());
Assert.assertEquals(expectedDetails.getEndTime() - expectedDetails.getStartTime(), result.get("duration").asLong());
Assert.assertEquals(expectedDetails.getLastUpdateTime(), result.get("last-modification").asLong());
JsonNode tasks = result.get("tasks");
Assert.assertEquals(expectedDetails.getNumTasks(), tasks.get("total").asInt());
int[] tasksPerState = expectedDetails.getNumVerticesPerExecutionState();
Assert.assertEquals(tasksPerState[ExecutionState.CREATED.ordinal()] + tasksPerState[ExecutionState.SCHEDULED.ordinal()] + tasksPerState[ExecutionState.DEPLOYING.ordinal()], tasks.get("pending").asInt());
Assert.assertEquals(tasksPerState[ExecutionState.RUNNING.ordinal()], tasks.get("running").asInt());
Assert.assertEquals(tasksPerState[ExecutionState.FINISHED.ordinal()], tasks.get("finished").asInt());
Assert.assertEquals(tasksPerState[ExecutionState.CANCELING.ordinal()], tasks.get("canceling").asInt());
Assert.assertEquals(tasksPerState[ExecutionState.CANCELED.ordinal()], tasks.get("canceled").asInt());
Assert.assertEquals(tasksPerState[ExecutionState.FAILED.ordinal()], tasks.get("failed").asInt());
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class JobVertexTaskManagersHandlerTest method compareVertexTaskManagers.
private static void compareVertexTaskManagers(AccessExecutionJobVertex originalTask, AccessExecutionVertex originalSubtask, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalTask.getJobVertexId().toString(), result.get("id").asText());
Assert.assertEquals(originalTask.getName(), result.get("name").asText());
Assert.assertTrue(result.get("now").asLong() > 0);
ArrayNode taskmanagers = (ArrayNode) result.get("taskmanagers");
JsonNode taskManager = taskmanagers.get(0);
TaskManagerLocation location = originalSubtask.getCurrentAssignedResourceLocation();
String expectedLocationString = location.getHostname() + ':' + location.dataPort();
Assert.assertEquals(expectedLocationString, taskManager.get("host").asText());
Assert.assertEquals(ExecutionState.FINISHED.name(), taskManager.get("status").asText());
Assert.assertEquals(3, taskManager.get("start-time").asLong());
Assert.assertEquals(5, taskManager.get("end-time").asLong());
Assert.assertEquals(2, taskManager.get("duration").asLong());
JsonNode statusCounts = taskManager.get("status-counts");
Assert.assertEquals(0, statusCounts.get(ExecutionState.CREATED.name()).asInt());
Assert.assertEquals(0, statusCounts.get(ExecutionState.SCHEDULED.name()).asInt());
Assert.assertEquals(0, statusCounts.get(ExecutionState.DEPLOYING.name()).asInt());
Assert.assertEquals(0, statusCounts.get(ExecutionState.RUNNING.name()).asInt());
Assert.assertEquals(1, statusCounts.get(ExecutionState.FINISHED.name()).asInt());
Assert.assertEquals(0, statusCounts.get(ExecutionState.CANCELING.name()).asInt());
Assert.assertEquals(0, statusCounts.get(ExecutionState.CANCELED.name()).asInt());
Assert.assertEquals(0, statusCounts.get(ExecutionState.FAILED.name()).asInt());
long expectedNumBytesIn = 0;
long expectedNumBytesOut = 0;
long expectedNumRecordsIn = 0;
long expectedNumRecordsOut = 0;
for (AccessExecutionVertex vertex : originalTask.getTaskVertices()) {
IOMetrics ioMetrics = vertex.getCurrentExecutionAttempt().getIOMetrics();
expectedNumBytesIn += ioMetrics.getNumBytesInLocal() + ioMetrics.getNumBytesInRemote();
expectedNumBytesOut += ioMetrics.getNumBytesOut();
expectedNumRecordsIn += ioMetrics.getNumRecordsIn();
expectedNumRecordsOut += ioMetrics.getNumRecordsOut();
}
JsonNode metrics = taskManager.get("metrics");
Assert.assertEquals(expectedNumBytesIn, metrics.get("read-bytes").asLong());
Assert.assertEquals(expectedNumBytesOut, metrics.get("write-bytes").asLong());
Assert.assertEquals(expectedNumRecordsIn, metrics.get("read-records").asLong());
Assert.assertEquals(expectedNumRecordsOut, metrics.get("write-records").asLong());
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class SubtaskExecutionAttemptDetailsHandlerTest method compareAttemptDetails.
private static void compareAttemptDetails(AccessExecution originalAttempt, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalAttempt.getParallelSubtaskIndex(), result.get("subtask").asInt());
Assert.assertEquals(originalAttempt.getState().name(), result.get("status").asText());
Assert.assertEquals(originalAttempt.getAttemptNumber(), result.get("attempt").asInt());
Assert.assertEquals(originalAttempt.getAssignedResourceLocation().getHostname(), result.get("host").asText());
long start = originalAttempt.getStateTimestamp(ExecutionState.DEPLOYING);
Assert.assertEquals(start, result.get("start-time").asLong());
long end = originalAttempt.getStateTimestamp(ExecutionState.FINISHED);
Assert.assertEquals(end, result.get("end-time").asLong());
Assert.assertEquals(end - start, result.get("duration").asLong());
ArchivedJobGenerationUtils.compareIoMetrics(originalAttempt.getIOMetrics(), result.get("metrics"));
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class SubtasksAllAccumulatorsHandlerTest method compareSubtaskAccumulators.
private static void compareSubtaskAccumulators(AccessExecutionJobVertex originalTask, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalTask.getJobVertexId().toString(), result.get("id").asText());
Assert.assertEquals(originalTask.getParallelism(), result.get("parallelism").asInt());
ArrayNode subtasks = (ArrayNode) result.get("subtasks");
Assert.assertEquals(originalTask.getTaskVertices().length, subtasks.size());
for (int x = 0; x < originalTask.getTaskVertices().length; x++) {
JsonNode subtask = subtasks.get(x);
AccessExecutionVertex expectedSubtask = originalTask.getTaskVertices()[x];
Assert.assertEquals(x, subtask.get("subtask").asInt());
Assert.assertEquals(expectedSubtask.getCurrentExecutionAttempt().getAttemptNumber(), subtask.get("attempt").asInt());
Assert.assertEquals(expectedSubtask.getCurrentAssignedResourceLocation().getHostname(), subtask.get("host").asText());
ArchivedJobGenerationUtils.compareStringifiedAccumulators(expectedSubtask.getCurrentExecutionAttempt().getUserAccumulatorsStringified(), (ArrayNode) subtask.get("user-accumulators"));
}
}
Aggregations