New code update
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Tue, 17 Jun 2014 06:57:43 +0000 (07:57 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Tue, 17 Jun 2014 06:57:43 +0000 (07:57 +0100)
build.xml
log/log4j.properties.updater [new file with mode: 0644]
webservices/compbio/stat/collector/ExecutionStatUpdater.java

index 6c7b389..fe7b271 100644 (file)
--- a/build.xml
+++ b/build.xml
                <!-- Engines -->
                <include name="compbio/engine/**"/>
                <!-- Runners -->
+               <include name="compbio/runner/**"/>
+               <!-- Runners -->
                <include name="compbio/stat/collector/**"/>
+               <include name="compbio/ws/client/**"/>
                <!-- Logging configuration -->
        </fileset>
 
        <target name="stat-updater" depends="compile" description="Prepare executable jar for stat updater">
                <echo>Jar file: StatUpdater jar</echo>
                <delete file="${basedir}/${stat-updater}"></delete>
+               <copy file="${basedir}/log/log4j.properties.updater" tofile="${basedir}/log4j.properties"/>
                <jar jarfile="${basedir}/${stat-updater}">
+                       <fileset dir="${basedir}">
+                               <include name="log4j.properties"/>
+                       </fileset>
                        <fileset refid="statupdater"/>
                        <zipgroupfileset excludes="META-INF/*" dir="" includes="WEB-INF/lib/log4j-1.2.15.jar" />
                        <zipgroupfileset excludes="META-INF/*" dir="" includes="lib/jcommander-1.30.jar" />
                        <zipgroupfileset excludes="META-INF/*.SF" dir="${web.lib.path}" >
                                <include name="${compbio-util}"/>
-                       </zipgroupfileset>
-                       <manifest>
+                       </zipgroupfileset>                      <manifest>
                                <attribute name="Built-By" value="${author}" />
                                <attribute name="Main-Class" value="compbio.stat.collector.ExecutionStatUpdater" />
                                <attribute name="Class-Path" value="." />
                                <attribute name="Implementation-URL" value="${project.url}" />
                        </manifest>
                </jar>
+               <delete file="${basedir}/log4j.properties"/>
        </target>
        
        <target name="full-jabaws-client-jar" depends="compile" description="Pack datamodel, engine and runners">
diff --git a/log/log4j.properties.updater b/log/log4j.properties.updater
new file mode 100644 (file)
index 0000000..e6f4a06
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+## CHANGE THIS (The root directory where to store all the log files)  \r
+#logDir = .\r
+\r
+## Uncomment to enable JWS2 activity logging to standard out (to the console if available)\r
+## for possible log levels please refer to Log4j documentation http://logging.apache.org/log4j/1.2/manual.html \r
+## Valid log levels are:\r
+## TRACE - log everything from below including very detailed messages (useful for debugging only)\r
+## DEBUG - log everything from below including some minor events (useful for debugging only)\r
+## INFO - log everything from below including some information messages\r
+## WARN - log error and warnings\r
+## ERROR - log errors and fatal events only \r
+## FATAL - log fatal events only\r
+\r
+##################################################################################################################################\r
+log4j.rootLogger=DEBUG\r
+log4j.appender.R=org.apache.log4j.FileAppender\r
+log4j.appender.R.File=StatDBupdater.log\r
+log4j.appender.R.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.R.layout.ConversionPattern=%m%n %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - \r
index f26ecc3..a5d89d1 100644 (file)
@@ -139,9 +139,9 @@ public class ExecutionStatUpdater {
                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
@@ -155,18 +155,29 @@ public class ExecutionStatUpdater {
        public static void main(String[] args) throws IOException, SQLException, ParseException {\r
                mainJCommander jct = new mainJCommander();\r
                new JCommander(jct, args);\r
-               String WorkingDir = jct.workingdir;\r
-               String dbname = jct.dbname;\r
-               Date ST = shortDF.parse(jct.starttime);\r
-               Date ET = shortDF.parse(jct.endtime);\r
-               long StartTime = 0;\r
-               if (null != ST) {\r
-                       StartTime = ST.getTime();\r
-               }\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 != ET) {\r
-                       EndTime = ET.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
@@ -174,7 +185,7 @@ public class ExecutionStatUpdater {
 \r
                ExecutionStatUpdater esu = new ExecutionStatUpdater(WorkingDir, 1);\r
                esu.collectStatistics(StartTime, EndTime);\r
-               esu.writeStatToDB();\r
+               esu.writeStatToDB(DBname);\r
        }\r
 \r
        static FileFilter directories = new FileFilter() {\r
@@ -189,12 +200,14 @@ public class ExecutionStatUpdater {
                // 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
@@ -204,9 +217,11 @@ public class ExecutionStatUpdater {
                                        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