class SubtaskExecutionAttemptDetailsHandler extends AbstractSubtaskAttemptRequestHandler {

	public static String createAttemptDetailsJson(
			AccessExecution execAttempt,
			String jobID,
			String vertexID,
			@Nullable MetricFetcher fetcher) throws IOException {
		StringWriter writer = new StringWriter();
		JsonGenerator gen = JsonFactory.JACKSON_FACTORY.createGenerator(writer);

		final ExecutionState status = execAttempt.getState();
		final long now = System.currentTimeMillis();

		TaskManagerLocation location = execAttempt.getAssignedResourceLocation();
		String locationString = location == null ? "(unassigned)" : location.getHostname();

		long startTime = execAttempt.getStateTimestamp(ExecutionState.DEPLOYING);
		if (startTime == 0) {
			startTime = -1;
		}
		long endTime = status.isTerminal() ? execAttempt.getStateTimestamp(status) : -1;
		long duration = startTime > 0 ? ((endTime > 0 ? endTime : now) - startTime) : -1;

		gen.writeStartObject();
		gen.writeNumberField("subtask", execAttempt.getParallelSubtaskIndex());
		gen.writeStringField("status", status.name());
		gen.writeNumberField("attempt", execAttempt.getAttemptNumber());
		gen.writeStringField("host", locationString);
		gen.writeNumberField("start-time", startTime);
		gen.writeNumberField("end-time", endTime);
		gen.writeNumberField("duration", duration);

		MutableIOMetrics counts = new MutableIOMetrics();

		counts.addIOMetrics(
			execAttempt,
			fetcher,
			jobID,
			vertexID
		);

		counts.writeIOMetricsAsJson(gen);

		gen.writeEndObject();

		gen.close();
		return writer.toString();
	}

	public  SubtaskExecutionAttemptDetailsHandler(ExecutionGraphCache executionGraphHolder, Executor executor, MetricFetcher fetcher);

}