Search in sources :

Example 6 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.

the class CheckpointStatsDetailsHandlerTest method testCheckpointDetailsRequestInProgressCheckpoint.

/**
	 * Tests a checkpoint details request for an in progress checkpoint.
	 */
@Test
public void testCheckpointDetailsRequestInProgressCheckpoint() throws Exception {
    PendingCheckpointStats checkpoint = mock(PendingCheckpointStats.class);
    when(checkpoint.getCheckpointId()).thenReturn(1992139L);
    when(checkpoint.getStatus()).thenReturn(CheckpointStatsStatus.IN_PROGRESS);
    when(checkpoint.getProperties()).thenReturn(CheckpointProperties.forStandardCheckpoint());
    when(checkpoint.getTriggerTimestamp()).thenReturn(1919191900L);
    when(checkpoint.getLatestAckTimestamp()).thenReturn(1977791901L);
    when(checkpoint.getStateSize()).thenReturn(111939272822L);
    when(checkpoint.getEndToEndDuration()).thenReturn(121191L);
    when(checkpoint.getAlignmentBuffered()).thenReturn(1L);
    when(checkpoint.getNumberOfSubtasks()).thenReturn(501);
    when(checkpoint.getNumberOfAcknowledgedSubtasks()).thenReturn(101);
    List<TaskStateStats> taskStats = new ArrayList<>();
    TaskStateStats task1 = createTaskStateStats();
    TaskStateStats task2 = createTaskStateStats();
    taskStats.add(task1);
    taskStats.add(task2);
    when(checkpoint.getAllTaskStateStats()).thenReturn(taskStats);
    JsonNode rootNode = triggerRequest(checkpoint);
    assertEquals(checkpoint.getCheckpointId(), rootNode.get("id").asLong());
    assertEquals(checkpoint.getStatus().toString(), rootNode.get("status").asText());
    assertEquals(checkpoint.getProperties().isSavepoint(), rootNode.get("is_savepoint").asBoolean());
    assertEquals(checkpoint.getTriggerTimestamp(), rootNode.get("trigger_timestamp").asLong());
    assertEquals(checkpoint.getLatestAckTimestamp(), rootNode.get("latest_ack_timestamp").asLong());
    assertEquals(checkpoint.getStateSize(), rootNode.get("state_size").asLong());
    assertEquals(checkpoint.getEndToEndDuration(), rootNode.get("end_to_end_duration").asLong());
    assertEquals(checkpoint.getAlignmentBuffered(), rootNode.get("alignment_buffered").asLong());
    assertEquals(checkpoint.getNumberOfSubtasks(), rootNode.get("num_subtasks").asInt());
    assertEquals(checkpoint.getNumberOfAcknowledgedSubtasks(), rootNode.get("num_acknowledged_subtasks").asInt());
    verifyTaskNodes(taskStats, rootNode);
}
Also used : PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 7 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project flink by apache.

the class CheckpointStatsDetailsHandlerTest method verifyTaskNodes.

private static void verifyTaskNodes(Collection<TaskStateStats> tasks, JsonNode parentNode) {
    for (TaskStateStats task : tasks) {
        long duration = ThreadLocalRandom.current().nextInt(128);
        JsonNode taskNode = parentNode.get("tasks").get(task.getJobVertexId().toString());
        assertEquals(task.getLatestAckTimestamp(), taskNode.get("latest_ack_timestamp").asLong());
        assertEquals(task.getStateSize(), taskNode.get("state_size").asLong());
        assertEquals(task.getEndToEndDuration(task.getLatestAckTimestamp() - duration), taskNode.get("end_to_end_duration").asLong());
        assertEquals(task.getAlignmentBuffered(), taskNode.get("alignment_buffered").asLong());
        assertEquals(task.getNumberOfSubtasks(), taskNode.get("num_subtasks").asInt());
        assertEquals(task.getNumberOfAcknowledgedSubtasks(), taskNode.get("num_acknowledged_subtasks").asInt());
    }
}
Also used : TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 8 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 9 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 10 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)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)879 Test (org.junit.Test)224 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)217 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)142 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)125 IOException (java.io.IOException)91 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)86 HashMap (java.util.HashMap)79 HttpGet (org.apache.http.client.methods.HttpGet)68 JsonException (jmri.server.json.JsonException)66 Deployment (org.activiti.engine.test.Deployment)66 ArrayList (java.util.ArrayList)62 InputStream (java.io.InputStream)55 StringEntity (org.apache.http.entity.StringEntity)54 ByteArrayInputStream (java.io.ByteArrayInputStream)51 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)49 Task (org.activiti.engine.task.Task)41 HttpPost (org.apache.http.client.methods.HttpPost)39 Map (java.util.Map)33 Tree (org.apache.jackrabbit.oak.api.Tree)30