Java Code Examples for org.apache.flink.runtime.executiongraph.AccessExecutionGraph#getCheckpointStatsSnapshot()

The following examples show how to use org.apache.flink.runtime.executiongraph.AccessExecutionGraph#getCheckpointStatsSnapshot() . 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: 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 2
Source File: TaskCheckpointStatisticDetailsHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		for (TaskStateStats subtaskStats : checkpoint.getAllTaskStateStats()) {
			ResponseBody json = createCheckpointDetails(checkpoint, subtaskStats);
			String path = getMessageHeaders().getTargetRestEndpointURL()
				.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
				.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()))
				.replace(':' + JobVertexIdPathParameter.KEY, subtaskStats.getJobVertexId().toString());
			archive.add(new ArchivedJson(path, json));
		}
	}
	return archive;
}
 
Example 3
Source File: CheckpointStatisticDetailsHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		ResponseBody json = CheckpointStatistics.generateCheckpointStatistics(checkpoint, true);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()));
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example 4
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 5
Source File: TaskCheckpointStatisticDetailsHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		for (TaskStateStats subtaskStats : checkpoint.getAllTaskStateStats()) {
			ResponseBody json = createCheckpointDetails(checkpoint, subtaskStats);
			String path = getMessageHeaders().getTargetRestEndpointURL()
				.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
				.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()))
				.replace(':' + JobVertexIdPathParameter.KEY, subtaskStats.getJobVertexId().toString());
			archive.add(new ArchivedJson(path, json));
		}
	}
	return archive;
}
 
Example 6
Source File: CheckpointStatisticDetailsHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		ResponseBody json = CheckpointStatistics.generateCheckpointStatistics(checkpoint, true);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()));
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example 7
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 8
Source File: TaskCheckpointStatisticDetailsHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		for (TaskStateStats subtaskStats : checkpoint.getAllTaskStateStats()) {
			ResponseBody json = createCheckpointDetails(checkpoint, subtaskStats);
			String path = getMessageHeaders().getTargetRestEndpointURL()
				.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
				.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()))
				.replace(':' + JobVertexIdPathParameter.KEY, subtaskStats.getJobVertexId().toString());
			archive.add(new ArchivedJson(path, json));
		}
	}
	return archive;
}
 
Example 9
Source File: CheckpointStatisticDetailsHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ArchivedJson> archiveJsonWithPath(AccessExecutionGraph graph) throws IOException {
	CheckpointStatsSnapshot stats = graph.getCheckpointStatsSnapshot();
	if (stats == null) {
		return Collections.emptyList();
	}
	CheckpointStatsHistory history = stats.getHistory();
	List<ArchivedJson> archive = new ArrayList<>(history.getCheckpoints().size());
	for (AbstractCheckpointStats checkpoint : history.getCheckpoints()) {
		ResponseBody json = CheckpointStatistics.generateCheckpointStatistics(checkpoint, true);
		String path = getMessageHeaders().getTargetRestEndpointURL()
			.replace(':' + JobIDPathParameter.KEY, graph.getJobID().toString())
			.replace(':' + CheckpointIdPathParameter.KEY, String.valueOf(checkpoint.getCheckpointId()));
		archive.add(new ArchivedJson(path, json));
	}
	return archive;
}
 
Example 10
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);
	}
}
 
Example 11
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 12
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 CheckpointingStatistics.Summary summary = new CheckpointingStatistics.Summary(
			MinMaxAvgStatistics.valueOf(checkpointStatsSummary.getStateSizeStats()),
			MinMaxAvgStatistics.valueOf(checkpointStatsSummary.getEndToEndDurationStats()),
			new MinMaxAvgStatistics(0, 0, 0));

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