// Path: hiway-db/src/main/java/de/huberlin/hiwaydb/useDB/HiwayDBI.java
// public interface HiwayDBI {
// 
// 	public static final String KEY_FILE_TIME_STAGEIN = "file-time-stagein";
// 	public static final String KEY_FILE_TIME_STAGEOUT = "file-time-stageout";
// 	public static final String KEY_HIWAY_EVENT = "hiway-event";
// 	public static final String KEY_INVOC_HOST = "invoc-host";
// 	public static final String KEY_INVOC_TIME_SCHED = "invoc-time-sched";
// 	public static final String KEY_INVOC_TIME_STAGEIN = "invoc-time-stagein";
// 	public static final String KEY_INVOC_TIME_STAGEOUT = "invoc-time-stageout";
// 	public static final String KEY_WF_NAME = "wf-name";
// 	public static final String KEY_WF_TIME = "wf-time";
// 	public static final String KEY_WF_OUTPUT = "wf-output";
// 
// 	public Set<String> getHostNames();
// 
// 	public Set<Long> getTaskIdsForWorkflow(String workflowName);
// 
// 	public String getTaskName(long taskId);
// 
// 	public Collection<InvocStat> getLogEntriesForTasks(Set<Long> taskIds);
// 
// 	public Collection<InvocStat> getLogEntriesForTaskOnHostSince(long taskId, String hostName, long timestamp);
// 
// 	public void logToDB(JsonReportEntry entry);
// 
// }


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.json.JSONException;
import org.json.JSONObject;
import de.huberlin.hiwaydb.useDB.HiwayDBI;
import de.huberlin.wbi.cuneiform.core.invoc.Invocation;
import de.huberlin.wbi.cuneiform.core.semanticmodel.JsonReportEntry;
				writeEntryToLog(new JsonReportEntry(workflowId, taskId, taskName, langLabel, id, JsonReportEntry.KEY_INVOC_SCRIPT, sb.toString()));
			} catch (IOException e) {
				e.printStackTrace(System.out);
			}
		}

		// obj = new JSONObject();
		// obj.put(JsonReportEntry.LABEL_REALTIME, Long.toString(toc - tic));
		// writeEntryToLog(new JsonReportEntry(tic, workflowId, taskId, taskName, langLabel, id, null, JsonReportEntry.KEY_INVOC_TIME, obj));

		tic = System.currentTimeMillis();
		try {
			new Data(id + "_" + Invocation.STDOUT_FILENAME, containerId).stageOut();
		} catch (IOException e) {
			e.printStackTrace(System.out);
		}
		try {
			new Data(id + "_" + Invocation.STDERR_FILENAME, containerId).stageOut();
		} catch (IOException e) {
			e.printStackTrace(System.out);
		}

		stageOut();
		toc = System.currentTimeMillis();
		obj = new JSONObject();
		try {
			obj.put(JsonReportEntry.LABEL_REALTIME, Long.toString(toc - tic));
		} catch (JSONException e) {
			e.printStackTrace(System.out);
		}
// Path: hiway-db/src/main/java/de/huberlin/hiwaydb/useDB/HiwayDBI.java
// public interface HiwayDBI {
// 
// 	public static final String KEY_FILE_TIME_STAGEIN = "file-time-stagein";
// 	public static final String KEY_FILE_TIME_STAGEOUT = "file-time-stageout";
// 	public static final String KEY_HIWAY_EVENT = "hiway-event";
// 	public static final String KEY_INVOC_HOST = "invoc-host";
// 	public static final String KEY_INVOC_TIME_SCHED = "invoc-time-sched";
// 	public static final String KEY_INVOC_TIME_STAGEIN = "invoc-time-stagein";
// 	public static final String KEY_INVOC_TIME_STAGEOUT = "invoc-time-stageout";
// 	public static final String KEY_WF_NAME = "wf-name";
// 	public static final String KEY_WF_TIME = "wf-time";
// 	public static final String KEY_WF_OUTPUT = "wf-output";
// 
// 	public Set<String> getHostNames();
// 
// 	public Set<Long> getTaskIdsForWorkflow(String workflowName);
// 
// 	public String getTaskName(long taskId);
// 
// 	public Collection<InvocStat> getLogEntriesForTasks(Set<Long> taskIds);
// 
// 	public Collection<InvocStat> getLogEntriesForTaskOnHostSince(long taskId, String hostName, long timestamp);
// 
// 	public void logToDB(JsonReportEntry entry);
// 
// }


// Path: hiway-core/src/main/java/de/huberlin/wbi/hiway/common/Worker.java
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.json.JSONException;
import org.json.JSONObject;
import de.huberlin.hiwaydb.useDB.HiwayDBI;
import de.huberlin.wbi.cuneiform.core.invoc.Invocation;
import de.huberlin.wbi.cuneiform.core.semanticmodel.JsonReportEntry;

				writeEntryToLog(new JsonReportEntry(workflowId, taskId, taskName, langLabel, id, JsonReportEntry.KEY_INVOC_SCRIPT, sb.toString()));
			} catch (IOException e) {
				e.printStackTrace(System.out);
			}
		}

		// obj = new JSONObject();
		// obj.put(JsonReportEntry.LABEL_REALTIME, Long.toString(toc - tic));
		// writeEntryToLog(new JsonReportEntry(tic, workflowId, taskId, taskName, langLabel, id, null, JsonReportEntry.KEY_INVOC_TIME, obj));

		tic = System.currentTimeMillis();
		try {
			new Data(id + "_" + Invocation.STDOUT_FILENAME, containerId).stageOut();
		} catch (IOException e) {
			e.printStackTrace(System.out);
		}
		try {
			new Data(id + "_" + Invocation.STDERR_FILENAME, containerId).stageOut();
		} catch (IOException e) {
			e.printStackTrace(System.out);
		}

		stageOut();
		toc = System.currentTimeMillis();
		obj = new JSONObject();
		try {
			obj.put(JsonReportEntry.LABEL_REALTIME, Long.toString(toc - tic));
		} catch (JSONException e) {
			e.printStackTrace(System.out);
		}
		try {