org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo Java Examples

The following examples show how to use org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo. 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: JobVertexBackPressureHandlerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
}
 
Example #2
Source File: JobVertexBackPressureHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static JobVertexBackPressureInfo createJobVertexBackPressureInfo(
		final OperatorBackPressureStats operatorBackPressureStats) {
	return new JobVertexBackPressureInfo(
		JobVertexBackPressureInfo.VertexBackPressureStatus.OK,
		getBackPressureLevel(operatorBackPressureStats.getMaxBackPressureRatio()),
		operatorBackPressureStats.getEndTimestamp(),
		IntStream.range(0, operatorBackPressureStats.getNumberOfSubTasks())
			.mapToObj(subtask -> {
				final double backPressureRatio = operatorBackPressureStats.getBackPressureRatio(subtask);
				return new JobVertexBackPressureInfo.SubtaskBackPressureInfo(
					subtask,
					getBackPressureLevel(backPressureRatio),
					backPressureRatio);
			})
			.collect(Collectors.toList()));
}
 
Example #3
Source File: JobVertexBackPressureHandlerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
}
 
Example #4
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private static JobVertexBackPressureInfo createJobVertexBackPressureInfo(
		final OperatorBackPressureStats operatorBackPressureStats) {
	return new JobVertexBackPressureInfo(
		JobVertexBackPressureInfo.VertexBackPressureStatus.OK,
		getBackPressureLevel(operatorBackPressureStats.getMaxBackPressureRatio()),
		operatorBackPressureStats.getEndTimestamp(),
		IntStream.range(0, operatorBackPressureStats.getNumberOfSubTasks())
			.mapToObj(subtask -> {
				final double backPressureRatio = operatorBackPressureStats.getBackPressureRatio(subtask);
				return new JobVertexBackPressureInfo.SubtaskBackPressureInfo(
					subtask,
					getBackPressureLevel(backPressureRatio),
					backPressureRatio);
			})
			.collect(Collectors.toList()));
}
 
Example #5
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private static JobVertexBackPressureInfo createJobVertexBackPressureInfo(
		final OperatorBackPressureStats operatorBackPressureStats) {
	return new JobVertexBackPressureInfo(
		JobVertexBackPressureInfo.VertexBackPressureStatus.OK,
		getBackPressureLevel(operatorBackPressureStats.getMaxBackPressureRatio()),
		operatorBackPressureStats.getEndTimestamp(),
		IntStream.range(0, operatorBackPressureStats.getNumberOfSubTasks())
			.mapToObj(subtask -> {
				final double backPressureRatio = operatorBackPressureStats.getBackPressureRatio(subtask);
				return new JobVertexBackPressureInfo.SubtaskBackPressureInfo(
					subtask,
					getBackPressureLevel(backPressureRatio),
					backPressureRatio);
			})
			.collect(Collectors.toList()));
}
 
Example #6
Source File: JobVertexBackPressureHandlerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
		jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
	final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();

	assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
}
 
Example #7
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the back pressure level as a String.
 *
 * @param backPressureRatio Ratio of back pressures samples to total number of samples.
 *
 * @return Back pressure level ('ok', 'low', or 'high')
 */
private static JobVertexBackPressureInfo.VertexBackPressureLevel getBackPressureLevel(double backPressureRatio) {
	if (backPressureRatio <= 0.10) {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.OK;
	} else if (backPressureRatio <= 0.5) {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.LOW;
	} else {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH;
	}
}
 
Example #8
Source File: JobVertexBackPressureHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@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, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	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(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getRatio)
		.collect(Collectors.toList()), contains(1.0, 0.5, 0.1));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getBackpressureLevel)
		.collect(Collectors.toList()), contains(HIGH, LOW, OK));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getSubtask)
		.collect(Collectors.toList()), contains(0, 1, 2));
}
 
Example #9
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the back pressure level as a String.
 *
 * @param backPressureRatio Ratio of back pressures samples to total number of samples.
 *
 * @return Back pressure level ('ok', 'low', or 'high')
 */
