// 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;
	}

	public void stageOut() {
		try (BufferedReader logReader = new BufferedReader(new FileReader(new File(Invocation.REPORT_FILENAME)))) {
			String line;
			while ((line = logReader.readLine()) != null) {
				JsonReportEntry entry = new JsonReportEntry(line);
				if (entry.getKey().equals(JsonReportEntry.KEY_FILE_SIZE_STAGEOUT)) {
					outputFiles.add(new Data(entry.getFile(), containerId));
				}
			}
		} catch (IOException | JSONException e) {
			e.printStackTrace(System.out);
		}
		for (Data output : outputFiles) {
			long tic = System.currentTimeMillis();
			try {
				output.stageOut();
			} catch (IOException e) {
				e.printStackTrace(System.out);
			}
			long toc = System.currentTimeMillis();
			JSONObject obj = new JSONObject();
			try {
				obj.put(JsonReportEntry.LABEL_REALTIME, Long.toString(toc - tic));
			} catch (JSONException e) {
				e.printStackTrace(System.out);
			}
			try {
				writeEntryToLog(new JsonReportEntry(tic, workflowId, taskId, taskName, langLabel, id, output.getLocalPath().toString(),
// 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;

	}

	public void stageOut() {
		try (BufferedReader logReader = new BufferedReader(new FileReader(new File(Invocation.REPORT_FILENAME)))) {
			String line;
			while ((line = logReader.readLine()) != null) {
				JsonReportEntry entry = new JsonReportEntry(line);
				if (entry.getKey().equals(JsonReportEntry.KEY_FILE_SIZE_STAGEOUT)) {
					outputFiles.add(new Data(entry.getFile(), containerId));
				}
			}
		} catch (IOException | JSONException e) {
			e.printStackTrace(System.out);
		}
		for (Data output : outputFiles) {
			long tic = System.currentTimeMillis();
			try {
				output.stageOut();
			} catch (IOException e) {
				e.printStackTrace(System.out);
			}
			long toc = System.currentTimeMillis();
			JSONObject obj = new JSONObject();
			try {
				obj.put(JsonReportEntry.LABEL_REALTIME, Long.toString(toc - tic));
			} catch (JSONException e) {
				e.printStackTrace(System.out);
			}
			try {
				writeEntryToLog(new JsonReportEntry(tic, workflowId, taskId, taskName, langLabel, id, output.getLocalPath().toString(),
						HiwayDBI.KEY_FILE_TIME_STAGEOUT, obj));