From 3060f80cbe157ec9e4b8d5fec6eaf400ea0ec3d6 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 10 Apr 2014 15:18:34 -0500 Subject: [PATCH] Issue #2675 - Change GAFF to be called from Quartz. Added spring file. Change-Id: I38f2890097e074cc42735657855ffff97a455707 Former-commit-id: 9bee70e2491a4404fad9ffca7712166a088a8d38 [formerly efc9fb3a72a128ff8a9c184815d43323d1c66462] [formerly 069acec611e0b14ccb29c852e7aa1b88aa4040a7] [formerly 9bee70e2491a4404fad9ffca7712166a088a8d38 [formerly efc9fb3a72a128ff8a9c184815d43323d1c66462] [formerly 069acec611e0b14ccb29c852e7aa1b88aa4040a7] [formerly 9e0d6b3b1f6ba12e027acc5fbd1a3558b138472a [formerly 069acec611e0b14ccb29c852e7aa1b88aa4040a7 [formerly c75780f9e3c7b9a5447b0f72b11e42a3c8dce68b]]]] Former-commit-id: 9e0d6b3b1f6ba12e027acc5fbd1a3558b138472a Former-commit-id: 91262c116779847373b40c636c1f6ae600835186 [formerly b0808d2e33040e9e53a53682c1c6c52d1df9a237] [formerly 61ea6c5c176fc46e3893a95c5ce490abcb717fd6 [formerly 3d146a780bdd82136f13f919259bd5bd8c5bf45c]] Former-commit-id: ec9d16ce95e19bf8f3576f44a56d102f6fe82028 [formerly af798af879f9ab5978efc4b0251b887cf8755340] Former-commit-id: 8e40aeec38677cf4f1b6b20c7dbe53ab1dab6f7c --- .../res/spring/gaff-spring.xml | 37 +++++++++ .../com.raytheon.uf.edex.ohd.properties | 1 + .../uf/edex/ohd/pproc/DecodeDpaSrv.java | 7 +- .../com/raytheon/uf/edex/ohd/pproc/GAFF.java | 79 +++++-------------- 4 files changed, 60 insertions(+), 64 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.edex.ohd/res/spring/gaff-spring.xml diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/gaff-spring.xml b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/gaff-spring.xml new file mode 100644 index 0000000000..4cd2665193 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/gaff-spring.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/resources/com.raytheon.uf.edex.ohd.properties b/edexOsgi/com.raytheon.uf.edex.ohd/resources/com.raytheon.uf.edex.ohd.properties index 338b02fdbd..134228a79e 100644 --- a/edexOsgi/com.raytheon.uf.edex.ohd/resources/com.raytheon.uf.edex.ohd.properties +++ b/edexOsgi/com.raytheon.uf.edex.ohd/resources/com.raytheon.uf.edex.ohd.properties @@ -10,3 +10,4 @@ arealqpegen.cron=0+10,25,40,55+*+*+*+? dqcpreprocessor.cron=0+20+0,6,12,18+*+*+? mpelightningsrv.cron=0+0/30+*+*+*+? freezingLevel.cron=0+5+2,8,14,20+*+*+? +gaff.cron=0+0/12+*+*+*+? diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/DecodeDpaSrv.java b/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/DecodeDpaSrv.java index 8814a53a69..1a536360fb 100644 --- a/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/DecodeDpaSrv.java +++ b/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/DecodeDpaSrv.java @@ -51,6 +51,7 @@ import com.raytheon.uf.edex.ohd.MainMethod; * Mar 20, 2013 1804 bsteffen Switch all radar decompressing to be in * memory. * Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging. + * Apr 10, 2014 2675 mpduff Removed call to GAFF. * * * @@ -82,12 +83,6 @@ public class DecodeDpaSrv { return null; } - // Run GAFF - GAFF gaff = new GAFF(); - if (gaff.shouldGAFFRun()) { - gaff.process(); - } - String path = appsDefaults.getToken("pproc_bin"); int exitValue = MainMethod.runProgram("ksh", path + "/Run_DecodeDPA", outFile.getAbsolutePath()); diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/GAFF.java b/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/GAFF.java index 78a8b3fd72..24c61a89e3 100644 --- a/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/GAFF.java +++ b/edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/GAFF.java @@ -46,6 +46,7 @@ import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginFactory; @@ -63,6 +64,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Jan 5, 2011 mpduff Initial creation * Sep 5, 2013 16437 wkwock Fix the "HiRes" issue * Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging. + * Apr 10, 2014 2675 mpduff Modified to be called from quartz timer. * * * @@ -135,11 +137,6 @@ public class GAFF { */ private String hsa = "XXX"; - /** - * Time of last run in millis. - */ - private long lastRunTime = 0; - /** * The previous Duration */ @@ -165,12 +162,6 @@ public class GAFF { */ private Rectangle wfoExtent = null; - /** Process start time */ - private final long start; - - /** Process end time */ - private long end; - private final GAFFDB db = new GAFFDB(); /** RFC Site name to RFC lookup map */ @@ -210,42 +201,18 @@ public class GAFF { } public GAFF() { - start = Calendar.getInstance().getTimeInMillis(); - log.debug("GAFF process is starting"); - - init(); - if (log.isPriorityEnabled(Priority.DEBUG)) { - log.debug(toString()); - } } private void init() { - // Only run every 12 minutes - this.lastRunTime = db.getLastRunTime(PROCESS_NAME); - getTokens(); this.hsa = db.getHsa(); } - public boolean shouldGAFFRun() { - // Only run every 12 minutes - final int minutesBetweenRuns = 12; - - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - if (cal.getTimeInMillis() - this.lastRunTime < minutesBetweenRuns * 60 * 1000) { - if (log.isPriorityEnabled(Priority.DEBUG)) { - float time = (cal.getTimeInMillis() - this.lastRunTime) / 1000 / 60; - log.debug("Only run every 12 minutes. " + time - + " minutes since last run."); - } - return false; - } - - return true; - } - public void process() { + long start = TimeUtil.currentTimeMillis(); + log.info("GAFF process starting"); + init(); Rectangle extent; HRAP hrap; HRAPSubGrid subGrid; @@ -268,12 +235,12 @@ public class GAFF { /* write record to PerfLog table */ try { - db.insertPerflog(PROCESS_NAME, this.start); + db.insertPerflog(PROCESS_NAME, start); } catch (DataAccessLayerException e) { log.error("Error updating perflog table", e); } - end = Calendar.getInstance().getTimeInMillis(); + long end = TimeUtil.currentTimeMillis(); log.info("GAFF Process complete in " + (end - start) + " millis"); } @@ -289,14 +256,13 @@ public class GAFF { */ private void createFFGMosaic(int dur, HRAP hrap, HRAPSubGrid subGrid) { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - cal.set(Calendar.HOUR, 0); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - String today = sdf.format(cal.getTime()); + Calendar cal = TimeUtil.newGmtCalendar(); + TimeUtil.minCalendarFields(cal, Calendar.HOUR, Calendar.HOUR_OF_DAY, + Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND); + ThreadLocal sdf = TimeUtil + .buildThreadLocalSimpleDateFormat("yyyy-MM-dd HH:mm:ss", + TimeZone.getTimeZone("GMT")); + String today = sdf.get().format(cal.getTime()); String uri = null; IDataRecord dataRec; Rectangle rfcExtent = null; @@ -378,7 +344,6 @@ public class GAFF { dataRec = dataStore.retrieve(uri, "Data", Request.ALL); if (dataRec instanceof FloatDataRecord) { - // gridList.add(((FloatDataRecord) dataRec).getFloatData()); gridMap.put(rfc, ((FloatDataRecord) dataRec).getFloatData()); } @@ -444,7 +409,6 @@ public class GAFF { wfoExtent.width, this.mosaicFfgShort, minArea, dur, grReftime.getTime()); areaProcessor.processAreas(); - } } @@ -519,21 +483,20 @@ public class GAFF { public String toString() { StringBuilder sb = new StringBuilder( "***********************************\n"); - sb.append("siteId = " + this.siteId); - sb.append("\nmosaicDir = " + this.mosaicDir); - sb.append("\nlookbackLimit = " + this.lookbackLimit); - sb.append("\nminArea = " + this.minArea); + sb.append("siteId = ").append(this.siteId); + sb.append("\nmosaicDir = ").append(this.mosaicDir); + sb.append("\nlookbackLimit = ").append(this.lookbackLimit); + sb.append("\nminArea = ").append(this.minArea); sb.append("\nRFC Names"); for (String s : rfcNames) { - sb.append("\n " + s); + sb.append("\n ").append(s); } sb.append("\nDurations"); for (int i : this.durations) { - sb.append("\n " + i); + sb.append("\n ").append(i); } - sb.append("\nLast run time = " + this.lastRunTime); - sb.append("\nHSA = " + this.hsa); + sb.append("\nHSA = ").append(this.hsa); return sb.toString(); }