Java Code Examples for org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus#NOT_FOUND

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus#NOT_FOUND . 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: CheckpointConfigHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private static CheckpointConfigInfo createCheckpointConfigInfo(AccessExecutionGraph executionGraph) throws RestHandlerException {
	final CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration = executionGraph.getCheckpointCoordinatorConfiguration();

	if (checkpointCoordinatorConfiguration == null) {
		throw new RestHandlerException(
			"Checkpointing is not enabled for this job (" + executionGraph.getJobID() + ").",
			HttpResponseStatus.NOT_FOUND);
	} else {
		CheckpointRetentionPolicy retentionPolicy = checkpointCoordinatorConfiguration.getCheckpointRetentionPolicy();

		CheckpointConfigInfo.ExternalizedCheckpointInfo externalizedCheckpointInfo = new CheckpointConfigInfo.ExternalizedCheckpointInfo(
				retentionPolicy != CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION,
				retentionPolicy != CheckpointRetentionPolicy.RETAIN_ON_CANCELLATION);

		String stateBackendName = executionGraph.getStateBackendName().orElse(null);

		return new CheckpointConfigInfo(
			checkpointCoordinatorConfiguration.isExactlyOnce() ? CheckpointConfigInfo.ProcessingMode.EXACTLY_ONCE : CheckpointConfigInfo.ProcessingMode.AT_LEAST_ONCE,
			checkpointCoordinatorConfiguration.getCheckpointInterval(),
			checkpointCoordinatorConfiguration.getCheckpointTimeout(),
			checkpointCoordinatorConfiguration.getMinPauseBetweenCheckpoints(),
			checkpointCoordinatorConfiguration.getMaxConcurrentCheckpoints(),
			externalizedCheckpointInfo,
			stateBackendName);
	}
}
 
Example 2
Source File: AbstractCheckpointHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected R handleRequest(HandlerRequest<EmptyRequestBody, M> request, AccessExecutionGraph executionGraph) throws RestHandlerException {
	final long checkpointId = request.getPathParameter(CheckpointIdPathParameter.class);

	final CheckpointStatsSnapshot checkpointStatsSnapshot = executionGraph.getCheckpointStatsSnapshot();

	if (checkpointStatsSnapshot != null) {
		AbstractCheckpointStats checkpointStats = checkpointStatsSnapshot.getHistory().getCheckpointById(checkpointId);

		if (checkpointStats != null) {
			checkpointStatsCache.tryAdd(checkpointStats);
		} else {
			checkpointStats = checkpointStatsCache.tryGet(checkpointId);
		}

		if (checkpointStats != null) {
			return handleCheckpointRequest(request, checkpointStats);
		} else {
			throw new RestHandlerException("Could not find checkpointing statistics for checkpoint " + checkpointId + '.', HttpResponseStatus.NOT_FOUND);
		}
	} else {
		throw new RestHandlerException("Checkpointing was not enabled for job " + executionGraph.getJobID() + '.', HttpResponseStatus.NOT_FOUND);
	}
}
 
Example 3
Source File: CheckpointConfigHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static CheckpointConfigInfo createCheckpointConfigInfo(AccessExecutionGraph executionGraph) throws RestHandlerException {
	final CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration = executionGraph.getCheckpointCoordinatorConfiguration();

	if (checkpointCoordinatorConfiguration == null) {
		throw new RestHandlerException(
			"Checkpointing is not enabled for this job (" + executionGraph.getJobID() + ").",
			HttpResponseStatus.NOT_FOUND);
	} else {
		CheckpointRetentionPolicy retentionPolicy = checkpointCoordinatorConfiguration.getCheckpointRetentionPolicy();

		CheckpointConfigInfo.ExternalizedCheckpointInfo externalizedCheckpointInfo = new CheckpointConfigInfo.ExternalizedCheckpointInfo(
				retentionPolicy != CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION,
				retentionPolicy != CheckpointRetentionPolicy.RETAIN_ON_CANCELLATION);

		return new CheckpointConfigInfo(
			checkpointCoordinatorConfiguration.isExactlyOnce() ? CheckpointConfigInfo.ProcessingMode.EXACTLY_ONCE : CheckpointConfigInfo.ProcessingMode.AT_LEAST_ONCE,
			checkpointCoordinatorConfiguration.getCheckpointInterval(),
			checkpointCoordinatorConfiguration.getCheckpointTimeout(),
			checkpointCoordinatorConfiguration.getMinPauseBetweenCheckpoints(),
			checkpointCoordinatorConfiguration.getMaxConcurrentCheckpoints(),
			externalizedCheckpointInfo);
	}
}
 
