import java.io.FileFilter;\r
import java.io.IOException;\r
import java.sql.SQLException;\r
+import java.text.ParseException;\r
import java.text.SimpleDateFormat;\r
import java.util.ArrayList;\r
import java.util.Date;\r
private List<String> parameters = new ArrayList<String>();\r
\r
@Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")\r
- Integer verbose = 1;\r
+ public Integer verbose = 1;\r
\r
@Parameter(names = "-start", description = "Start time")\r
- String starttime;\r
+ public String starttime;\r
\r
@Parameter(names = "-end", description = "Start time")\r
- String endtime;\r
+ public String endtime;\r
\r
@Parameter(names = "-db", description = "Path to database")\r
- String dbname;\r
+ public String dbname;\r
+\r
+ @Parameter(names = "-dir", description = "Path to job directory")\r
+ public String workingdir;\r
}\r
\r
public class ExecutionStatUpdater {\r
static SimpleDateFormat DF = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");\r
+ static SimpleDateFormat shortDF = new SimpleDateFormat("dd/MM/yyyy");\r
private static final Logger log = Logger.getLogger(ExecutionStatUpdater.class);\r
\r
final private File workingDirectory;\r
return new StatProcessor(stats);\r
}\r
\r
- void writeStatToDB() throws SQLException {\r
+ void writeStatToDB(String dbname) throws SQLException {\r
Set<JobStat> rjobs = new HashSet<JobStat>(stats);\r
- StatDB statdb = new StatDB();\r
+ StatDB statdb = new StatDB(dbname);\r
log.debug("Removing records that has already been recorded");\r
statdb.removeRecordedJobs(rjobs);\r
log.debug("New records left: " + rjobs.size());\r
\r
/**\r
* main function\r
+ * @throws ParseException \r
*/\r
- public static void main(String[] args) throws IOException, SQLException {\r
+ public static void main(String[] args) throws IOException, SQLException, ParseException {\r
mainJCommander jct = new mainJCommander();\r
new JCommander(jct, args);\r
- String WorkingDir = "jobout";\r
- String StartTime = jct.starttime;\r
- String EndTime = jct.endtime;\r
- String dbname = jct.dbname;\r
- long StartTimeLong = 0;\r
- long EndTimeLong = 0;\r
+ String WorkingDir = "jobsout";\r
+ String DBname = "ExecutionStatistic";\r
+\r
+ long StartTime = 0L;\r
+ Date currDate = new Date();\r
+ long EndTime = currDate.getTime();\r
+ if (null != jct.starttime) {\r
+ Date ST = shortDF.parse(jct.starttime);\r
+ if (null != ST) {\r
+ StartTime = ST.getTime();\r
+ }\r
+ }\r
+ if (null != jct.endtime) {\r
+ Date ET = shortDF.parse(jct.endtime);\r
+ if (null != ET) {\r
+ EndTime = ET.getTime();\r
+ }\r
+ }\r
+ if (null != jct.dbname) {\r
+ DBname = jct.dbname;\r
+ }\r
+ if (null != jct.workingdir) {\r
+ WorkingDir = jct.workingdir;\r
+ }\r
+\r
+ System.out.println("Start time: " + jct.starttime + " = " + StartTime);\r
+ System.out.println("End time: " + jct.endtime + " = " + EndTime);\r
\r
ExecutionStatUpdater esu = new ExecutionStatUpdater(WorkingDir, 1);\r
- esu.collectStatistics(StartTimeLong, EndTimeLong);\r
- esu.writeStatToDB();\r
+ esu.collectStatistics(StartTime, EndTime);\r
+ esu.writeStatToDB(DBname);\r
}\r
\r
static FileFilter directories = new FileFilter() {\r
// clear stats array;\r
stats.clear();\r
File[] dirs = workingDirectory.listFiles(directories);\r
+ log.debug("Start time = " + StartTime + ", end time = " + EndTime);\r
for (File dir : dirs) {\r
// skip work directory with test inputs and out of ordered time\r
// range\r
log.debug("check directory: " + dir.getName() + "...");\r
if (InputFilter.accept(new File(dir.getPath() + File.separator + SkeletalExecutable.INPUT)) && StartTime < dir.lastModified()\r
&& dir.lastModified() < EndTime) {\r
+ log.debug(", ACCEPTED");\r
JobDirectory jd = new JobDirectory(dir);\r
JobStat jstat = jd.getJobStat();\r
// Do not record stats on the job that has not completed yet\r
log.debug("Skipping the job: " + jstat + " as it has not completed yet");\r
}\r
} else {\r
+ log.debug(", REJECTED");\r
log.trace("training input: " + dir.getName() + File.separator + SkeletalExecutable.INPUT);\r
}\r
}\r
+ log.debug("Statistics collected!");\r
}\r
\r
}\r