Search in sources :

Example 51 with JsonNode

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);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) FailedCheckpointStats(org.apache.flink.runtime.checkpoint.FailedCheckpointStats) Test(org.junit.Test)

Example 52 with JsonNode

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());
}
Also used : PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) CheckpointStatsCounts(org.apache.flink.runtime.checkpoint.CheckpointStatsCounts) RestoredCheckpointStats(org.apache.flink.runtime.checkpoint.RestoredCheckpointStats) JsonNode(com.fasterxml.jackson.databind.JsonNode) CompletedCheckpointStats(org.apache.flink.runtime.checkpoint.CompletedCheckpointStats) FailedCheckpointStats(org.apache.flink.runtime.checkpoint.FailedCheckpointStats) MinMaxAvgStats(org.apache.flink.runtime.checkpoint.MinMaxAvgStats)

Example 53 with JsonNode

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);
}
Also used : ExecutionGraphHolder(org.apache.flink.runtime.webmonitor.ExecutionGraphHolder) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 54 with JsonNode

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"));
}
Also used : JobStatus(org.apache.flink.runtime.jobgraph.JobStatus) AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) IOMetrics(org.apache.flink.runtime.executiongraph.IOMetrics) AccessExecutionVertex(org.apache.flink.runtime.executiongraph.AccessExecutionVertex)

Example 55 with JsonNode

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());
}
Also used : TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) AccessExecutionVertex(org.apache.flink.runtime.executiongraph.AccessExecutionVertex)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1055 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)275 Test (org.junit.Test)267 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)165 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)125 IOException (java.io.IOException)124 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)97 HashMap (java.util.HashMap)78 ArrayList (java.util.ArrayList)75 HttpGet (org.apache.http.client.methods.HttpGet)69 JsonException (jmri.server.json.JsonException)66 Deployment (org.activiti.engine.test.Deployment)66 InputStream (java.io.InputStream)64 StringEntity (org.apache.http.entity.StringEntity)54 ByteArrayInputStream (java.io.ByteArrayInputStream)53 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)49 Map (java.util.Map)45 Task (org.activiti.engine.task.Task)41 HttpPost (org.apache.http.client.methods.HttpPost)39 Tree (org.apache.jackrabbit.oak.api.Tree)30