Example 4
Source File: CheckpointConfigHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
private static CheckpointConfigInfo createCheckpointConfigInfo(AccessExecutionGraph executionGraph) throws RestHandlerException {
	final CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration = executionGraph.getCheckpointCoordinatorConfiguration();

	if (checkpointCoordinatorConfiguration == null) {
		throw new RestHandlerException(
			"Checkpointing is not enabled for this job (" + executionGraph.getJobID() + ").",
			HttpResponseStatus.NOT_FOUND);
	} else {
		CheckpointRetentionPolicy retentionPolicy = checkpointCoordinatorConfiguration.getCheckpointRetentionPolicy();

		CheckpointConfigInfo.ExternalizedCheckpointInfo externalizedCheckpointInfo = new CheckpointConfigInfo.ExternalizedCheckpointInfo(
				retentionPolicy != CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION,
				retentionPolicy != CheckpointRetentionPolicy.RETAIN_ON_CANCELLATION);

		return new CheckpointConfigInfo(
			checkpointCoordinatorConfiguration.isExactlyOnce() ? CheckpointConfigInfo.ProcessingMode.EXACTLY_ONCE : CheckpointConfigInfo.ProcessingMode.AT_LEAST_ONCE,
			checkpointCoordinatorConfiguration.getCheckpointInterval(),
			checkpointCoordinatorConfiguration.getCheckpointTimeout(),
			checkpointCoordinatorConfiguration.getMinPauseBetweenCheckpoints(),
			checkpointCoordinatorConfiguration.getMaxConcurrentCheckpoints(),
			externalizedCheckpointInfo);
	}
}
 
Example 5
Source File: AbstractCheckpointHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected R handleRequest(HandlerRequest<EmptyRequestBody, M> request, AccessExecutionGraph executionGraph) throws RestHandlerException {
	final long checkpointId = request.getPathParameter(CheckpointIdPathParameter.class);

	final CheckpointStatsSnapshot checkpointStatsSnapshot = executionGraph.getCheckpointStatsSnapshot();

	if (checkpointStatsSnapshot != null) {
		AbstractCheckpointStats checkpointStats = checkpointStatsSnapshot.getHistory().getCheckpointById(checkpointId);

		if (checkpointStats != null) {
			checkpointStatsCache.tryAdd(checkpointStats);
		} else {
			checkpointStats = checkpointStatsCache.tryGet(checkpointId);
		}

		if (checkpointStats != null) {
			return handleCheckpointRequest(request, checkpointStats);
		} else {
			throw new RestHandlerException("Could not find checkpointing statistics for checkpoint " + checkpointId + '.', HttpResponseStatus.NOT_FOUND);
		}
	} else {
		throw new RestHandlerException("Checkpointing was not enabled for job " + executionGraph.getJobID() + '.', HttpResponseStatus.NOT_FOUND);
	}
}
 
Example 6
Source File: AbstractSubtaskAttemptHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected R handleRequest(HandlerRequest<EmptyRequestBody, M> request, AccessExecutionVertex executionVertex) throws RestHandlerException {
	final Integer attemptNumber = request.getPathParameter(SubtaskAttemptPathParameter.class);

	final AccessExecution currentAttempt = executionVertex.getCurrentExecutionAttempt();
	if (attemptNumber == currentAttempt.getAttemptNumber()) {
		return handleRequest(request, currentAttempt);
	} else if (attemptNumber >= 0 && attemptNumber < currentAttempt.getAttemptNumber()) {
		final AccessExecution execution = executionVertex.getPriorExecutionAttempt(attemptNumber);

		if (execution != null) {
			return handleRequest(request, execution);
		} else {
			throw new RestHandlerException("Attempt " + attemptNumber + " not found in subtask " +
				executionVertex.getTaskNameWithSubtaskIndex(), HttpResponseStatus.NOT_FOUND);
		}
	} else {
		throw new RestHandlerException("Invalid attempt num " + attemptNumber, HttpResponseStatus.NOT_FOUND);
	}
}
 
