Search in sources :

Example 6 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class JobExceptionsHandlerTest method testOnlyRootCause.

@Test
public void testOnlyRootCause() throws HandlerRequestException {
    final Throwable rootCause = new RuntimeException("root cause");
    final long rootCauseTimestamp = System.currentTimeMillis();
    final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(fromGlobalFailure(rootCause, rootCauseTimestamp));
    final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
    final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
    assertThat(response.getRootException(), is(ExceptionUtils.stringifyException(rootCause)));
    assertThat(response.getRootTimestamp(), is(rootCauseTimestamp));
    assertFalse(response.isTruncated());
    assertThat(response.getAllExceptions(), empty());
    assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsGlobalFailure(rootCause, rootCauseTimestamp)));
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) SerializedThrowable(org.apache.flink.util.SerializedThrowable) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobExceptionsInfoWithHistory(org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory) Test(org.junit.Test)

Example 7 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class JobExceptionsHandlerTest method checkExceptionLimit.

private static void checkExceptionLimit(JobExceptionsHandler jobExceptionsHandler, ExecutionGraphInfo graph, int maxNumExceptions, int numExpectedException) throws HandlerRequestException {
    final HandlerRequest<EmptyRequestBody> handlerRequest = createRequest(graph.getJobId(), numExpectedException);
    final JobExceptionsInfo jobExceptionsInfo = jobExceptionsHandler.handleRequest(handlerRequest, graph);
    final int numReportedException = Math.min(maxNumExceptions, numExpectedException);
    assertEquals(jobExceptionsInfo.getAllExceptions().size(), numReportedException);
}
Also used : JobExceptionsInfo(org.apache.flink.runtime.rest.messages.JobExceptionsInfo) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody)

Example 8 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class AggregatingMetricsHandlerTestBase method testListMetrics.

@Test
public void testListMetrics() throws Exception {
    HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), handler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, Collections.emptyMap(), Collections.emptyList());
    AggregatedMetricsResponseBody response = handler.handleRequest(request, MOCK_DISPATCHER_GATEWAY).get();
    List<String> availableMetrics = response.getMetrics().stream().map(AggregatedMetric::getId).sorted().collect(Collectors.toList());
    assertEquals(2, availableMetrics.size());
    assertEquals("abc.metric1", availableMetrics.get(0));
    assertEquals("abc.metric2", availableMetrics.get(1));
}
Also used : AggregatedMetricsResponseBody(org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody) AggregatedMetric(org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) Test(org.junit.Test)

Example 9 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class AggregatingMetricsHandlerTestBase method testDefaultAggregation.

@Test
public void testDefaultAggregation() throws Exception {
    Map<String, List<String>> queryParams = new HashMap<>(4);
    queryParams.put("get", Collections.singletonList("abc.metric1"));
    HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), handler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, queryParams, Collections.emptyList());
    AggregatedMetricsResponseBody response = handler.handleRequest(request, MOCK_DISPATCHER_GATEWAY).get();
    Collection<AggregatedMetric> aggregatedMetrics = response.getMetrics();
    assertEquals(1, aggregatedMetrics.size());
    AggregatedMetric aggregatedMetric = aggregatedMetrics.iterator().next();
    assertEquals("abc.metric1", aggregatedMetric.getId());
    assertEquals(1.0, aggregatedMetric.getMin(), 0.1);
    assertEquals(3.0, aggregatedMetric.getMax(), 0.1);
    assertEquals(2.0, aggregatedMetric.getAvg(), 0.1);
    assertEquals(4.0, aggregatedMetric.getSum(), 0.1);
}
Also used : AggregatedMetricsResponseBody(org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody) AggregatedMetric(org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric) HashMap(java.util.HashMap) List(java.util.List) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) Test(org.junit.Test)

Example 10 with EmptyRequestBody

use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.

the class TaskManagerDetailsHandlerTest method testTaskManagerMetricsInfoExtraction.

@Test
public void testTaskManagerMetricsInfoExtraction() throws RestHandlerException, ExecutionException, InterruptedException, JsonProcessingException, HandlerRequestException {
    initializeMetricStore(metricFetcher.getMetricStore());
    resourceManagerGateway.setRequestTaskManagerDetailsInfoFunction(taskManagerId -> CompletableFuture.completedFuture(new TaskManagerInfoWithSlots(createEmptyTaskManagerInfo(), Collections.emptyList())));
    HandlerRequest<EmptyRequestBody> request = createRequest();
    TaskManagerDetailsInfo taskManagerDetailsInfo = testInstance.handleRequest(request, resourceManagerGateway).get();
    TaskManagerMetricsInfo actual = taskManagerDetailsInfo.getTaskManagerMetricsInfo();
    TaskManagerMetricsInfo expected = new TaskManagerMetricsInfo(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 20L, Collections.emptyList());
    ObjectMapper objectMapper = new ObjectMapper();
    String actualJson = objectMapper.writeValueAsString(actual);
    String expectedJson = objectMapper.writeValueAsString(expected);
    assertThat(actualJson, is(expectedJson));
}
Also used : TaskManagerMetricsInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo) TaskManagerInfoWithSlots(org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) TaskManagerDetailsInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo) ObjectMapper(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)30 Test (org.junit.Test)23 HashMap (java.util.HashMap)12 List (java.util.List)8 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)7 AggregatedMetric (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric)7 AggregatedMetricsResponseBody (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody)7 RestfulGateway (org.apache.flink.runtime.webmonitor.RestfulGateway)6 JobExceptionsInfoWithHistory (org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory)5 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)5 Map (java.util.Map)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Nonnull (javax.annotation.Nonnull)4 JobID (org.apache.flink.api.common.JobID)4 Time (org.apache.flink.api.common.time.Time)4 HandlerRequest (org.apache.flink.runtime.rest.handler.HandlerRequest)4 DefaultExecutionGraphCache (org.apache.flink.runtime.rest.handler.legacy.DefaultExecutionGraphCache)4 Path (java.nio.file.Path)3 CompletionException (java.util.concurrent.CompletionException)3 ExecutionException (java.util.concurrent.ExecutionException)3