org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats Java Examples

The following examples show how to use org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats. 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: 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 #2
Source File: JobVertexBackPressureHandlerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
	restfulGateway = TestingRestfulGateway.newBuilder().setRequestOperatorBackPressureStatsFunction(
		(jobId, jobVertexId) -> {
			if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE)) {
				return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(new OperatorBackPressureStats(
					4711,
					Integer.MAX_VALUE,
					new double[]{1.0, 0.5, 0.1}
				)));
			} else if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT)) {
				return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(null));
			} else {
				throw new AssertionError();
			}
		}
	).build();
	jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
		() -> CompletableFuture.completedFuture(restfulGateway),
		Time.seconds(10),
		Collections.emptyMap(),
		JobVertexBackPressureHeaders.getInstance()
	);
}
 
Example #3
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 #4
Source File: JobVertexBackPressureHandlerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
	restfulGateway = TestingRestfulGateway.newBuilder().setRequestOperatorBackPressureStatsFunction(
		(jobId, jobVertexId) -> {
			if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE)) {
				return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(new OperatorBackPressureStats(
					4711,
					Integer.MAX_VALUE,
					new double[]{1.0, 0.5, 0.1}
				)));
			} else if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT)) {
				return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(null));
			} else {
				throw new AssertionError();
			}
		}
	).build();
	jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
		() -> CompletableFuture.completedFuture(restfulGateway),
		Time.seconds(10),
		Collections.emptyMap(),
		JobVertexBackPressureHeaders.getInstance()
	);
}
 
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
@Before
public void setUp() {
	restfulGateway = new TestingRestfulGateway.Builder().setRequestOperatorBackPressureStatsFunction(
		(jobId, jobVertexId) -> {
			if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE)) {
				return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(new OperatorBackPressureStats(
					4711,
					Integer.MAX_VALUE,
					new double[]{1.0, 0.5, 0.1}
				)));
			} else if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT)) {
				return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(null));
			} else {
				throw new AssertionError();
			}
		}
	).build();
	jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
		() -> CompletableFuture.completedFuture(restfulGateway),
		Time.seconds(10),
		Collections.emptyMap(),
		JobVertexBackPressureHeaders.getInstance()
	);
}
 
Example #7
Source File: JobMaster.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(final JobVertexID jobVertexId) {
	final ExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexId);
	if (jobVertex == null) {
		return FutureUtils.completedExceptionally(new FlinkException("JobVertexID not found " +
			jobVertexId));
	}

	final Optional<OperatorBackPressureStats> operatorBackPressureStats =
		backPressureStatsTracker.getOperatorBackPressureStats(jobVertex);
	return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(
		operatorBackPressureStats.orElse(null)));
}
 
Example #8
Source File: BackPressureITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private static boolean isBackPressured(final OperatorBackPressureStats backPressureStats) {
	for (int i = 0; i < backPressureStats.getNumberOfSubTasks(); i++) {
		final double subtaskBackPressureRatio = backPressureStats.getBackPressureRatio(i);
		if (subtaskBackPressureRatio != MAX_BACK_PRESSURE_RATIO) {
			return false;
		}
	}
	return true;
}
 
Example #9
Source File: JobMaster.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(final JobVertexID jobVertexId) {
	try {
		final Optional<OperatorBackPressureStats> operatorBackPressureStats = schedulerNG.requestOperatorBackPressureStats(jobVertexId);
		return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(
			operatorBackPressureStats.orElse(null)));
	} catch (FlinkException e) {
		log.info("Error while requesting operator back pressure stats", e);
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #10
Source File: LegacyScheduler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<OperatorBackPressureStats> requestOperatorBackPressureStats(final JobVertexID jobVertexId) throws FlinkException {
	final ExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexId);
	if (jobVertex == null) {
		throw new FlinkException("JobVertexID not found " +
			jobVertexId);
	}

	return backPressureStatsTracker.getOperatorBackPressureStats(jobVertex);
}
 
Example #11
Source File: BackPressureITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private static boolean isBackPressured(final OperatorBackPressureStats backPressureStats) {
	for (int i = 0; i < backPressureStats.getNumberOfSubTasks(); i++) {
		final double subtaskBackPressureRatio = backPressureStats.getBackPressureRatio(i);
		if (subtaskBackPressureRatio != MAX_BACK_PRESSURE_RATIO) {
			return false;
		}
	}
	return true;
}
 
Example #12
Source File: JobMaster.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(final JobVertexID jobVertexId) {
	try {
		final Optional<OperatorBackPressureStats> operatorBackPressureStats = schedulerNG.requestOperatorBackPressureStats(jobVertexId);
		return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(
			operatorBackPressureStats.orElse(null)));
	} catch (FlinkException e) {
		log.info("Error while requesting operator back pressure stats", e);
		return FutureUtils.completedExceptionally(e);
	}
}
 
Example #13
Source File: SchedulerBase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<OperatorBackPressureStats> requestOperatorBackPressureStats(final JobVertexID jobVertexId) throws FlinkException {
	final ExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexId);
	if (jobVertex == null) {
		throw new FlinkException("JobVertexID not found " +
			jobVertexId);
	}

	return backPressureStatsTracker.getOperatorBackPressureStats(jobVertex);
}
 
Example #14
Source File: SchedulerNG.java    From flink with Apache License 2.0 votes vote down vote up
Optional<OperatorBackPressureStats> requestOperatorBackPressureStats(JobVertexID jobVertexId) throws FlinkException; 
Example #15
Source File: SchedulerNG.java    From flink with Apache License 2.0 votes vote down vote up
Optional<OperatorBackPressureStats> requestOperatorBackPressureStats(JobVertexID jobVertexId) throws FlinkException;