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+*+*+?
mpelightningsrv.cron=0+0/30+*+*+*+?
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
* memory.
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* Apr 10, 2014 2675 mpduff Removed call to GAFF.
*
* </pre>
*
@ -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());

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.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.
*
* </pre>
*
@ -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<SimpleDateFormat> 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();
}