Example 7
Source File: AbstractJobVertexHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected R handleRequest(
		HandlerRequest<EmptyRequestBody, M> request,
		AccessExecutionGraph executionGraph) throws RestHandlerException {

	final JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
	final AccessExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexID);

	if (jobVertex == null) {
		throw new RestHandlerException("No vertex with ID '" + jobVertexID + "' exists.", HttpResponseStatus.NOT_FOUND);
	}

	return handleRequest(request, jobVertex);
}
 
Example 8
Source File: AbstractSubtaskHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected R handleRequest(
		HandlerRequest<EmptyRequestBody, M> request,
		AccessExecutionJobVertex jobVertex) throws RestHandlerException {

	final Integer subtaskIndex = request.getPathParameter(SubtaskIndexPathParameter.class);
	final AccessExecutionVertex[] executionVertices = jobVertex.getTaskVertices();

	if (subtaskIndex >= executionVertices.length || subtaskIndex < 0) {
		throw new RestHandlerException("Invalid subtask index for vertex " + jobVertex.getJobVertexId(), HttpResponseStatus.NOT_FOUND);
	}

	return handleRequest(request, executionVertices[subtaskIndex]);
}
 
Example 9
Source File: JobExecutionResultHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private static CompletionException propagateException(final Throwable throwable) {
	final Throwable cause = ExceptionUtils.stripCompletionException(throwable);

	if (cause instanceof FlinkJobNotFoundException) {
		throw new CompletionException(new RestHandlerException(
			throwable.getMessage(),
			HttpResponseStatus.NOT_FOUND,
			throwable));
	} else {
		throw new CompletionException(throwable);
	}
}
 
Example 10
Source File: JobExecutionResultHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
private static CompletionException propagateException(final Throwable throwable) {
	final Throwable cause = ExceptionUtils.stripCompletionException(throwable);

	if (cause instanceof FlinkJobNotFoundException) {
		throw new CompletionException(new RestHandlerException(
			throwable.getMessage(),
			HttpResponseStatus.NOT_FOUND,
			throwable));
	} else {
		throw new CompletionException(throwable);
	}
}
 
Example 11
Source File: JobExecutionResultHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static CompletionException propagateException(final Throwable throwable) {
	final Throwable cause = ExceptionUtils.stripCompletionException(throwable);

	if (cause instanceof FlinkJobNotFoundException) {
		throw new CompletionException(new RestHandlerException(
			throwable.getMessage(),
			HttpResponseStatus.NOT_FOUND,
			throwable));
	} else {
		throw new CompletionException(throwable);
	}
}
 
Example 12
Source File: AbstractJobVertexHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected R handleRequest(
		HandlerRequest<EmptyRequestBody, M> request,
		AccessExecutionGraph executionGraph) throws RestHandlerException {

	final JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
	final AccessExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexID);

	if (jobVertex == null) {
		throw new RestHandlerException("No vertex with ID '" + jobVertexID + "' exists.", HttpResponseStatus.NOT_FOUND);
	}

	return handleRequest(request, jobVertex);
}
 
Example 13
Source File: AbstractSubtaskHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected R handleRequest(
		HandlerRequest<EmptyRequestBody, M> request,
		AccessExecutionJobVertex jobVertex) throws RestHandlerException {

	final Integer subtaskIndex = request.getPathParameter(SubtaskIndexPathParameter.class);
	final AccessExecutionVertex[] executionVertices = jobVertex.getTaskVertices();

	if (subtaskIndex >= executionVertices.length || subtaskIndex < 0) {
		throw new RestHandlerException("Invalid subtask index for vertex " + jobVertex.getJobVertexId(), HttpResponseStatus.NOT_FOUND);
	}

	return handleRequest(request, executionVertices[subtaskIndex]);
}
 
Example 14
Source File: NotFoundException.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public NotFoundException(String message, Throwable cause) {
	super(message, HttpResponseStatus.NOT_FOUND, cause);
}
 
