Issue #2675 - Change GAFF to be called from Quartz. Added spring file.

Change-Id: I38f2890097e074cc42735657855ffff97a455707

Former-commit-id: c75780f9e3c7b9a5447b0f72b11e42a3c8dce68b
This commit is contained in:
Mike Duff 2014-04-10 15:18:34 -05:00
parent 666b271528
commit 9e0d6b3b1f
4 changed files with 60 additions and 64 deletions

View file

@ -0,0 +1,37 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="gaffService" class="com.raytheon.uf.edex.ohd.pproc.GAFF">
</bean>
<camelContext id="clustered-gaff-context" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler"
autoStartup="false">
<endpoint id="gaffCron" uri="clusteredquartz://hydro/gaffScheduled/?cron=${gaff.cron}"/>
<!-- Run GAFF on a scheduled timer -->
<route id="gaffScheduled">
<from uri="gaffCron" />
<to uri="jms-generic:queue:gaffScheduledWork" />
</route>
<route id="gaffScheduledWork">
<from uri="jms-generic:queue:gaffScheduledWork" />
<doTry>
<bean ref="gaffService" method="process" />
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:GAFF?level=ERROR"/>
</doCatch>
</doTry>
</route>
</camelContext>
<bean factory-bean="clusteredCamelContextMgr"
factory-method="register">
<constructor-arg ref="clustered-gaff-context" />
</bean>
</beans>

View file

@ -10,3 +10,4 @@ arealqpegen.cron=0+10,25,40,55+*+*+*+?
dqcpreprocessor.cron=0+20+0,6,12,18+*+*+? dqcpreprocessor.cron=0+20+0,6,12,18+*+*+?
mpelightningsrv.cron=0+0/30+*+*+*+? mpelightningsrv.cron=0+0/30+*+*+*+?
freezingLevel.cron=0+5+2,8,14,20+*+*+? freezingLevel.cron=0+5+2,8,14,20+*+*+?
gaff.cron=0+0/12+*+*+*+?

View file

