use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class CheckpointStatsDetailsHandlerTest method testCheckpointDetailsRequestFailedCheckpoint.
/**
* Tests a checkpoint details request for a failed checkpoint.
*/
@Test
public void testCheckpointDetailsRequestFailedCheckpoint() throws Exception {
FailedCheckpointStats checkpoint = createFailedCheckpoint();
JsonNode rootNode = triggerRequest(checkpoint);
compareFailedCheckpoint(checkpoint, rootNode);
verifyTaskNodes(checkpoint.getAllTaskStateStats(), rootNode);
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class CheckpointStatsHandlerTest method compareCheckpointStats.
private static void compareCheckpointStats(TestCheckpointStats checkpointStats, JsonNode rootNode) {
CheckpointStatsCounts counts = checkpointStats.counts;
JsonNode countNode = rootNode.get("counts");
assertEquals(counts.getNumberOfRestoredCheckpoints(), countNode.get("restored").asLong());
assertEquals(counts.getTotalNumberOfCheckpoints(), countNode.get("total").asLong());
assertEquals(counts.getNumberOfInProgressCheckpoints(), countNode.get("in_progress").asLong());
assertEquals(counts.getNumberOfCompletedCheckpoints(), countNode.get("completed").asLong());
assertEquals(counts.getNumberOfFailedCheckpoints(), countNode.get("failed").asLong());
MinMaxAvgStats stateSizeSummary = checkpointStats.stateSizeSummary;
JsonNode summaryNode = rootNode.get("summary");
JsonNode sizeSummaryNode = summaryNode.get("state_size");
assertEquals(stateSizeSummary.getMinimum(), sizeSummaryNode.get("min").asLong());
assertEquals(stateSizeSummary.getMaximum(), sizeSummaryNode.get("max").asLong());
assertEquals(stateSizeSummary.getAverage(), sizeSummaryNode.get("avg").asLong());
MinMaxAvgStats durationSummary = checkpointStats.durationSummary;
JsonNode durationSummaryNode = summaryNode.get("end_to_end_duration");
assertEquals(durationSummary.getMinimum(), durationSummaryNode.get("min").asLong());
assertEquals(durationSummary.getMaximum(), durationSummaryNode.get("max").asLong());
assertEquals(durationSummary.getAverage(), durationSummaryNode.get("avg").asLong());
MinMaxAvgStats alignmentBufferedSummary = checkpointStats.alignmentBufferedSummary;
JsonNode alignmentBufferedNode = summaryNode.get("alignment_buffered");
assertEquals(alignmentBufferedSummary.getMinimum(), alignmentBufferedNode.get("min").asLong());
assertEquals(alignmentBufferedSummary.getMaximum(), alignmentBufferedNode.get("max").asLong());
assertEquals(alignmentBufferedSummary.getAverage(), alignmentBufferedNode.get("avg").asLong());
CompletedCheckpointStats latestCompleted = checkpointStats.latestCompleted;
JsonNode latestNode = rootNode.get("latest");
JsonNode latestCheckpointNode = latestNode.get("completed");
assertEquals(latestCompleted.getCheckpointId(), latestCheckpointNode.get("id").asLong());
assertEquals(latestCompleted.getTriggerTimestamp(), latestCheckpointNode.get("trigger_timestamp").asLong());
assertEquals(latestCompleted.getLatestAckTimestamp(), latestCheckpointNode.get("latest_ack_timestamp").asLong());
assertEquals(latestCompleted.getStateSize(), latestCheckpointNode.get("state_size").asLong());
assertEquals(latestCompleted.getEndToEndDuration(), latestCheckpointNode.get("end_to_end_duration").asLong());
assertEquals(latestCompleted.getAlignmentBuffered(), latestCheckpointNode.get("alignment_buffered").asLong());
assertEquals(latestCompleted.getExternalPath(), latestCheckpointNode.get("external_path").asText());
CompletedCheckpointStats latestSavepoint = checkpointStats.latestSavepoint;
JsonNode latestSavepointNode = latestNode.get("savepoint");
assertEquals(latestSavepoint.getCheckpointId(), latestSavepointNode.get("id").asLong());
assertEquals(latestSavepoint.getTriggerTimestamp(), latestSavepointNode.get("trigger_timestamp").asLong());
assertEquals(latestSavepoint.getLatestAckTimestamp(), latestSavepointNode.get("latest_ack_timestamp").asLong());
assertEquals(latestSavepoint.getStateSize(), latestSavepointNode.get("state_size").asLong());
assertEquals(latestSavepoint.getEndToEndDuration(), latestSavepointNode.get("end_to_end_duration").asLong());
assertEquals(latestSavepoint.getAlignmentBuffered(), latestSavepointNode.get("alignment_buffered").asLong());
assertEquals(latestSavepoint.getExternalPath(), latestSavepointNode.get("external_path").asText());
FailedCheckpointStats latestFailed = checkpointStats.latestFailed;
JsonNode latestFailedNode = latestNode.get("failed");
assertEquals(latestFailed.getCheckpointId(), latestFailedNode.get("id").asLong());
assertEquals(latestFailed.getTriggerTimestamp(), latestFailedNode.get("trigger_timestamp").asLong());
assertEquals(latestFailed.getLatestAckTimestamp(), latestFailedNode.get("latest_ack_timestamp").asLong());
assertEquals(latestFailed.getStateSize(), latestFailedNode.get("state_size").asLong());
assertEquals(latestFailed.getEndToEndDuration(), latestFailedNode.get("end_to_end_duration").asLong());
assertEquals(latestFailed.getAlignmentBuffered(), latestFailedNode.get("alignment_buffered").asLong());
assertEquals(latestFailed.getFailureTimestamp(), latestFailedNode.get("failure_timestamp").asLong());
assertEquals(latestFailed.getFailureMessage(), latestFailedNode.get("failure_message").asText());
RestoredCheckpointStats latestRestored = checkpointStats.latestRestored;
JsonNode latestRestoredNode = latestNode.get("restored");
assertEquals(latestRestored.getCheckpointId(), latestRestoredNode.get("id").asLong());
assertEquals(latestRestored.getRestoreTimestamp(), latestRestoredNode.get("restore_timestamp").asLong());
assertEquals(latestRestored.getProperties().isSavepoint(), latestRestoredNode.get("is_savepoint").asBoolean());
assertEquals(latestRestored.getExternalPath(), latestRestoredNode.get("external_path").asText());
JsonNode historyNode = rootNode.get("history");
Iterator<JsonNode> it = historyNode.iterator();
assertTrue(it.hasNext());
JsonNode inProgressNode = it.next();
PendingCheckpointStats inProgress = checkpointStats.inProgress;
compareInProgressCheckpoint(inProgress, inProgressNode);
assertTrue(it.hasNext());
JsonNode completedSavepointNode = it.next();
CompletedCheckpointStats completedSavepoint = checkpointStats.completedSavepoint;
compareCompletedSavepoint(completedSavepoint, completedSavepointNode);
assertTrue(it.hasNext());
JsonNode failedNode = it.next();
FailedCheckpointStats failed = checkpointStats.failed;
compareFailedCheckpoint(failed, failedNode);
assertFalse(it.hasNext());
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class CheckpointStatsHandlerTest method testCheckpointStatsRequest.
/**
* Tests a complete checkpoint stats snapshot.
*/
@Test
public void testCheckpointStatsRequest() throws Exception {
TestCheckpointStats testCheckpointStats = createTestCheckpointStats();
CheckpointStatsHandler handler = new CheckpointStatsHandler(mock(ExecutionGraphHolder.class));
String json = handler.handleRequest(testCheckpointStats.graph, Collections.<String, String>emptyMap());
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(json);
compareCheckpointStats(testCheckpointStats, rootNode);
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class JobDetailsHandlerTest method compareJobDetails.
private static void compareJobDetails(AccessExecutionGraph originalJob, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalJob.getJobID().toString(), result.get("jid").asText());
Assert.assertEquals(originalJob.getJobName(), result.get("name").asText());
Assert.assertEquals(originalJob.isStoppable(), result.get("isStoppable").asBoolean());
Assert.assertEquals(originalJob.getState().name(), result.get("state").asText());
Assert.assertEquals(originalJob.getStatusTimestamp(JobStatus.CREATED), result.get("start-time").asLong());
Assert.assertEquals(originalJob.getStatusTimestamp(originalJob.getState()), result.get("end-time").asLong());
Assert.assertEquals(originalJob.getStatusTimestamp(originalJob.getState()) - originalJob.getStatusTimestamp(JobStatus.CREATED), result.get("duration").asLong());
JsonNode timestamps = result.get("timestamps");
for (JobStatus status : JobStatus.values()) {
Assert.assertEquals(originalJob.getStatusTimestamp(status), timestamps.get(status.name()).asLong());
}
ArrayNode tasks = (ArrayNode) result.get("vertices");
int x = 0;
for (AccessExecutionJobVertex expectedTask : originalJob.getVerticesTopologically()) {
JsonNode task = tasks.get(x);
Assert.assertEquals(expectedTask.getJobVertexId().toString(), task.get("id").asText());
Assert.assertEquals(expectedTask.getName(), task.get("name").asText());
Assert.assertEquals(expectedTask.getParallelism(), task.get("parallelism").asInt());
Assert.assertEquals(expectedTask.getAggregateState().name(), task.get("status").asText());
Assert.assertEquals(3, task.get("start-time").asLong());
Assert.assertEquals(5, task.get("end-time").asLong());
Assert.assertEquals(2, task.get("duration").asLong());
JsonNode subtasksPerState = task.get("tasks");
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.CREATED.name()).asInt());
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.SCHEDULED.name()).asInt());
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.DEPLOYING.name()).asInt());
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.RUNNING.name()).asInt());
Assert.assertEquals(1, subtasksPerState.get(ExecutionState.FINISHED.name()).asInt());
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.CANCELING.name()).asInt());
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.CANCELED.name()).asInt());
Assert.assertEquals(0, subtasksPerState.get(ExecutionState.FAILED.name()).asInt());
long expectedNumBytesIn = 0;
long expectedNumBytesOut = 0;
long expectedNumRecordsIn = 0;
long expectedNumRecordsOut = 0;
for (AccessExecutionVertex vertex : expectedTask.getTaskVertices()) {
IOMetrics ioMetrics = vertex.getCurrentExecutionAttempt().getIOMetrics();
expectedNumBytesIn += ioMetrics.getNumBytesInLocal() + ioMetrics.getNumBytesInRemote();
expectedNumBytesOut += ioMetrics.getNumBytesOut();
expectedNumRecordsIn += ioMetrics.getNumRecordsIn();
expectedNumRecordsOut += ioMetrics.getNumRecordsOut();
}
JsonNode metrics = task.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());
x++;
}
Assert.assertEquals(1, tasks.size());
JsonNode statusCounts = result.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(1, statusCounts.get(ExecutionState.RUNNING.name()).asInt());
Assert.assertEquals(0, 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());
Assert.assertEquals(ArchivedJobGenerationUtils.mapper.readTree(originalJob.getJsonPlan()), result.get("plan"));
}
use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.
the class JobExceptionsHandlerTest method compareExceptions.
private static void compareExceptions(AccessExecutionGraph originalJob, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalJob.getFailureCauseAsString(), result.get("root-exception").asText());
ArrayNode exceptions = (ArrayNode) result.get("all-exceptions");
int x = 0;
for (AccessExecutionVertex expectedSubtask : originalJob.getAllExecutionVertices()) {
if (!expectedSubtask.getFailureCauseAsString().equals(ExceptionUtils.STRINGIFIED_NULL_EXCEPTION)) {
JsonNode exception = exceptions.get(x);
Assert.assertEquals(expectedSubtask.getFailureCauseAsString(), exception.get("exception").asText());
Assert.assertEquals(expectedSubtask.getTaskNameWithSubtaskIndex(), exception.get("task").asText());
TaskManagerLocation location = expectedSubtask.getCurrentAssignedResourceLocation();
String expectedLocationString = location.getFQDNHostname() + ':' + location.dataPort();
Assert.assertEquals(expectedLocationString, exception.get("location").asText());
}
x++;
}
Assert.assertEquals(x > JobExceptionsHandler.MAX_NUMBER_EXCEPTION_TO_REPORT, result.get("truncated").asBoolean());
}
Aggregations