CheckpointStatsHistory createSnapshot() {
		if (readOnly) {
			throw new UnsupportedOperationException("Can't create a snapshot of a read-only history.");
		}

		List<AbstractCheckpointStats> checkpointsHistory;
		Map<Long, AbstractCheckpointStats> checkpointsById;

		checkpointsById = new HashMap<>(checkpointsArray.length);

		if (maxSize == 0) {
			checkpointsHistory = Collections.emptyList();
		} else {
			AbstractCheckpointStats[] newCheckpointsArray = new AbstractCheckpointStats[checkpointsArray.length];

			System.arraycopy(checkpointsArray, nextPos, newCheckpointsArray, 0, checkpointsArray.length - nextPos);
			System.arraycopy(checkpointsArray, 0, newCheckpointsArray, checkpointsArray.length - nextPos, nextPos);

			checkpointsHistory = Arrays.asList(newCheckpointsArray);

			// reverse the order such that we start with the youngest checkpoint
			Collections.reverse(checkpointsHistory);

			for (AbstractCheckpointStats checkpoint : checkpointsHistory) {
				checkpointsById.put(checkpoint.getCheckpointId(), checkpoint);
			}
		}

		if (latestCompletedCheckpoint != null) {
			checkpointsById.put(latestCompletedCheckpoint.getCheckpointId(), latestCompletedCheckpoint);
		}

		if (latestFailedCheckpoint != null) {
			checkpointsById.put(latestFailedCheckpoint.getCheckpointId(), latestFailedCheckpoint);
		}

		if (latestSavepoint != null) {
			checkpointsById.put(latestSavepoint.getCheckpointId(), latestSavepoint);
		}

		return new CheckpointStatsHistory(
			true,
			maxSize,
			null,
			checkpointsHistory,
			checkpointsById,
			latestCompletedCheckpoint,
			latestFailedCheckpoint,
			latestSavepoint);
	}
CheckpointStatsHistory createSnapshot ( ) { if ( readOnly ) { throw new UnsupportedOperationException ( "Can't create a snapshot of a read-only history." ) ; } List < AbstractCheckpointStats > checkpointsHistory ; Map < Long , AbstractCheckpointStats > checkpointsById ; checkpointsById = new HashMap < > ( checkpointsArray . length ) ; if ( maxSize == 0 ) { checkpointsHistory = Collections . emptyList ( ) ; } else { AbstractCheckpointStats [ ] newCheckpointsArray = new AbstractCheckpointStats [ checkpointsArray . length ] ; System . arraycopy ( checkpointsArray , nextPos , newCheckpointsArray , 0 , checkpointsArray . length - nextPos ) ; System . arraycopy ( checkpointsArray , 0 , newCheckpointsArray , checkpointsArray . length - nextPos , nextPos ) ; checkpointsHistory = Arrays . asList ( newCheckpointsArray ) ; Collections . reverse ( checkpointsHistory ) ; for ( AbstractCheckpointStats checkpoint : checkpointsHistory ) { checkpointsById . put ( checkpoint . getCheckpointId ( ) , checkpoint ) ; } } if ( latestCompletedCheckpoint != null ) { checkpointsById . put ( latestCompletedCheckpoint . getCheckpointId ( ) , latestCompletedCheckpoint ) ; } if ( latestFailedCheckpoint != null ) { checkpointsById . put ( latestFailedCheckpoint . getCheckpointId ( ) , latestFailedCheckpoint ) ; } if ( latestSavepoint != null ) { checkpointsById . put ( latestSavepoint . getCheckpointId ( ) , latestSavepoint ) ; } return new CheckpointStatsHistory ( true , maxSize , null , checkpointsHistory , checkpointsById , latestCompletedCheckpoint , latestFailedCheckpoint , latestSavepoint ) ; }
Creates a snapshot of the current state.

@return Snapshot of the current state.