- static class JobDirectory {\r
-\r
- File jobdir;\r
- Map<String, File> files = new HashMap<String, File>();\r
-\r
- public JobDirectory(File directory) {\r
- this.jobdir = directory;\r
- for (File f : jobdir.listFiles()) {\r
- files.put(f.getName(), f);\r
- }\r
- }\r
-\r
- public boolean hasStatus(JobStatus status) {\r
- return files.containsKey(status.toString());\r
- }\r
-\r
- boolean isCollected() {\r
- return hasStatus(JobStatus.COLLECTED);\r
- }\r
-\r
- boolean isCancelled() {\r
- return hasStatus(JobStatus.CANCELLED);\r
- }\r
-\r
- long getStartTime() {\r
- long starttime = UNDEFINED;\r
- File startfile = files.get(JobStatus.STARTED.toString());\r
- if (startfile == null) {\r
- startfile = files.get(JobStatus.SUBMITTED.toString());\r
- }\r
- if (startfile != null) {\r
- starttime = startfile.lastModified();\r
- /*\r
- * String start = FileUtil.readFileToString(startfile);\r
- * starttime = Long.parseLong(start.trim());\r
- */\r
- }\r
- return starttime;\r
- }\r
-\r
- String getClusterJobID() {\r
- String clustjobId = "";\r
- File jobid = files.get("JOBID");\r
- try {\r
- if (jobid != null) {\r
- clustjobId = FileUtil.readFileToString(jobid);\r
- }\r
- } catch (IOException ioe) {\r
- ioe.printStackTrace();\r
- // TODO LOG\r
- }\r
- return clustjobId.trim();\r
- }\r
-\r
- long getFinishedTime() {\r
- long ftime = UNDEFINED;\r
- File finished = files.get(JobStatus.FINISHED.toString());\r
- if (finished != null) {\r
- ftime = finished.lastModified();\r
- /*\r
- * String start = FileUtil.readFileToString(finished); ftime =\r
- * Long.parseLong(start.trim());\r
- */\r
- // System.out.println("f " + ftime);\r
- }\r
- /*\r
- * } catch (IOException e) { log.log(Level.WARN,\r
- * "Cannot parse finished time: " + e.getMessage(), e); } catch\r
- * (NumberFormatException e) { log.log(Level.WARN,\r
- * "Cannot parse finished time: " + e.getMessage(), e); }\r
- */\r
- return ftime;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- Class<Executable<?>> getWSRunnerName() {\r
- String name = jobdir.getName().split("#")[0];\r
- try {\r
- if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) {\r
- assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1;\r
- name = name.substring(1);\r
+ // TODO test!\r
+ void collectStatistics() {\r
+ // clear stats array;\r
+ stats.clear();\r
+ File[] dirs = workingDirectory.listFiles(directories);\r
+ for (File dir : dirs) {\r
+ // skip work directory with test inputas \r
+ log.debug("check directory: " + dir.getName() + "...");\r
+ if (InputFilter.accept(new File(dir.getPath() + File.separator + SkeletalExecutable.INPUT))) {\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
+ if (hasCompleted(jd)) {\r
+ stats.add(jstat);\r
+ } else {\r
+ log.debug("Skipping the job: " + jstat + " as it has not completed yet");\r