Search in sources :

Example 1 with JobVertexMessageParameters

use of org.apache.flink.runtime.rest.messages.JobVertexMessageParameters in project flink by apache.

the class JobVertexBackPressureHandlerTest method testGetBackPressure.

@Test
public void testGetBackPressure() throws Exception {
    final Map<String, String> pathParameters = new HashMap<>();
    pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE.toString());
    pathParameters.put(JobVertexIdPathParameter.KEY, TEST_JOB_VERTEX_ID.toString());
    final HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), new JobVertexMessageParameters(), pathParameters, Collections.emptyMap(), Collections.emptyList());
    final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture = jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
    final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();
    assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.OK));
    assertThat(jobVertexBackPressureInfo.getBackpressureLevel(), equalTo(HIGH));
    assertThat(jobVertexBackPressureInfo.getSubtasks().stream().map(SubtaskBackPressureInfo::getBackPressuredRatio).collect(Collectors.toList()), contains(1.0, 0.5, 0.1));
    assertThat(jobVertexBackPressureInfo.getSubtasks().stream().map(SubtaskBackPressureInfo::getIdleRatio).collect(Collectors.toList()), contains(0.0, 0.1, 0.2));
    assertThat(jobVertexBackPressureInfo.getSubtasks().stream().map(SubtaskBackPressureInfo::getBusyRatio).collect(Collectors.toList()), contains(0.0, 0.9, 0.7));
    assertThat(jobVertexBackPressureInfo.getSubtasks().stream().map(SubtaskBackPressureInfo::getBackpressureLevel).collect(Collectors.toList()), contains(HIGH, LOW, OK));
    assertThat(jobVertexBackPressureInfo.getSubtasks().stream().map(SubtaskBackPressureInfo::getSubtask).collect(Collectors.toList()), contains(0, 1, 3));
}
Also used : HashMap(java.util.HashMap) JobVertexBackPressureInfo(org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) SubtaskBackPressureInfo(org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo.SubtaskBackPressureInfo) JobVertexMessageParameters(org.apache.flink.runtime.rest.messages.JobVertexMessageParameters) Test(org.junit.Test)

Example 2 with JobVertexMessageParameters

use of org.apache.flink.runtime.rest.messages.JobVertexMessageParameters 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 3 with JobVertexMessageParameters

use of org.apache.flink.runtime.rest.messages.JobVertexMessageParameters in project flink by apache.

the class JobVertexBackPressureHandlerTest method testAbsentBackPressure.

@Test
public void testAbsentBackPressure() throws Exception {
    final Map<String, String> pathParameters = new HashMap<>();
    pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT.toString());
    pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());
    final HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), new JobVertexMessageParameters(), pathParameters, Collections.emptyMap(), Collections.emptyList());
    final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture = jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
    final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();
    assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
}
Also used : HashMap(java.util.HashMap) JobVertexBackPressureInfo(org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobVertexMessageParameters(org.apache.flink.runtime.rest.messages.JobVertexMessageParameters) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)3 JobVertexMessageParameters (org.apache.flink.runtime.rest.messages.JobVertexMessageParameters)3 EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)2 JobVertexBackPressureInfo (org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo)2 Test (org.junit.Test)2 AccessExecutionJobVertex (org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex)1 AccessExecutionVertex (org.apache.flink.runtime.executiongraph.AccessExecutionVertex)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 MetricFetcher (org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher)1 MetricStore (org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore)1 SubtaskBackPressureInfo (org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo.SubtaskBackPressureInfo)1 Before (org.junit.Before)1