// Path: src/main/java/com/turn/sorcerer/status/Status.java
// public enum Status {
// 
// 	/**
// 	 * Represents a task that is a part of a scheduled pipeline but is not yet
// 	 * eligible for execution, or more specifically the previous tasks in the
// 	 * workflow have not completed or one of
// 	 * {@link com.turn.sorcerer.task.Task#getDependencies(int)} is returning
// 	 * false
// 	 */
// 	PENDING("PENDING"),
// 
// 	/**
// 	 * Represents either:
// 	 *
// 	 * <li>A task that is in-progress, or more specifically
// 	 * {@link com.turn.sorcerer.task.Task#exec} method is running
// 	 * </li>
// 	 *
// 	 * <li>
// 	 * A pipeline whose initial task has been launched but the pipeline is not
// 	 * complete, or more specifically all of its memeber tasks have not
// 	 * completed successfully.
// 	 * </li>
// 	 */
// 	IN_PROGRESS("RUNNING"),
// 
// 	/**
// 	 * Represents either:
// 	 *
// 	 * <li>
// 	 * A successfully completed task, or more specifically
// 	 * {@link com.turn.sorcerer.task.Task#exec} has completed with no
// 	 * exceptions
// 	 * </li>
// 	 *
// 	 * <li>
// 	 * A successfully completed pipeline, or more specifically a pipeline
// 	 * with all member tasks successfully completed.
// 	 * </li>
// 	 */
// 	SUCCESS("SUCCESS"),
// 
// 	/**
// 	 * Represents a task with a previous iteration run that resulted in an
// 	 * error state, or more specifically
// 	 * {@link com.turn.sorcerer.task.Task#exec} was executed with an exception
// 	 * thrown
// 	 */
// 	ERROR("ERROR"),
// 	;
// 
// 	// String representation of status
// 	private String string;
// 
// 	private Status(String string) {
// 		this.string = string;
// 	}
// 
// 	/**
// 	 * Returns string representation of state.
// 	 */
// 	public String getString() {
// 		return string;
// 	}
// }
// 
// Path: src/main/java/com/turn/sorcerer/status/StatusStorage.java
// public interface StatusStorage {
// 
// 	String toString();
// 
// 	void init() throws IOException;
// 
// 	StatusStorage setType(String type);
// 
// 	DateTime getLastUpdateTime(String identifier, int id) throws IOException;
// 
// 	DateTime getStatusUpdateTime(String identifier, int id, Status status) throws IOException;
// 
// 	int getCurrentIterNo(String identifier) throws IOException;
// 
// 	Status checkStatus(String identifier, int id) throws IOException;
// 
// 	void clearAllStatuses(String identifier, int jobId) throws IOException;
// 
// 	void removeStatus(String identifier, int jobId, Status status) throws IOException;
// 
// 	void commitStatus(String identifier, int jobId, Status status, DateTime time, boolean overwrite) throws IOException;
// 
// }


import com.turn.sorcerer.status.Status;
import com.turn.sorcerer.status.StatusStorage;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.inject.BindingAnnotation;
import com.google.inject.Inject;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
		if (fs == null) {
			try {
				fs = FileSystem.get(new Configuration());
			} catch (IOException e) {
				logger.error("Filesystem unreachable!", e);
				throw e;
			}
		}

		long maxTS = 0;

		Path directoryPath = new Path(getStatusPath(identifier, id));

		FileStatus[] fileStatuses;

		try {
			fileStatuses = fs.listStatus(directoryPath);
		} catch (FileNotFoundException fnfe ) {
			return new DateTime(0);
		}


		for (FileStatus fileStatus : fileStatuses) {
			maxTS = Math.max(fileStatus.getModificationTime(), maxTS);
		}

		return new DateTime(maxTS);
	}

	@Override
// Path: src/main/java/com/turn/sorcerer/status/Status.java
// public enum Status {
// 
// 	/**
// 	 * Represents a task that is a part of a scheduled pipeline but is not yet
// 	 * eligible for execution, or more specifically the previous tasks in the
// 	 * workflow have not completed or one of
// 	 * {@link com.turn.sorcerer.task.Task#getDependencies(int)} is returning
// 	 * false
// 	 */
// 	PENDING("PENDING"),
// 
// 	/**
// 	 * Represents either:
// 	 *
// 	 * <li>A task that is in-progress, or more specifically
// 	 * {@link com.turn.sorcerer.task.Task#exec} method is running
// 	 * </li>
// 	 *
// 	 * <li>
// 	 * A pipeline whose initial task has been launched but the pipeline is not
// 	 * complete, or more specifically all of its memeber tasks have not
// 	 * completed successfully.
// 	 * </li>
// 	 */
// 	IN_PROGRESS("RUNNING"),
// 
// 	/**
// 	 * Represents either:
// 	 *
// 	 * <li>
// 	 * A successfully completed task, or more specifically
// 	 * {@link com.turn.sorcerer.task.Task#exec} has completed with no
// 	 * exceptions
// 	 * </li>
// 	 *
// 	 * <li>
// 	 * A successfully completed pipeline, or more specifically a pipeline
// 	 * with all member tasks successfully completed.
// 	 * </li>
// 	 */
// 	SUCCESS("SUCCESS"),
// 
// 	/**
// 	 * Represents a task with a previous iteration run that resulted in an
// 	 * error state, or more specifically
// 	 * {@link com.turn.sorcerer.task.Task#exec} was executed with an exception
// 	 * thrown
// 	 */
// 	ERROR("ERROR"),
// 	;
// 
// 	// String representation of status
// 	private String string;
// 
// 	private Status(String string) {
// 		this.string = string;
// 	}
// 
// 	/**
// 	 * Returns string representation of state.
// 	 */
// 	public String getString() {
// 		return string;
// 	}
// }
// 
// Path: src/main/java/com/turn/sorcerer/status/StatusStorage.java
// public interface StatusStorage {
// 
// 	String toString();
// 
// 	void init() throws IOException;
// 
// 	StatusStorage setType(String type);
// 
// 	DateTime getLastUpdateTime(String identifier, int id) throws IOException;
// 
// 	DateTime getStatusUpdateTime(String identifier, int id, Status status) throws IOException;
// 
// 	int getCurrentIterNo(String identifier) throws IOException;
// 
// 	Status checkStatus(String identifier, int id) throws IOException;
// 
// 	void clearAllStatuses(String identifier, int jobId) throws IOException;
// 
// 	void removeStatus(String identifier, int jobId, Status status) throws IOException;
// 
// 	void commitStatus(String identifier, int jobId, Status status, DateTime time, boolean overwrite) throws IOException;
// 
// }


// Path: src/main/java/com/turn/sorcerer/status/impl/HDFSStatusStorage.java
import com.turn.sorcerer.status.Status;
import com.turn.sorcerer.status.StatusStorage;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.inject.BindingAnnotation;
import com.google.inject.Inject;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

		if (fs == null) {
			try {
				fs = FileSystem.get(new Configuration());
			} catch (IOException e) {
				logger.error("Filesystem unreachable!", e);
				throw e;
			}
		}

		long maxTS = 0;

		Path directoryPath = new Path(getStatusPath(identifier, id));

		FileStatus[] fileStatuses;

		try {
			fileStatuses = fs.listStatus(directoryPath);
		} catch (FileNotFoundException fnfe ) {
			return new DateTime(0);
		}


		for (FileStatus fileStatus : fileStatuses) {
			maxTS = Math.max(fileStatus.getModificationTime(), maxTS);
		}

		return new DateTime(maxTS);
	}

	@Override
	public DateTime getStatusUpdateTime(String identifier, int id, Status status) throws IOException {