org.apache.flink.runtime.rest.messages.job.metrics.Metric Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.messages.job.metrics.Metric.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YARNHighAvailabilityITCase.java From flink with Apache License 2.0 | 6 votes |
private static Optional<Metric> getJobMetric( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId, final String metricName) throws Exception { final JobMetricsMessageParameters messageParameters = new JobMetricsMessageParameters(); messageParameters.jobPathParameter.resolve(jobId); messageParameters.metricsFilterParameter.resolveFromString(metricName); final Collection<Metric> metrics = restClusterClient.sendRequest( JobMetricsHeaders.getInstance(), messageParameters, EmptyRequestBody.getInstance()).get().getMetrics(); final Metric metric = Iterables.getOnlyElement(metrics, null); checkState(metric == null || metric.getId().equals(metricName)); return Optional.ofNullable(metric); }
Example #2
Source File: AbstractMetricsHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testListMetrics() throws Exception { final CompletableFuture<MetricCollectionResponseBody> completableFuture = testMetricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), new TestMessageParameters(), Collections.emptyMap(), Collections.emptyMap()), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(TEST_METRIC_NAME)); assertThat(metric.getValue(), equalTo(null)); }
Example #3
Source File: AbstractMetricsHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testGetMetrics() throws Exception { final CompletableFuture<MetricCollectionResponseBody> completableFuture = testMetricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), new TestMessageParameters(), Collections.emptyMap(), Collections.singletonMap(METRICS_FILTER_QUERY_PARAM, Collections.singletonList(TEST_METRIC_NAME))), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(TEST_METRIC_NAME)); assertThat(metric.getValue(), equalTo(Integer.toString(TEST_METRIC_VALUE))); }
Example #4
Source File: MetricsHandlerTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that the metric with name defined under {@link #TEST_METRIC_NAME} can be retrieved * from the {@link MetricStore.ComponentMetricStore} returned from * {@link AbstractMetricsHandler#getComponentMetricStore(HandlerRequest, MetricStore)}. */ @Test public void testGetMetric() throws Exception { @SuppressWarnings("unchecked") final CompletableFuture<MetricCollectionResponseBody> completableFuture = metricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), metricsHandler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, Collections.emptyMap()), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(getExpectedIdForMetricName(TEST_METRIC_NAME))); }
Example #5
Source File: YARNHighAvailabilityITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static Optional<Metric> getJobMetric( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId, final String metricName) throws Exception { final JobMetricsMessageParameters messageParameters = new JobMetricsMessageParameters(); messageParameters.jobPathParameter.resolve(jobId); messageParameters.metricsFilterParameter.resolveFromString(metricName); final Collection<Metric> metrics = restClusterClient.sendRequest( JobMetricsHeaders.getInstance(), messageParameters, EmptyRequestBody.getInstance()).get().getMetrics(); final Metric metric = Iterables.getOnlyElement(metrics, null); checkState(metric == null || metric.getId().equals(metricName)); return Optional.ofNullable(metric); }
Example #6
Source File: MetricsHandlerTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the metric with name defined under {@link #TEST_METRIC_NAME} can be retrieved * from the {@link MetricStore.ComponentMetricStore} returned from * {@link AbstractMetricsHandler#getComponentMetricStore(HandlerRequest, MetricStore)}. */ @Test public void testGetMetric() throws Exception { @SuppressWarnings("unchecked") final CompletableFuture<MetricCollectionResponseBody> completableFuture = metricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), metricsHandler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, Collections.emptyMap()), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(getExpectedIdForMetricName(TEST_METRIC_NAME))); }
Example #7
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGetMetrics() throws Exception { final CompletableFuture<MetricCollectionResponseBody> completableFuture = testMetricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), new TestMessageParameters(), Collections.emptyMap(), Collections.singletonMap(METRICS_FILTER_QUERY_PARAM, Collections.singletonList(TEST_METRIC_NAME))), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(TEST_METRIC_NAME)); assertThat(metric.getValue(), equalTo(Integer.toString(TEST_METRIC_VALUE))); }
Example #8
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testListMetrics() throws Exception { final CompletableFuture<MetricCollectionResponseBody> completableFuture = testMetricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), new TestMessageParameters(), Collections.emptyMap(), Collections.emptyMap()), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(TEST_METRIC_NAME)); assertThat(metric.getValue(), equalTo(null)); }
Example #9
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGetMetrics() throws Exception { final CompletableFuture<MetricCollectionResponseBody> completableFuture = testMetricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), new TestMessageParameters(), Collections.emptyMap(), Collections.singletonMap(METRICS_FILTER_QUERY_PARAM, Collections.singletonList(TEST_METRIC_NAME))), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(TEST_METRIC_NAME)); assertThat(metric.getValue(), equalTo(Integer.toString(TEST_METRIC_VALUE))); }
Example #10
Source File: MetricsHandlerTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the metric with name defined under {@link #TEST_METRIC_NAME} can be retrieved * from the {@link MetricStore.ComponentMetricStore} returned from * {@link AbstractMetricsHandler#getComponentMetricStore(HandlerRequest, MetricStore)}. */ @Test public void testGetMetric() throws Exception { @SuppressWarnings("unchecked") final CompletableFuture<MetricCollectionResponseBody> completableFuture = metricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), metricsHandler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, Collections.emptyMap()), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(getExpectedIdForMetricName(TEST_METRIC_NAME))); }
Example #11
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testListMetrics() throws Exception { final CompletableFuture<MetricCollectionResponseBody> completableFuture = testMetricsHandler.handleRequest( new HandlerRequest<>( EmptyRequestBody.getInstance(), new TestMessageParameters(), Collections.emptyMap(), Collections.emptyMap()), mockDispatcherGateway); assertTrue(completableFuture.isDone()); final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get(); assertThat(metricCollectionResponseBody.getMetrics(), hasSize(1)); final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next(); assertThat(metric.getId(), equalTo(TEST_METRIC_NAME)); assertThat(metric.getValue(), equalTo(null)); }
Example #12
Source File: YARNHighAvailabilityITCase.java From flink with Apache License 2.0 | 6 votes |
private static Optional<Metric> getJobMetric( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId, final String metricName) throws Exception { final JobMetricsMessageParameters messageParameters = new JobMetricsMessageParameters(); messageParameters.jobPathParameter.resolve(jobId); messageParameters.metricsFilterParameter.resolveFromString(metricName); final Collection<Metric> metrics = restClusterClient.sendRequest( JobMetricsHeaders.getInstance(), messageParameters, EmptyRequestBody.getInstance()).get().getMetrics(); final Metric metric = Iterables.getOnlyElement(metrics, null); checkState(metric == null || metric.getId().equals(metricName)); return Optional.ofNullable(metric); }
Example #13
Source File: YARNHighAvailabilityITCase.java From flink with Apache License 2.0 | 5 votes |
private static int getJobFullRestarts( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId) throws Exception { return getJobMetric(restClusterClient, jobId, "fullRestarts") .map(Metric::getValue) .map(Integer::parseInt) .orElse(0); }
Example #14
Source File: YARNHighAvailabilityITCase.java From flink with Apache License 2.0 | 5 votes |
private static int getJobFullRestarts( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId) throws Exception { return getJobMetric(restClusterClient, jobId, "fullRestarts") .map(Metric::getValue) .map(Integer::parseInt) .orElse(0); }
Example #15
Source File: JobVertexWatermarksHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Override public boolean matches(Object o) { if (!(o instanceof Metric)) { return false; } Metric actual = (Metric) o; return actual.getId().equals(id) && Objects.equals(value, actual.getValue()); }
Example #16
Source File: AbstractMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
private static List<Metric> getRequestedMetrics( MetricStore.ComponentMetricStore componentMetricStore, Set<String> requestedMetrics) throws RestHandlerException { final List<Metric> metrics = new ArrayList<>(requestedMetrics.size()); for (final String requestedMetric : requestedMetrics) { final String value = componentMetricStore.getMetric(requestedMetric, null); if (value != null) { metrics.add(new Metric(requestedMetric, value)); } } return metrics; }
Example #17
Source File: AbstractMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
private static List<Metric> getAvailableMetrics(MetricStore.ComponentMetricStore componentMetricStore) { return componentMetricStore.metrics .keySet() .stream() .map(Metric::new) .collect(Collectors.toList()); }
Example #18
Source File: JobVertexWatermarksHandler.java From flink with Apache License 2.0 | 5 votes |
@Override protected MetricCollectionResponseBody handleRequest( HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request, AccessExecutionJobVertex jobVertex) throws RestHandlerException { String jobID = request.getPathParameter(JobIDPathParameter.class).toString(); String taskID = jobVertex.getJobVertexId().toString(); metricFetcher.update(); MetricStore.TaskMetricStore taskMetricStore = metricFetcher.getMetricStore().getTaskMetricStore(jobID, taskID); if (taskMetricStore == null) { return new MetricCollectionResponseBody(Collections.emptyList()); } AccessExecutionVertex[] taskVertices = jobVertex.getTaskVertices(); List<Metric> metrics = new ArrayList<>(taskVertices.length); for (AccessExecutionVertex taskVertex : taskVertices) { String id = taskVertex.getParallelSubtaskIndex() + "." + MetricNames.IO_CURRENT_INPUT_WATERMARK; String watermarkValue = taskMetricStore.getMetric(id); if (watermarkValue != null) { metrics.add(new Metric(id, watermarkValue)); } } return new MetricCollectionResponseBody(metrics); }
Example #19
Source File: AbstractMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static List<Metric> getAvailableMetrics(MetricStore.ComponentMetricStore componentMetricStore) { return componentMetricStore.metrics .keySet() .stream() .map(Metric::new) .collect(Collectors.toList()); }
Example #20
Source File: AbstractMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
private static List<Metric> getRequestedMetrics( MetricStore.ComponentMetricStore componentMetricStore, Set<String> requestedMetrics) throws RestHandlerException { final List<Metric> metrics = new ArrayList<>(requestedMetrics.size()); for (final String requestedMetric : requestedMetrics) { final String value = componentMetricStore.getMetric(requestedMetric, null); if (value != null) { metrics.add(new Metric(requestedMetric, value)); } } return metrics; }
Example #21
Source File: AbstractMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
private static List<Metric> getAvailableMetrics(MetricStore.ComponentMetricStore componentMetricStore) { return componentMetricStore.metrics .keySet() .stream() .map(Metric::new) .collect(Collectors.toList()); }
Example #22
Source File: YARNHighAvailabilityITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static int getJobFullRestarts( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId) throws Exception { return getJobMetric(restClusterClient, jobId, "fullRestarts") .map(Metric::getValue) .map(Integer::parseInt) .orElse(0); }
Example #23
Source File: AbstractMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static List<Metric> getRequestedMetrics( MetricStore.ComponentMetricStore componentMetricStore, Set<String> requestedMetrics) throws RestHandlerException { final List<Metric> metrics = new ArrayList<>(requestedMetrics.size()); for (final String requestedMetric : requestedMetrics) { final String value = componentMetricStore.getMetric(requestedMetric, null); if (value != null) { metrics.add(new Metric(requestedMetric, value)); } } return metrics; }
Example #24
Source File: JobVertexWatermarksHandlerTest.java From flink with Apache License 2.0 | 4 votes |
@Override public void describeTo(Description description) { description.appendValue(new Metric(id, value)); }