org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore.
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: MetricsHandlerTestBase.java From flink with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.leaderRetriever = new GatewayRetriever<DispatcherGateway>() { @Override public CompletableFuture<DispatcherGateway> getFuture() { return CompletableFuture.completedFuture(mockDispatcherGateway); } }; this.pathParameters = getPathParameters(); this.metricsHandler = getMetricsHandler(); final MetricStore metricStore = new MetricStore(); metricStore.add(new MetricDump.CounterDump(getQueryScopeInfo(), TEST_METRIC_NAME, TEST_METRIC_VALUE)); when(mockMetricFetcher.getMetricStore()).thenReturn(metricStore); }
Example #2
Source File: AggregatingSubtasksMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedSubtaskMetricsParameters> request) { JobID jobID = request.getPathParameter(JobIDPathParameter.class); JobVertexID taskID = request.getPathParameter(JobVertexIdPathParameter.class); Collection<String> subtaskRanges = request.getQueryParameter(SubtasksFilterQueryParameter.class); if (subtaskRanges.isEmpty()) { MetricStore.TaskMetricStore taskMetricStore = store.getTaskMetricStore(jobID.toString(), taskID.toString()); if (taskMetricStore != null) { return taskMetricStore.getAllSubtaskMetricStores(); } else { return Collections.emptyList(); } } else { Iterable<Integer> subtasks = getIntegerRangeFromString(subtaskRanges); Collection<MetricStore.ComponentMetricStore> subtaskStores = new ArrayList<>(8); for (int subtask : subtasks) { MetricStore.ComponentMetricStore subtaskMetricStore = store.getSubtaskMetricStore(jobID.toString(), taskID.toString(), subtask); if (subtaskMetricStore != null) { subtaskStores.add(subtaskMetricStore); } } return subtaskStores; } }
Example #3
Source File: AggregatingTaskManagersMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregateTaskManagerMetricsParameters> request) { List<ResourceID> taskmanagers = request.getQueryParameter(TaskManagersFilterQueryParameter.class); if (taskmanagers.isEmpty()) { return store.getTaskManagers().values(); } else { Collection<MetricStore.TaskManagerMetricStore> taskmanagerStores = new ArrayList<>(taskmanagers.size()); for (ResourceID taskmanager : taskmanagers) { MetricStore.TaskManagerMetricStore taskManagerMetricStore = store.getTaskManagerMetricStore(taskmanager.getResourceIdString()); if (taskManagerMetricStore != null) { taskmanagerStores.add(taskManagerMetricStore); } } return taskmanagerStores; } }
Example #4
Source File: AggregatingJobsMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedJobMetricsParameters> request) { List<JobID> jobs = request.getQueryParameter(JobsFilterQueryParameter.class); if (jobs.isEmpty()) { return store.getJobs().values(); } else { Collection<MetricStore.ComponentMetricStore> jobStores = new ArrayList<>(jobs.size()); for (JobID job : jobs) { MetricStore.ComponentMetricStore jobMetricStore = store.getJobMetricStore(job.toString()); if (jobMetricStore != null) { jobStores.add(jobMetricStore); } } return jobStores; } }
Example #5
Source File: TaskManagerDetailsHandler.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static List<TaskManagerMetricsInfo.GarbageCollectorInfo> createGarbageCollectorInfo(MetricStore.TaskManagerMetricStore taskManagerMetricStore) { Preconditions.checkNotNull(taskManagerMetricStore); ArrayList<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfos = new ArrayList<>(taskManagerMetricStore.garbageCollectorNames.size()); for (String garbageCollectorName: taskManagerMetricStore.garbageCollectorNames) { final String count = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Count", null); final String time = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Time", null); if (count != null && time != null) { garbageCollectorInfos.add( new TaskManagerMetricsInfo.GarbageCollectorInfo( garbageCollectorName, Long.valueOf(count), Long.valueOf(time))); } } return garbageCollectorInfos; }
Example #6
Source File: AggregatingSubtasksMetricsHandler.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedSubtaskMetricsParameters> request) { JobID jobID = request.getPathParameter(JobIDPathParameter.class); JobVertexID taskID = request.getPathParameter(JobVertexIdPathParameter.class); Collection<String> subtaskRanges = request.getQueryParameter(SubtasksFilterQueryParameter.class); if (subtaskRanges.isEmpty()) { MetricStore.TaskMetricStore taskMetricStore = store.getTaskMetricStore(jobID.toString(), taskID.toString()); if (taskMetricStore != null) { return taskMetricStore.getAllSubtaskMetricStores(); } else { return Collections.emptyList(); } } else { Iterable<Integer> subtasks = getIntegerRangeFromString(subtaskRanges); Collection<MetricStore.ComponentMetricStore> subtaskStores = new ArrayList<>(8); for (int subtask : subtasks) { MetricStore.ComponentMetricStore subtaskMetricStore = store.getSubtaskMetricStore(jobID.toString(), taskID.toString(), subtask); if (subtaskMetricStore != null) { subtaskStores.add(subtaskMetricStore); } } return subtaskStores; } }
Example #7
Source File: AbstractMetricsHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); final MetricStore metricStore = new MetricStore(); metricStore.add(new MetricDump.CounterDump( new QueryScopeInfo.JobManagerQueryScopeInfo(), TEST_METRIC_NAME, TEST_METRIC_VALUE)); when(mockMetricFetcher.getMetricStore()).thenReturn(metricStore); testMetricsHandler = new TestMetricsHandler( new GatewayRetriever<DispatcherGateway>() { @Override public CompletableFuture<DispatcherGateway> getFuture() { return CompletableFuture.completedFuture(mockDispatcherGateway); } }, Time.milliseconds(50), Collections.emptyMap(), new TestMetricsHeaders(), mockMetricFetcher); }
Example #8
Source File: MetricsHandlerTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.leaderRetriever = new GatewayRetriever<DispatcherGateway>() { @Override public CompletableFuture<DispatcherGateway> getFuture() { return CompletableFuture.completedFuture(mockDispatcherGateway); } }; this.pathParameters = getPathParameters(); this.metricsHandler = getMetricsHandler(); final MetricStore metricStore = new MetricStore(); metricStore.add(new MetricDump.CounterDump(getQueryScopeInfo(), TEST_METRIC_NAME, TEST_METRIC_VALUE)); when(mockMetricFetcher.getMetricStore()).thenReturn(metricStore); }
Example #9
Source File: TaskManagerDetailsHandler.java From flink with Apache License 2.0 | 6 votes |
private static List<TaskManagerMetricsInfo.GarbageCollectorInfo> createGarbageCollectorInfo(MetricStore.TaskManagerMetricStore taskManagerMetricStore) { Preconditions.checkNotNull(taskManagerMetricStore); ArrayList<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfos = new ArrayList<>(taskManagerMetricStore.garbageCollectorNames.size()); for (String garbageCollectorName: taskManagerMetricStore.garbageCollectorNames) { final String count = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Count", null); final String time = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Time", null); if (count != null && time != null) { garbageCollectorInfos.add( new TaskManagerMetricsInfo.GarbageCollectorInfo( garbageCollectorName, Long.valueOf(count), Long.valueOf(time))); } } return garbageCollectorInfos; }
Example #10
Source File: AggregatingJobsMetricsHandler.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedJobMetricsParameters> request) { List<JobID> jobs = request.getQueryParameter(JobsFilterQueryParameter.class); if (jobs.isEmpty()) { return store.getJobs().values(); } else { Collection<MetricStore.ComponentMetricStore> jobStores = new ArrayList<>(jobs.size()); for (JobID job : jobs) { MetricStore.ComponentMetricStore jobMetricStore = store.getJobMetricStore(job.toString()); if (jobMetricStore != null) { jobStores.add(jobMetricStore); } } return jobStores; } }
Example #11
Source File: AggregatingTaskManagersMetricsHandler.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregateTaskManagerMetricsParameters> request) { List<ResourceID> taskmanagers = request.getQueryParameter(TaskManagersFilterQueryParameter.class); if (taskmanagers.isEmpty()) { return store.getTaskManagers().values(); } else { Collection<MetricStore.TaskManagerMetricStore> taskmanagerStores = new ArrayList<>(taskmanagers.size()); for (ResourceID taskmanager : taskmanagers) { MetricStore.TaskManagerMetricStore taskManagerMetricStore = store.getTaskManagerMetricStore(taskmanager.getResourceIdString()); if (taskManagerMetricStore != null) { taskmanagerStores.add(taskManagerMetricStore); } } return taskmanagerStores; } }
Example #12
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); final MetricStore metricStore = new MetricStore(); metricStore.add(new MetricDump.CounterDump( new QueryScopeInfo.JobManagerQueryScopeInfo(), TEST_METRIC_NAME, TEST_METRIC_VALUE)); when(mockMetricFetcher.getMetricStore()).thenReturn(metricStore); testMetricsHandler = new TestMetricsHandler( new GatewayRetriever<DispatcherGateway>() { @Override public CompletableFuture<DispatcherGateway> getFuture() { return CompletableFuture.completedFuture(mockDispatcherGateway); } }, Time.milliseconds(50), Collections.emptyMap(), new TestMetricsHeaders(), mockMetricFetcher); }
Example #13
Source File: MetricsHandlerTestBase.java From flink with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.leaderRetriever = new GatewayRetriever<DispatcherGateway>() { @Override public CompletableFuture<DispatcherGateway> getFuture() { return CompletableFuture.completedFuture(mockDispatcherGateway); } }; this.pathParameters = getPathParameters(); this.metricsHandler = getMetricsHandler(); final MetricStore metricStore = new MetricStore(); metricStore.add(new MetricDump.CounterDump(getQueryScopeInfo(), TEST_METRIC_NAME, TEST_METRIC_VALUE)); when(mockMetricFetcher.getMetricStore()).thenReturn(metricStore); }
Example #14
Source File: TaskManagerDetailsHandler.java From flink with Apache License 2.0 | 6 votes |
private static List<TaskManagerMetricsInfo.GarbageCollectorInfo> createGarbageCollectorInfo(MetricStore.TaskManagerMetricStore taskManagerMetricStore) { Preconditions.checkNotNull(taskManagerMetricStore); ArrayList<TaskManagerMetricsInfo.GarbageCollectorInfo> garbageCollectorInfos = new ArrayList<>(taskManagerMetricStore.garbageCollectorNames.size()); for (String garbageCollectorName: taskManagerMetricStore.garbageCollectorNames) { final String count = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Count", null); final String time = taskManagerMetricStore.getMetric("Status.JVM.GarbageCollector." + garbageCollectorName + ".Time", null); if (count != null && time != null) { garbageCollectorInfos.add( new TaskManagerMetricsInfo.GarbageCollectorInfo( garbageCollectorName, Long.valueOf(count), Long.valueOf(time))); } } return garbageCollectorInfos; }
Example #15
Source File: AggregatingJobsMetricsHandler.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedJobMetricsParameters> request) { List<JobID> jobs = request.getQueryParameter(JobsFilterQueryParameter.class); if (jobs.isEmpty()) { return store.getJobs().values(); } else { Collection<MetricStore.ComponentMetricStore> jobStores = new ArrayList<>(jobs.size()); for (JobID job : jobs) { MetricStore.ComponentMetricStore jobMetricStore = store.getJobMetricStore(job.toString()); if (jobMetricStore != null) { jobStores.add(jobMetricStore); } } return jobStores; } }
Example #16
Source File: AggregatingTaskManagersMetricsHandler.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregateTaskManagerMetricsParameters> request) { List<ResourceID> taskmanagers = request.getQueryParameter(TaskManagersFilterQueryParameter.class); if (taskmanagers.isEmpty()) { return store.getTaskManagers().values(); } else { Collection<MetricStore.TaskManagerMetricStore> taskmanagerStores = new ArrayList<>(taskmanagers.size()); for (ResourceID taskmanager : taskmanagers) { MetricStore.TaskManagerMetricStore taskManagerMetricStore = store.getTaskManagerMetricStore(taskmanager.getResourceIdString()); if (taskManagerMetricStore != null) { taskmanagerStores.add(taskManagerMetricStore); } } return taskmanagerStores; } }
Example #17
Source File: AggregatingSubtasksMetricsHandler.java From flink with Apache License 2.0 | 6 votes |
@Nonnull @Override Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregatedSubtaskMetricsParameters> request) { JobID jobID = request.getPathParameter(JobIDPathParameter.class); JobVertexID taskID = request.getPathParameter(JobVertexIdPathParameter.class); Collection<String> subtaskRanges = request.getQueryParameter(SubtasksFilterQueryParameter.class); if (subtaskRanges.isEmpty()) { MetricStore.TaskMetricStore taskMetricStore = store.getTaskMetricStore(jobID.toString(), taskID.toString()); if (taskMetricStore != null) { return taskMetricStore.getAllSubtaskMetricStores(); } else { return Collections.emptyList(); } } else { Iterable<Integer> subtasks = getIntegerRangeFromString(subtaskRanges); Collection<MetricStore.ComponentMetricStore> subtaskStores = new ArrayList<>(8); for (int subtask : subtasks) { MetricStore.ComponentMetricStore subtaskMetricStore = store.getSubtaskMetricStore(jobID.toString(), taskID.toString(), subtask); if (subtaskMetricStore != null) { subtaskStores.add(subtaskMetricStore); } } return subtaskStores; } }
Example #18
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); final MetricStore metricStore = new MetricStore(); metricStore.add(new MetricDump.CounterDump( new QueryScopeInfo.JobManagerQueryScopeInfo(), TEST_METRIC_NAME, TEST_METRIC_VALUE)); when(mockMetricFetcher.getMetricStore()).thenReturn(metricStore); testMetricsHandler = new TestMetricsHandler( new GatewayRetriever<DispatcherGateway>() { @Override public CompletableFuture<DispatcherGateway> getFuture() { return CompletableFuture.completedFuture(mockDispatcherGateway); } }, Time.milliseconds(50), Collections.emptyMap(), new TestMetricsHeaders(), mockMetricFetcher); }
Example #19
Source File: JobVertexWatermarksHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Before public void before() throws Exception { taskMetricStore = Mockito.mock(MetricStore.TaskMetricStore.class); MetricStore metricStore = Mockito.mock(MetricStore.class); Mockito.when(metricStore.getTaskMetricStore(TEST_JOB_ID.toString(), TEST_VERTEX_ID.toString())) .thenReturn(taskMetricStore); metricFetcher = Mockito.mock(MetricFetcher.class); Mockito.when(metricFetcher.getMetricStore()).thenReturn(metricStore); watermarkHandler = new JobVertexWatermarksHandler( Mockito.mock(LeaderGatewayRetriever.class), Time.seconds(1), Collections.emptyMap(), metricFetcher, NoOpExecutionGraphCache.INSTANCE, Mockito.mock(Executor.class)); final Map<String, String> pathParameters = new HashMap<>(); pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID.toString()); pathParameters.put(JobVertexIdPathParameter.KEY, TEST_VERTEX_ID.toString()); request = new HandlerRequest<>(EmptyRequestBody.getInstance(), new JobVertexMessageParameters(), pathParameters, Collections.emptyMap()); vertex = Mockito.mock(AccessExecutionJobVertex.class); Mockito.when(vertex.getJobVertexId()).thenReturn(TEST_VERTEX_ID); AccessExecutionVertex firstTask = Mockito.mock(AccessExecutionVertex.class); AccessExecutionVertex secondTask = Mockito.mock(AccessExecutionVertex.class); Mockito.when(firstTask.getParallelSubtaskIndex()).thenReturn(0); Mockito.when(secondTask.getParallelSubtaskIndex()).thenReturn(1); AccessExecutionVertex[] accessExecutionVertices = {firstTask, secondTask}; Mockito.when(vertex.getTaskVertices()).thenReturn(accessExecutionVertices); }
Example #20
Source File: AbstractAggregatingMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
/** * Extracts and aggregates all requested metrics from the given metric stores, and maps the result to a JSON string. * * @param stores available metrics * @param requestedMetrics ids of requested metrics * @param requestedAggregationsFactories requested aggregations * @return JSON string containing the requested metrics */ private AggregatedMetricsResponseBody getAggregatedMetricValues( Collection<? extends MetricStore.ComponentMetricStore> stores, List<String> requestedMetrics, MetricAccumulatorFactory requestedAggregationsFactories) { Collection<AggregatedMetric> aggregatedMetrics = new ArrayList<>(requestedMetrics.size()); for (String requestedMetric : requestedMetrics) { final Collection<Double> values = new ArrayList<>(stores.size()); try { for (MetricStore.ComponentMetricStore store : stores) { String stringValue = store.metrics.get(requestedMetric); if (stringValue != null) { values.add(Double.valueOf(stringValue)); } } } catch (NumberFormatException nfe) { log.warn("The metric {} is not numeric and can't be aggregated.", requestedMetric, nfe); // metric is not numeric so we can't perform aggregations => ignore it continue; } if (!values.isEmpty()) { Iterator<Double> valuesIterator = values.iterator(); MetricAccumulator acc = requestedAggregationsFactories.get(requestedMetric, valuesIterator.next()); valuesIterator.forEachRemaining(acc::add); aggregatedMetrics.add(acc.get()); } else { return new AggregatedMetricsResponseBody(Collections.emptyList()); } } return new AggregatedMetricsResponseBody(aggregatedMetrics); }
Example #21
Source File: AbstractAggregatingMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
/** * Returns a JSON string containing a list of all available metrics in the given stores. Effectively this method maps * the union of all key-sets to JSON. * * @param stores metrics * @return JSON string containing a list of all available metrics */ private static Collection<String> getAvailableMetrics(Collection<? extends MetricStore.ComponentMetricStore> stores) { Set<String> uniqueMetrics = new HashSet<>(32); for (MetricStore.ComponentMetricStore store : stores) { uniqueMetrics.addAll(store.metrics.keySet()); } return uniqueMetrics; }
Example #22
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 #23
Source File: SubtaskMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
@Nullable @Override protected MetricStore.ComponentMetricStore getComponentMetricStore( HandlerRequest<EmptyRequestBody, SubtaskMetricsMessageParameters> request, MetricStore metricStore) { final JobID jobId = request.getPathParameter(JobIDPathParameter.class); final JobVertexID vertexId = request.getPathParameter(JobVertexIdPathParameter.class); final int subtaskIndex = request.getPathParameter(SubtaskIndexPathParameter.class); return metricStore.getSubtaskMetricStore(jobId.toString(), vertexId.toString(), subtaskIndex); }
Example #24
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 #25
Source File: AbstractAggregatingMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Returns a JSON string containing a list of all available metrics in the given stores. Effectively this method maps * the union of all key-sets to JSON. * * @param stores metrics * @return JSON string containing a list of all available metrics */ private static Collection<String> getAvailableMetrics(Collection<? extends MetricStore.ComponentMetricStore> stores) { Set<String> uniqueMetrics = new HashSet<>(32); for (MetricStore.ComponentMetricStore store : stores) { uniqueMetrics.addAll(store.metrics.keySet()); } return uniqueMetrics; }
Example #26
Source File: AbstractMetricsHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Nullable @Override protected MetricStore.ComponentMetricStore getComponentMetricStore( HandlerRequest<EmptyRequestBody, TestMessageParameters> request, MetricStore metricStore) { return returnComponentMetricStore ? metricStore.getJobManager() : null; }
Example #27
Source File: AbstractAggregatingMetricsHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Extracts and aggregates all requested metrics from the given metric stores, and maps the result to a JSON string. * * @param stores available metrics * @param requestedMetrics ids of requested metrics * @param requestedAggregationsFactories requested aggregations * @return JSON string containing the requested metrics */ private AggregatedMetricsResponseBody getAggregatedMetricValues( Collection<? extends MetricStore.ComponentMetricStore> stores, List<String> requestedMetrics, MetricAccumulatorFactory requestedAggregationsFactories) { Collection<AggregatedMetric> aggregatedMetrics = new ArrayList<>(requestedMetrics.size()); for (String requestedMetric : requestedMetrics) { final Collection<Double> values = new ArrayList<>(stores.size()); try { for (MetricStore.ComponentMetricStore store : stores) { String stringValue = store.metrics.get(requestedMetric); if (stringValue != null) { values.add(Double.valueOf(stringValue)); } } } catch (NumberFormatException nfe) { log.warn("The metric {} is not numeric and can't be aggregated.", requestedMetric, nfe); // metric is not numeric so we can't perform aggregations => ignore it continue; } if (!values.isEmpty()) { Iterator<Double> valuesIterator = values.iterator(); MetricAccumulator acc = requestedAggregationsFactories.get(requestedMetric, valuesIterator.next()); valuesIterator.forEachRemaining(acc::add); aggregatedMetrics.add(acc.get()); } else { return new AggregatedMetricsResponseBody(Collections.emptyList()); } } return new AggregatedMetricsResponseBody(aggregatedMetrics); }
Example #28
Source File: JobVertexMetricsHandler.java From flink with Apache License 2.0 | 5 votes |
@Override protected MetricStore.ComponentMetricStore getComponentMetricStore( HandlerRequest<EmptyRequestBody, JobVertexMetricsMessageParameters> request, MetricStore metricStore) { final JobID jobId = request.getPathParameter(JobIDPathParameter.class); final JobVertexID vertexId = request.getPathParameter(JobVertexIdPathParameter.class); return metricStore.getTaskMetricStore(jobId.toString(), vertexId.toString()); }
Example #29
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 #30
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; }