Example 15
Source File: CheckpointingStatisticsHandler.java    From flink with Apache License 2.0 4 votes vote down vote up
private static CheckpointingStatistics createCheckpointingStatistics(AccessExecutionGraph executionGraph) throws RestHandlerException {
	final CheckpointStatsSnapshot checkpointStatsSnapshot = executionGraph.getCheckpointStatsSnapshot();

	if (checkpointStatsSnapshot == null) {
		throw new RestHandlerException("Checkpointing has not been enabled.", HttpResponseStatus.NOT_FOUND);
	} else {
		final CheckpointStatsCounts checkpointStatsCounts = checkpointStatsSnapshot.getCounts();

		final CheckpointingStatistics.Counts counts = new CheckpointingStatistics.Counts(
			checkpointStatsCounts.getNumberOfRestoredCheckpoints(),
			checkpointStatsCounts.getTotalNumberOfCheckpoints(),
			checkpointStatsCounts.getNumberOfInProgressCheckpoints(),
			checkpointStatsCounts.getNumberOfCompletedCheckpoints(),
			checkpointStatsCounts.getNumberOfFailedCheckpoints());

		final CompletedCheckpointStatsSummary checkpointStatsSummary = checkpointStatsSnapshot.getSummaryStats();
		final MinMaxAvgStats stateSize = checkpointStatsSummary.getStateSizeStats();
		final MinMaxAvgStats duration = checkpointStatsSummary.getEndToEndDurationStats();
		final MinMaxAvgStats alignment = checkpointStatsSummary.getAlignmentBufferedStats();

		final CheckpointingStatistics.Summary summary = new CheckpointingStatistics.Summary(
			new MinMaxAvgStatistics(
				stateSize.getMinimum(),
				stateSize.getMaximum(),
				stateSize.getAverage()),
			new MinMaxAvgStatistics(
				duration.getMinimum(),
				duration.getMaximum(),
				duration.getAverage()),
			new MinMaxAvgStatistics(
				alignment.getMinimum(),
				alignment.getMaximum(),
				alignment.getAverage()));

		final CheckpointStatsHistory checkpointStatsHistory = checkpointStatsSnapshot.getHistory();

		final CheckpointStatistics.CompletedCheckpointStatistics completed = checkpointStatsHistory.getLatestCompletedCheckpoint() != null ?
			(CheckpointStatistics.CompletedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(
				checkpointStatsHistory.getLatestCompletedCheckpoint(),
				false) :
			null;

		final CheckpointStatistics.CompletedCheckpointStatistics savepoint = checkpointStatsHistory.getLatestSavepoint() != null ?
			(CheckpointStatistics.CompletedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(
				checkpointStatsHistory.getLatestSavepoint(),
				false) :
			null;

		final CheckpointStatistics.FailedCheckpointStatistics failed = checkpointStatsHistory.getLatestFailedCheckpoint() != null ?
			(CheckpointStatistics.FailedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(
				checkpointStatsHistory.getLatestFailedCheckpoint(),
				false) :
			null;

		final RestoredCheckpointStats restoredCheckpointStats = checkpointStatsSnapshot.getLatestRestoredCheckpoint();

		final CheckpointingStatistics.RestoredCheckpointStatistics restored;

		if (restoredCheckpointStats == null) {
			restored = null;
		} else {
			restored = new CheckpointingStatistics.RestoredCheckpointStatistics(
				restoredCheckpointStats.getCheckpointId(),
				restoredCheckpointStats.getRestoreTimestamp(),
				restoredCheckpointStats.getProperties().isSavepoint(),
				restoredCheckpointStats.getExternalPath());
		}

		final CheckpointingStatistics.LatestCheckpoints latestCheckpoints = new CheckpointingStatistics.LatestCheckpoints(
			completed,
			savepoint,
			failed,
			restored);

		final List<CheckpointStatistics> history = new ArrayList<>(16);

		for (AbstractCheckpointStats abstractCheckpointStats : checkpointStatsSnapshot.getHistory().getCheckpoints()) {
			history.add(CheckpointStatistics.generateCheckpointStatistics(abstractCheckpointStats, false));
		}

		return new CheckpointingStatistics(
			counts,
			summary,
			latestCheckpoints,
			history);
	}
}
 
Example 16
Source File: NotFoundException.java    From flink with Apache License 2.0 4 votes vote down vote up
public NotFoundException(String message, Throwable cause) {
	super(message, HttpResponseStatus.NOT_FOUND, cause);
}
 
Example 17
Source File: NotFoundException.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public NotFoundException(String message) {
	super(message, HttpResponseStatus.NOT_FOUND);
}
 
Example 18
Source File: NotFoundException.java    From flink with Apache License 2.0 4 votes vote down vote up
public NotFoundException(String message) {
	super(message, HttpResponseStatus.NOT_FOUND);
}
 
Example 19
Source File: NotFoundException.java    From flink with Apache License 2.0 4 votes vote down vote up
public NotFoundException(String message, Throwable cause) {
	super(message, HttpResponseStatus.NOT_FOUND, cause);
}
 
Example 20
Source File: CheckpointingStatisticsHandler.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static CheckpointingStatistics createCheckpointingStatistics(AccessExecutionGraph executionGraph) throws RestHandlerException {
	final CheckpointStatsSnapshot checkpointStatsSnapshot = executionGraph.getCheckpointStatsSnapshot();

	if (checkpointStatsSnapshot == null) {
		throw new RestHandlerException("Checkpointing has not been enabled.", HttpResponseStatus.NOT_FOUND);
	} else {
		final CheckpointStatsCounts checkpointStatsCounts = checkpointStatsSnapshot.getCounts();

		final CheckpointingStatistics.Counts counts = new CheckpointingStatistics.Counts(
			checkpointStatsCounts.getNumberOfRestoredCheckpoints(),
			checkpointStatsCounts.getTotalNumberOfCheckpoints(),
			checkpointStatsCounts.getNumberOfInProgressCheckpoints(),
			checkpointStatsCounts.getNumberOfCompletedCheckpoints(),
			checkpointStatsCounts.getNumberOfFailedCheckpoints());

		final CompletedCheckpointStatsSummary checkpointStatsSummary = checkpointStatsSnapshot.getSummaryStats();
		final MinMaxAvgStats stateSize = checkpointStatsSummary.getStateSizeStats();
		final MinMaxAvgStats duration = checkpointStatsSummary.getEndToEndDurationStats();
		final MinMaxAvgStats alignment = checkpointStatsSummary.getAlignmentBufferedStats();

		final CheckpointingStatistics.Summary summary = new CheckpointingStatistics.Summary(
			new MinMaxAvgStatistics(
				stateSize.getMinimum(),
				stateSize.getMaximum(),
				stateSize.getAverage()),
			new MinMaxAvgStatistics(
				duration.getMinimum(),
				duration.getMaximum(),
				duration.getAverage()),
			new MinMaxAvgStatistics(
				alignment.getMinimum(),
				alignment.getMaximum(),
				alignment.getAverage()));

		final CheckpointStatsHistory checkpointStatsHistory = checkpointStatsSnapshot.getHistory();

		final CheckpointStatistics.CompletedCheckpointStatistics completed = checkpointStatsHistory.getLatestCompletedCheckpoint() != null ?
			(CheckpointStatistics.CompletedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(
				checkpointStatsHistory.getLatestCompletedCheckpoint(),
				false) :
			null;

		final CheckpointStatistics.CompletedCheckpointStatistics savepoint = checkpointStatsHistory.getLatestSavepoint() != null ?
			(CheckpointStatistics.CompletedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(
				checkpointStatsHistory.getLatestSavepoint(),
				false) :
			null;

		final CheckpointStatistics.FailedCheckpointStatistics failed = checkpointStatsHistory.getLatestFailedCheckpoint() != null ?
			(CheckpointStatistics.FailedCheckpointStatistics) CheckpointStatistics.generateCheckpointStatistics(
				checkpointStatsHistory.getLatestFailedCheckpoint(),
				false) :
			null;

		final RestoredCheckpointStats restoredCheckpointStats = checkpointStatsSnapshot.getLatestRestoredCheckpoint();

		final CheckpointingStatistics.RestoredCheckpointStatistics restored;

		if (restoredCheckpointStats == null) {
			restored = null;
		} else {
			restored = new CheckpointingStatistics.RestoredCheckpointStatistics(
				restoredCheckpointStats.getCheckpointId(),
				restoredCheckpointStats.getRestoreTimestamp(),
				restoredCheckpointStats.getProperties().isSavepoint(),
				restoredCheckpointStats.getExternalPath());
		}

		final CheckpointingStatistics.LatestCheckpoints latestCheckpoints = new CheckpointingStatistics.LatestCheckpoints(
			completed,
			savepoint,
			failed,
			restored);

		final List<CheckpointStatistics> history = new ArrayList<>(16);

		for (AbstractCheckpointStats abstractCheckpointStats : checkpointStatsSnapshot.getHistory().getCheckpoints()) {
			history.add(CheckpointStatistics.generateCheckpointStatistics(abstractCheckpointStats, false));
		}

		return new CheckpointingStatistics(
			counts,
			summary,
			latestCheckpoints,
			history);
	}
}