class ArchivedExecutionGraph implements AccessExecutionGraph, Serializable {

	public static ArchivedExecutionGraph createFrom(ExecutionGraph executionGraph) {
		final int numberVertices = executionGraph.getTotalNumberOfVertices();

		Map<JobVertexID, ArchivedExecutionJobVertex> archivedTasks = new HashMap<>(numberVertices);
		List<ArchivedExecutionJobVertex> archivedVerticesInCreationOrder = new ArrayList<>(numberVertices);

		for (ExecutionJobVertex task : executionGraph.getVerticesTopologically()) {
			ArchivedExecutionJobVertex archivedTask = task.archive();
			archivedVerticesInCreationOrder.add(archivedTask);
			archivedTasks.put(task.getJobVertexId(), archivedTask);
		}

		final Map<String, SerializedValue<OptionalFailure<Object>>> serializedUserAccumulators =
			executionGraph.getAccumulatorsSerialized();

		final long[] timestamps = new long[JobStatus.values().length];

		for (JobStatus jobStatus : JobStatus.values()) {
			final int ordinal = jobStatus.ordinal();
			timestamps[ordinal] = executionGraph.getStatusTimestamp(jobStatus);
		}

		return new ArchivedExecutionGraph(
			executionGraph.getJobID(),
			executionGraph.getJobName(),
			archivedTasks,
			archivedVerticesInCreationOrder,
			timestamps,
			executionGraph.getState(),
			executionGraph.getFailureInfo(),
			executionGraph.getJsonPlan(),
			executionGraph.getAccumulatorResultsStringified(),
			serializedUserAccumulators,
			executionGraph.getArchivedExecutionConfig(),
			executionGraph.isStoppable(),
			executionGraph.getCheckpointCoordinatorConfiguration(),
			executionGraph.getCheckpointStatsSnapshot());
	}

	public  ArchivedExecutionGraph(
			JobID jobID,
			String jobName,
			Map<JobVertexID, ArchivedExecutionJobVertex> tasks,
			List<ArchivedExecutionJobVertex> verticesInCreationOrder,
			long[] stateTimestamps,
			JobStatus state,
			@Nullable ErrorInfo failureCause,
			String jsonPlan,
			StringifiedAccumulatorResult[] archivedUserAccumulators,
			Map<String, SerializedValue<OptionalFailure<Object>>> serializedUserAccumulators,
			ArchivedExecutionConfig executionConfig,
			boolean isStoppable,
			@Nullable CheckpointCoordinatorConfiguration jobCheckpointingConfiguration,
			@Nullable CheckpointStatsSnapshot checkpointStatsSnapshot);

}