public static Path archiveJob(Path rootPath, JobID jobId, Collection<ArchivedJson> jsonToArchive) throws IOException {
		try {
			FileSystem fs = rootPath.getFileSystem();
			Path path = new Path(rootPath, jobId.toString());
			OutputStream out = fs.create(path, FileSystem.WriteMode.NO_OVERWRITE);

			try (JsonGenerator gen = jacksonFactory.createGenerator(out, JsonEncoding.UTF8)) {
				gen.writeStartObject();
				gen.writeArrayFieldStart(ARCHIVE);
				for (ArchivedJson archive : jsonToArchive) {
					gen.writeStartObject();
					gen.writeStringField(PATH, archive.getPath());
					gen.writeStringField(JSON, archive.getJson());
					gen.writeEndObject();
				}
				gen.writeEndArray();
				gen.writeEndObject();
			} catch (Exception e) {
				fs.delete(path, false);
				throw e;
			}
			LOG.info("Job {} has been archived at {}.", jobId, path);
			return path;
		} catch (IOException e) {
			LOG.error("Failed to archive job.", e);
			throw e;
		}
	}
public static Path archiveJob ( Path rootPath , JobID jobId , Collection < ArchivedJson > jsonToArchive ) throws IOException { try { FileSystem fs = rootPath . getFileSystem ( ) ; Path path = new Path ( rootPath , jobId . toString ( ) ) ; OutputStream out = fs . create ( path , FileSystem . WriteMode . NO_OVERWRITE ) ; try ( JsonGenerator gen = jacksonFactory . createGenerator ( out , JsonEncoding . UTF8 ) ) { gen . writeStartObject ( ) ; gen . writeArrayFieldStart ( ARCHIVE ) ; for ( ArchivedJson archive : jsonToArchive ) { gen . writeStartObject ( ) ; gen . writeStringField ( PATH , archive . getPath ( ) ) ; gen . writeStringField ( JSON , archive . getJson ( ) ) ; gen . writeEndObject ( ) ; } gen . writeEndArray ( ) ; gen . writeEndObject ( ) ; } catch ( Exception e ) { fs . delete ( path , false ) ; throw e ; } LOG . info ( "Job {} has been archived at {}." , jobId , path ) ; return path ; } catch ( IOException e ) { LOG . error ( "Failed to archive job." , e ) ; throw e ; } }
Writes the given {@link AccessExecutionGraph} to the {@link FileSystem} pointed to by
{@link JobManagerOptions#ARCHIVE_DIR}.

@param rootPath directory to which the archive should be written to
@param jobId  job id
@param jsonToArchive collection of json-path pairs to that should be archived
@return path to where the archive was written, or null if no archive was created
@throws IOException