@ -51,6 +51,7 @@ import com.raytheon.uf.edex.ohd.MainMethod;
* Mar 20, 2013 1804 bsteffen Switch all radar decompressing to be in * Mar 20, 2013 1804 bsteffen Switch all radar decompressing to be in
* memory. * memory.
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging. * Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* Apr 10, 2014 2675 mpduff Removed call to GAFF.
* *
* </pre> * </pre>
* *
@ -82,12 +83,6 @@ public class DecodeDpaSrv {
return null; return null;
} }
// Run GAFF
GAFF gaff = new GAFF();
if (gaff.shouldGAFFRun()) {
gaff.process();
}
String path = appsDefaults.getToken("pproc_bin"); String path = appsDefaults.getToken("pproc_bin");
int exitValue = MainMethod.runProgram("ksh", path + "/Run_DecodeDPA", int exitValue = MainMethod.runProgram("ksh", path + "/Run_DecodeDPA",
outFile.getAbsolutePath()); outFile.getAbsolutePath());

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; 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.DataAccessLayerException;
import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginDao;
import com.raytheon.uf.edex.database.plugin.PluginFactory; import com.raytheon.uf.edex.database.plugin.PluginFactory;
@ -63,6 +64,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jan 5, 2011 mpduff Initial creation * Jan 5, 2011 mpduff Initial creation
* Sep 5, 2013 16437 wkwock Fix the "HiRes" issue * Sep 5, 2013 16437 wkwock Fix the "HiRes" issue
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging. * Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* Apr 10, 2014 2675 mpduff Modified to be called from quartz timer.
* *
* </pre> * </pre>
* *
@ -135,11 +137,6 @@ public class GAFF {
*/ */
private String hsa = "XXX"; private String hsa = "XXX";
/**
* Time of last run in millis.
*/
private long lastRunTime = 0;
/** /**
* The previous Duration * The previous Duration
*/ */
@ -165,12 +162,6 @@ public class GAFF {
*/ */
private Rectangle wfoExtent = null; private Rectangle wfoExtent = null;
/** Process start time */
private final long start;
/** Process end time */
private long end;
private final GAFFDB db = new GAFFDB(); private final GAFFDB db = new GAFFDB();
/** RFC Site name to RFC lookup map */ /** RFC Site name to RFC lookup map */
@ -210,42 +201,18 @@ public class GAFF {
} }
public 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() { private void init() {
// Only run every 12 minutes
this.lastRunTime = db.getLastRunTime(PROCESS_NAME);
getTokens(); getTokens();
this.hsa = db.getHsa(); 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() { public void process() {
long start = TimeUtil.currentTimeMillis();
log.info("GAFF process starting");
init();
Rectangle extent; Rectangle extent;
HRAP hrap; HRAP hrap;
HRAPSubGrid subGrid; HRAPSubGrid subGrid;
@ -268,12 +235,12 @@ public class GAFF {
/* write record to PerfLog table */ /* write record to PerfLog table */
try { try {
db.insertPerflog(PROCESS_NAME, this.start); db.insertPerflog(PROCESS_NAME, start);
} catch (DataAccessLayerException e) { } catch (DataAccessLayerException e) {
log.error("Error updating perflog table", 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"); 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) { private void createFFGMosaic(int dur, HRAP hrap, HRAPSubGrid subGrid) {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); Calendar cal = TimeUtil.newGmtCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); TimeUtil.minCalendarFields(cal, Calendar.HOUR, Calendar.HOUR_OF_DAY,
cal.set(Calendar.HOUR, 0); Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND);
cal.set(Calendar.HOUR_OF_DAY, 0); ThreadLocal<SimpleDateFormat> sdf = TimeUtil
cal.set(Calendar.MINUTE, 0); .buildThreadLocalSimpleDateFormat("yyyy-MM-dd HH:mm:ss",
cal.set(Calendar.SECOND, 0); TimeZone.getTimeZone("GMT"));
cal.set(Calendar.MILLISECOND, 0); String today = sdf.get().format(cal.getTime());
String today = sdf.format(cal.getTime());
String uri = null; String uri = null;
IDataRecord dataRec; IDataRecord dataRec;
Rectangle rfcExtent = null; Rectangle rfcExtent = null;
@ -378,7 +344,6 @@ public class GAFF {
dataRec = dataStore.retrieve(uri, "Data", Request.ALL); dataRec = dataStore.retrieve(uri, "Data", Request.ALL);
if (dataRec instanceof FloatDataRecord) { if (dataRec instanceof FloatDataRecord) {
// gridList.add(((FloatDataRecord) dataRec).getFloatData());
gridMap.put(rfc, ((FloatDataRecord) dataRec).getFloatData()); gridMap.put(rfc, ((FloatDataRecord) dataRec).getFloatData());
} }
@ -444,7 +409,6 @@ public class GAFF {
wfoExtent.width, this.mosaicFfgShort, minArea, dur, wfoExtent.width, this.mosaicFfgShort, minArea, dur,
grReftime.getTime()); grReftime.getTime());
areaProcessor.processAreas(); areaProcessor.processAreas();
} }
} }
@ -519,21 +483,20 @@ public class GAFF {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder( StringBuilder sb = new StringBuilder(
"***********************************\n"); "***********************************\n");
sb.append("siteId = " + this.siteId); sb.append("siteId = ").append(this.siteId);
sb.append("\nmosaicDir = " + this.mosaicDir); sb.append("\nmosaicDir = ").append(this.mosaicDir);
sb.append("\nlookbackLimit = " + this.lookbackLimit); sb.append("\nlookbackLimit = ").append(this.lookbackLimit);
sb.append("\nminArea = " + this.minArea); sb.append("\nminArea = ").append(this.minArea);
sb.append("\nRFC Names"); sb.append("\nRFC Names");
for (String s : rfcNames) { for (String s : rfcNames) {
sb.append("\n " + s); sb.append("\n ").append(s);
} }
sb.append("\nDurations"); sb.append("\nDurations");
for (int i : this.durations) { for (int i : this.durations) {
sb.append("\n " + i); sb.append("\n ").append(i);
} }
sb.append("\nLast run time = " + this.lastRunTime); sb.append("\nHSA = ").append(this.hsa);
sb.append("\nHSA = " + this.hsa);
return sb.toString(); return sb.toString();
} }