private static JobVertexBackPressureInfo.VertexBackPressureLevel getBackPressureLevel(double backPressureRatio) {
	if (backPressureRatio <= 0.10) {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.OK;
	} else if (backPressureRatio <= 0.5) {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.LOW;
	} else {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH;
	}
}
 
Example #10
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JobVertexBackPressureInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
		@Nonnull RestfulGateway gateway) throws RestHandlerException {
	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final JobVertexID jobVertexId = request.getPathParameter(JobVertexIdPathParameter.class);
	return gateway
		.requestOperatorBackPressureStats(jobId, jobVertexId)
		.thenApply(
			operatorBackPressureStats ->
				operatorBackPressureStats.getOperatorBackPressureStats().map(
					JobVertexBackPressureHandler::createJobVertexBackPressureInfo).orElse(
					JobVertexBackPressureInfo.deprecated()));
}
 
Example #11
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
public JobVertexBackPressureHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> messageHeaders) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders);
}
 
Example #12
Source File: JobVertexBackPressureHandlerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@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, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	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(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getRatio)
		.collect(Collectors.toList()), contains(1.0, 0.5, 0.1));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getBackpressureLevel)
		.collect(Collectors.toList()), contains(HIGH, LOW, OK));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getSubtask)
		.collect(Collectors.toList()), contains(0, 1, 2));
}
 
Example #13
Source File: JobVertexBackPressureHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public JobVertexBackPressureHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> messageHeaders) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders);
}
 
Example #14
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JobVertexBackPressureInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
		@Nonnull RestfulGateway gateway) throws RestHandlerException {
	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final JobVertexID jobVertexId = request.getPathParameter(JobVertexIdPathParameter.class);
	return gateway
		.requestOperatorBackPressureStats(jobId, jobVertexId)
		.thenApply(
			operatorBackPressureStats ->
				operatorBackPressureStats.getOperatorBackPressureStats().map(
					JobVertexBackPressureHandler::createJobVertexBackPressureInfo).orElse(
					JobVertexBackPressureInfo.deprecated()));
}
 
Example #15
Source File: JobVertexBackPressureHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
public JobVertexBackPressureHandler(
		GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		Time timeout,
		Map<String, String> responseHeaders,
		MessageHeaders<EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> messageHeaders) {
	super(leaderRetriever, timeout, responseHeaders, messageHeaders);
}
 
Example #16
Source File: JobVertexBackPressureHandlerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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, new JobVertexID().toString());

	final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
		new HandlerRequest<>(
			EmptyRequestBody.getInstance(),
			new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());

	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(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getRatio)
		.collect(Collectors.toList()), contains(1.0, 0.5, 0.1));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getBackpressureLevel)
		.collect(Collectors.toList()), contains(HIGH, LOW, OK));

	assertThat(jobVertexBackPressureInfo.getSubtasks()
		.stream()
		.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getSubtask)
		.collect(Collectors.toList()), contains(0, 1, 2));
}
 
Example #17
Source File: JobVertexBackPressureHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the back pressure level as a String.
 *
 * @param backPressureRatio Ratio of back pressures samples to total number of samples.
 *
 * @return Back pressure level ('ok', 'low', or 'high')
 */
private static JobVertexBackPressureInfo.VertexBackPressureLevel getBackPressureLevel(double backPressureRatio) {
	if (backPressureRatio <= 0.10) {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.OK;
	} else if (backPressureRatio <= 0.5) {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.LOW;
	} else {
		return JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH;
	}
}
 
Example #18
Source File: JobVertexBackPressureHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected CompletableFuture<JobVertexBackPressureInfo> handleRequest(
		@Nonnull HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
		@Nonnull RestfulGateway gateway) throws RestHandlerException {
	final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
	final JobVertexID jobVertexId = request.getPathParameter(JobVertexIdPathParameter.class);
	return gateway
		.requestOperatorBackPressureStats(jobId, jobVertexId)
		.thenApply(
			operatorBackPressureStats ->
				operatorBackPressureStats.getOperatorBackPressureStats().map(
					JobVertexBackPressureHandler::createJobVertexBackPressureInfo).orElse(
					JobVertexBackPressureInfo.deprecated()));
}