Search in sources :

Example 1 with MetricStore

use of org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore in project flink by apache.

the class JobVertexWatermarksHandlerTest method before.

@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 = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), new JobVertexMessageParameters(), pathParameters, Collections.emptyMap(), Collections.emptyList());
    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);
}
Also used : MetricStore(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore) AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) HashMap(java.util.HashMap) MetricFetcher(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher) JobVertexMessageParameters(org.apache.flink.runtime.rest.messages.JobVertexMessageParameters) AccessExecutionVertex(org.apache.flink.runtime.executiongraph.AccessExecutionVertex) Before(org.junit.Before)

Example 2 with MetricStore

use of org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore in project flink by apache.

the class JobVertexBackPressureHandlerTest method setUp.

@Before
public void setUp() {
    metricStore = new MetricStore();
    for (MetricDump metricDump : getMetricDumps()) {
        metricStore.add(metricDump);
    }
    jobVertexBackPressureHandler = new JobVertexBackPressureHandler(() -> CompletableFuture.completedFuture(restfulGateway), Time.seconds(10), Collections.emptyMap(), JobVertexBackPressureHeaders.getInstance(), new MetricFetcher() {

        private long updateCount = 0;

        @Override
        public MetricStore getMetricStore() {
            return metricStore;
        }

        @Override
        public void update() {
            updateCount++;
        }

        @Override
        public long getLastUpdateTime() {
            return updateCount;
        }
    });
}
Also used : MetricStore(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore) MetricDump(org.apache.flink.runtime.metrics.dump.MetricDump) MetricFetcher(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher) Before(org.junit.Before)

Example 3 with MetricStore

use of org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore in project flink by apache.

the class AbstractMetricsHandlerTest method setUp.

@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);
}
Also used : MetricStore(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore) MetricDump(org.apache.flink.runtime.metrics.dump.MetricDump) GatewayRetriever(org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever) DispatcherGateway(org.apache.flink.runtime.dispatcher.DispatcherGateway) Before(org.junit.Before)

Example 4 with MetricStore

use of org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore in project flink by apache.

the class MetricsHandlerTestBase method setUp.

@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);
}
Also used : MetricStore(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore) CompletableFuture(java.util.concurrent.CompletableFuture) MetricDump(org.apache.flink.runtime.metrics.dump.MetricDump) DispatcherGateway(org.apache.flink.runtime.dispatcher.DispatcherGateway) Before(org.junit.Before)

Example 5 with MetricStore

use of org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore in project flink by apache.

the class AggregatingSubtasksMetricsHandler method getStores.

@Nonnull
@Override
Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody> 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().values();
        } 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;
    }
}
Also used : MetricStore(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ArrayList(java.util.ArrayList) JobID(org.apache.flink.api.common.JobID) Nonnull(javax.annotation.Nonnull)

Aggregations

MetricStore (org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore)6 Before (org.junit.Before)4 MetricDump (org.apache.flink.runtime.metrics.dump.MetricDump)3 DispatcherGateway (org.apache.flink.runtime.dispatcher.DispatcherGateway)2 MetricFetcher (org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionException (java.util.concurrent.CompletionException)1 Nonnull (javax.annotation.Nonnull)1 JobID (org.apache.flink.api.common.JobID)1 AccessExecutionJobVertex (org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex)1 AccessExecutionVertex (org.apache.flink.runtime.executiongraph.AccessExecutionVertex)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 JobVertexMessageParameters (org.apache.flink.runtime.rest.messages.JobVertexMessageParameters)1 AggregatedMetric (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetric)1 AggregatedMetricsResponseBody (org.apache.flink.runtime.rest.messages.job.metrics.AggregatedMetricsResponseBody)1 MetricsAggregationParameter (org.apache.flink.runtime.rest.messages.job.metrics.MetricsAggregationParameter)1 GatewayRetriever (org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever)1