From 6514d7193fa31086f593937af0dfca7c572a22d1 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Mon, 16 Jun 2014 22:40:32 +0100 Subject: [PATCH] Add some code --- .../stat/collector/ExecutionStatUpdater.java | 38 ++++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/webservices/compbio/stat/collector/ExecutionStatUpdater.java b/webservices/compbio/stat/collector/ExecutionStatUpdater.java index f853539..f26ecc3 100644 --- a/webservices/compbio/stat/collector/ExecutionStatUpdater.java +++ b/webservices/compbio/stat/collector/ExecutionStatUpdater.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.sql.SQLException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -67,20 +68,24 @@ class mainJCommander { private List parameters = new ArrayList(); @Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity") - Integer verbose = 1; + public Integer verbose = 1; @Parameter(names = "-start", description = "Start time") - String starttime; + public String starttime; @Parameter(names = "-end", description = "Start time") - String endtime; + public String endtime; @Parameter(names = "-db", description = "Path to database") - String dbname; + public String dbname; + + @Parameter(names = "-dir", description = "Path to job directory") + public String workingdir; } public class ExecutionStatUpdater { static SimpleDateFormat DF = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); + static SimpleDateFormat shortDF = new SimpleDateFormat("dd/MM/yyyy"); private static final Logger log = Logger.getLogger(ExecutionStatUpdater.class); final private File workingDirectory; @@ -145,19 +150,30 @@ public class ExecutionStatUpdater { /** * main function + * @throws ParseException */ - public static void main(String[] args) throws IOException, SQLException { + public static void main(String[] args) throws IOException, SQLException, ParseException { mainJCommander jct = new mainJCommander(); new JCommander(jct, args); - String WorkingDir = "jobout"; - String StartTime = jct.starttime; - String EndTime = jct.endtime; + String WorkingDir = jct.workingdir; String dbname = jct.dbname; - long StartTimeLong = 0; - long EndTimeLong = 0; + Date ST = shortDF.parse(jct.starttime); + Date ET = shortDF.parse(jct.endtime); + long StartTime = 0; + if (null != ST) { + StartTime = ST.getTime(); + } + Date currDate = new Date(); + long EndTime = currDate.getTime(); + if (null != ET) { + EndTime = ET.getTime(); + } + + System.out.println("Start time: " + jct.starttime + " = " + StartTime); + System.out.println("End time: " + jct.endtime + " = " + EndTime); ExecutionStatUpdater esu = new ExecutionStatUpdater(WorkingDir, 1); - esu.collectStatistics(StartTimeLong, EndTimeLong); + esu.collectStatistics(StartTime, EndTime); esu.writeStatToDB(); } -- 1.7.10.2