Search in sources :

Example 1 with AggregatedMetricsResponseBody

use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody 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 2 with AggregatedMetricsResponseBody

use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody 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 3 with AggregatedMetricsResponseBody

use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody in project flink by apache.

the class AggregatingMetricsHandlerTestBase method testMaxAggregation.

@Test
public void testMaxAggregation() throws Exception {
    Map<String, List<String>> queryParams = new HashMap<>(4);
    queryParams.put("get", Collections.singletonList("abc.metric1"));
    queryParams.put("agg", Collections.singletonList("max"));
    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(3.0, aggregatedMetric.getMax(), 0.1);
    assertNull(aggregatedMetric.getMin());
    assertNull(aggregatedMetric.getSum());
    assertNull(aggregatedMetric.getAvg());
}
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 4 with AggregatedMetricsResponseBody

use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody in project flink by apache.

the class AggregatingMetricsHandlerTestBase method testAvgAggregation.

@Test
public void testAvgAggregation() throws Exception {
    Map<String, List<String>> queryParams = new HashMap<>(4);
    queryParams.put("get", Collections.singletonList("abc.metric1"));
    queryParams.put("agg", Collections.singletonList("avg"));
    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(2.0, aggregatedMetric.getAvg(), 0.1);
    assertNull(aggregatedMetric.getMin());
    assertNull(aggregatedMetric.getMax());
    assertNull(aggregatedMetric.getSum());
}
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 5 with AggregatedMetricsResponseBody

use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody in project flink by apache.

the class AggregatingMetricsHandlerTestBase method testMinAggregation.

@Test
public void testMinAggregation() throws Exception {
    Map<String, List<String>> queryParams = new HashMap<>(4);
    queryParams.put("get", Collections.singletonList("abc.metric1"));
    queryParams.put("agg", Collections.singletonList("min"));
    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);
    assertNull(aggregatedMetric.getMax());
    assertNull(aggregatedMetric.getSum());
    assertNull(aggregatedMetric.getAvg());
}
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)

Aggregations

AggregatedMetric (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric)9 AggregatedMetricsResponseBody (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody)9 EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)8 Test (org.junit.Test)7 HashMap (java.util.HashMap)6 List (java.util.List)6 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 CompletionException (java.util.concurrent.CompletionException)1 Executors (java.util.concurrent.Executors)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 JobID (org.apache.flink.api.common.JobID)1 Configuration (org.apache.flink.configuration.Configuration)1 TestEnvironment (org.apache.flink.connector.testframe.environment.TestEnvironment)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 RestClient (org.apache.flink.runtime.rest.RestClient)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 MetricStore (org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore)1