Search in sources :

Example 16 with JsonNode

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

the class CheckpointStatsSubtaskDetailsHandlerTest method testSubtaskRequestNoSummary.

/**
	 * Tests a subtask details request.
	 */
@Test
public void testSubtaskRequestNoSummary() throws Exception {
    PendingCheckpointStats checkpoint = mock(PendingCheckpointStats.class);
    when(checkpoint.getCheckpointId()).thenReturn(1992139L);
    when(checkpoint.getStatus()).thenReturn(CheckpointStatsStatus.IN_PROGRESS);
    // ack timestamp = duration
    when(checkpoint.getTriggerTimestamp()).thenReturn(0L);
    // no acknowledged
    TaskStateStats task = createTaskStateStats(0);
    when(checkpoint.getTaskStateStats(any(JobVertexID.class))).thenReturn(task);
    JsonNode rootNode = triggerRequest(checkpoint);
    assertNull(rootNode.get("summary"));
}
Also used : PendingCheckpointStats(org.apache.flink.runtime.checkpoint.PendingCheckpointStats) TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 17 with JsonNode

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

the class CheckpointStatsSubtaskDetailsHandlerTest method verifyTaskNode.

private static void verifyTaskNode(JsonNode taskNode, TaskStateStats task, long triggerTimestamp) {
    long duration = ThreadLocalRandom.current().nextInt(128);
    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());
    TaskStateStats.TaskStateStatsSummary summary = task.getSummaryStats();
    verifyMinMaxAvgStats(summary.getStateSizeStats(), taskNode.get("summary").get("state_size"));
    verifyMinMaxAvgStats(summary.getSyncCheckpointDurationStats(), taskNode.get("summary").get("checkpoint_duration").get("sync"));
    verifyMinMaxAvgStats(summary.getAsyncCheckpointDurationStats(), taskNode.get("summary").get("checkpoint_duration").get("async"));
    verifyMinMaxAvgStats(summary.getAlignmentBufferedStats(), taskNode.get("summary").get("alignment").get("buffered"));
    verifyMinMaxAvgStats(summary.getAlignmentDurationStats(), taskNode.get("summary").get("alignment").get("duration"));
    JsonNode endToEndDurationNode = taskNode.get("summary").get("end_to_end_duration");
    assertEquals(summary.getAckTimestampStats().getMinimum() - triggerTimestamp, endToEndDurationNode.get("min").asLong());
    assertEquals(summary.getAckTimestampStats().getMaximum() - triggerTimestamp, endToEndDurationNode.get("max").asLong());
    assertEquals((long) summary.getAckTimestampStats().getAverage() - triggerTimestamp, endToEndDurationNode.get("avg").asLong());
    SubtaskStateStats[] subtasks = task.getSubtaskStats();
    Iterator<JsonNode> it = taskNode.get("subtasks").iterator();
    assertTrue(it.hasNext());
    verifySubtaskStats(it.next(), 0, subtasks[0]);
    assertTrue(it.hasNext());
    verifySubtaskStats(it.next(), 1, subtasks[1]);
    assertTrue(it.hasNext());
    verifySubtaskStats(it.next(), 2, subtasks[2]);
    assertFalse(it.hasNext());
}
Also used : TaskStateStats(org.apache.flink.runtime.checkpoint.TaskStateStats) JsonNode(com.fasterxml.jackson.databind.JsonNode) SubtaskStateStats(org.apache.flink.runtime.checkpoint.SubtaskStateStats)

Example 18 with JsonNode

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());
}
Also used : JsonArchivist(org.apache.flink.runtime.webmonitor.history.JsonArchivist) ArchivedJson(org.apache.flink.runtime.webmonitor.history.ArchivedJson) AccessExecutionGraph(org.apache.flink.runtime.executiongraph.AccessExecutionGraph) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) JobDetails(org.apache.flink.runtime.messages.webmonitor.JobDetails) Test(org.junit.Test)

Example 19 with JsonNode

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());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 20 with JsonNode

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());
}
Also used : TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) 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)

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