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);
}
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;
}
});
}
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);
}
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);
}
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;
}
}
Aggregations