use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric 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));
}
use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric 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);
}
use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric 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());
}
use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric 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());
}
use of org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric 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());
}
Aggregations