Merge "Issue #2952 - Change MPE fieldgen to use thriftSrv" into development

Former-commit-id: 8efaad8250215b687ae9286358cdd30148cdc366
This commit is contained in:
Nate Jensen 2014-04-02 09:54:53 -05:00 committed by Gerrit Code Review
commit 0b25f77fe8
18 changed files with 337 additions and 232 deletions

View file

@ -20,23 +20,18 @@
package com.raytheon.viz.mpe.core; package com.raytheon.viz.mpe.core;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.mpe.fieldgen.MpeFieldGenRequest;
import com.raytheon.uf.common.comm.HttpClient; import com.raytheon.uf.common.mpe.fieldgen.MpeFieldGenResponse;
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
import com.raytheon.uf.common.serialization.SerializationException;
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.viz.core.VizApp; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.mpe.Activator; import com.raytheon.viz.mpe.Activator;
/** /**
@ -48,21 +43,18 @@ import com.raytheon.viz.mpe.Activator;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 1/08/09 1674 bphillip Initial creation * 1/08/09 1674 bphillip Initial creation
* 08/09/12 15307 snaples Updated job to use postStreamingByteArray. * 08/09/12 15307 snaples Updated job to use postStreamingByteArray.
* 03/28/14 2952 mpduff Changed to use ThriftSrv.
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
* @version 1.0 * @version 1.0
*/ */
public class MpeFieldGenJob extends Job { public class MpeFieldGenJob extends Job {
private final IUFStatusHandler log = UFStatus
private static final IUFStatusHandler handler = UFStatus.getHandler( .getHandler(MpeFieldGenJob.class);
MpeFieldGenJob.class, "DEFAULT");
/** The HTTP endpoint of the field gen service */
private static final String ENDPOINT_NAME = "/mpeFieldGenHttpService";
/** The argument to run the MPE Field Gen with */ /** The argument to run the MPE Field Gen with */
private String fieldGenArg; private final String fieldGenArg;
/** /**
* Constructs a new MpeFieldGenJob * Constructs a new MpeFieldGenJob
@ -79,50 +71,23 @@ public class MpeFieldGenJob extends Job {
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
final Integer[] mpeExitValue = new Integer[1]; final Integer[] mpeExitValue = new Integer[1];
String httpAddress = VizApp.getHttpServer() + ENDPOINT_NAME; MpeFieldGenRequest req = new MpeFieldGenRequest();
String args = fieldGenArg; req.setArgs(fieldGenArg);
byte[] ba = args.getBytes();
MpeFieldGenResponse response;
try { try {
HttpClient.getInstance().postStreamingByteArray(httpAddress, ba, response = (MpeFieldGenResponse) ThriftClient.sendRequest(req);
new HttpClient.IStreamHandler() { int exitValue = response.getExitValue();
/* if (exitValue != 0) {
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.comm.Connector.IStreamHandler
* #handleStream(java.io.InputStream)
*/
@Override
public void handleStream(InputStream is)
throws CommunicationException {
try {
DynamicSerializationManager dsm = DynamicSerializationManager
.getManager(SerializationType.Thrift);
mpeExitValue[0] = (Integer) dsm.deserialize(is);
System.out.println("MPE FieldGen returned: "
+ mpeExitValue[0]);
} catch (SerializationException e) {
throw new CommunicationException(
"Error deserializing", e);
}
}
});
} catch (CommunicationException e) {
return new Status(Status.ERROR, Activator.PLUGIN_ID, return new Status(Status.ERROR, Activator.PLUGIN_ID,
"MPE Field Gen execution failed with exit code: " "MPE Field Gen execution failed with exit code: "
+ mpeExitValue[0]); + mpeExitValue[0]);
} }
} catch (VizException e) {
log.handle(Priority.ERROR, "Error executing MPE FieldGen", e);
}
if (mpeExitValue[0] != null && mpeExitValue[0] == 0) {
return Status.OK_STATUS; return Status.OK_STATUS;
} }
return new Status(Status.ERROR, Activator.PLUGIN_ID,
"MPE Field Gen execution failed with exit code: "
+ mpeExitValue[0]);
}
} }

View file

@ -2,14 +2,16 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Mpe Plug-in Bundle-Name: Mpe Plug-in
Bundle-SymbolicName: com.raytheon.uf.common.mpe Bundle-SymbolicName: com.raytheon.uf.common.mpe
Bundle-Version: 1.12.1174.qualifier Bundle-Version: 1.14.0.qualifier
Bundle-Vendor: RAYTHEON Bundle-Vendor: RAYTHEON
Require-Bundle: com.raytheon.edex.common, Require-Bundle: com.raytheon.edex.common,
org.geotools, org.geotools,
org.apache.commons.lang, org.apache.commons.lang,
javax.persistence;bundle-version="1.0.0", javax.persistence;bundle-version="1.0.0",
javax.measure;bundle-version="1.0.0" javax.measure;bundle-version="1.0.0",
com.raytheon.uf.common.serialization.comm
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.common.mpe.constants, Export-Package: com.raytheon.uf.common.mpe.constants,
com.raytheon.uf.common.mpe.fieldgen,
com.raytheon.uf.common.mpe.util com.raytheon.uf.common.mpe.util

View file

@ -0,0 +1,62 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.mpe.fieldgen;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
* Request object used to kick off MPE FieldGen with the provided arguments.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2014 2952 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class MpeFieldGenRequest implements IServerRequest {
@DynamicSerializeElement
private String args;
/**
* @return the args
*/
public String getArgs() {
return args;
}
/**
* @param args
* the args to set
*/
public void setArgs(String args) {
this.args = args;
}
}

View file

@ -0,0 +1,61 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.mpe.fieldgen;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Response object providing the exit status code of MPE FieldGen.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2014 2952 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class MpeFieldGenResponse {
/** Field gen exit value */
@DynamicSerializeElement
private int exitValue;
/**
* @return the exitValue
*/
public int getExitValue() {
return exitValue;
}
/**
* @param exitValue
* the exitValue to set
*/
public void setExitValue(int exitValue) {
this.exitValue = exitValue;
}
}

View file

@ -17,7 +17,6 @@ Import-Package: com.raytheon.edex.util,
com.raytheon.uf.edex.database, com.raytheon.uf.edex.database,
com.raytheon.uf.edex.database.dao, com.raytheon.uf.edex.database.dao,
com.raytheon.uf.edex.database.plugin, com.raytheon.uf.edex.database.plugin,
org.apache.commons.logging,
org.quartz org.quartz
Export-Package: com.raytheon.uf.edex.ohd, Export-Package: com.raytheon.uf.edex.ohd,
com.raytheon.uf.edex.ohd.reportalarm, com.raytheon.uf.edex.ohd.reportalarm,

View file

@ -16,25 +16,9 @@
<constructor-arg ref="mpeProcessGribHandler"/> <constructor-arg ref="mpeProcessGribHandler"/>
</bean> </bean>
<camelContext id="mpeFieldGenReq-context" <bean factory-bean="handlerRegistry" factory-method="register">
xmlns="http://camel.apache.org/schema/spring" <constructor-arg value="com.raytheon.uf.common.mpe.fieldgen.MpeFieldGenRequest"/>
errorHandlerRef="errorHandler"> <constructor-arg ref="mpeFieldGenService"/>
</bean>
<endpoint id="mpeHttp_from"
uri="jetty:http://0.0.0.0:${HTTP_PORT}/services/mpeFieldGenHttpService?disableStreamCache=true" />
<route id="mpeHttp">
<from uri="ref:mpeHttp_from" />
<doTry>
<bean ref="mpeFieldGenService" method="process" />
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:mpeFieldGen?level=ERROR"/>
</doCatch>
</doTry>
<bean ref="serializationUtil" method="transformToThrift" />
</route>
</camelContext>
</beans> </beans>

View file

@ -27,10 +27,9 @@ import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.edex.core.props.PropertiesFactory; import com.raytheon.uf.edex.core.props.PropertiesFactory;
/** /**
@ -51,6 +50,7 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 28, 2008 jelkins Initial creation * Oct 28, 2008 jelkins Initial creation
* Oct 19, 2012 #1274 bgonzale Set AppContext on the process builder in ctor. * Oct 19, 2012 #1274 bgonzale Set AppContext on the process builder in ctor.
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* </pre> * </pre>
* *
* @author jelkins * @author jelkins
@ -59,9 +59,10 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory;
public class MainMethod extends Process { public class MainMethod extends Process {
protected Log log; private static final IUFStatusHandler log = UFStatus
.getHandler(MainMethod.class);
private ProcessBuilder processBuilder; private final ProcessBuilder processBuilder;
private Process process; private Process process;
@ -112,7 +113,6 @@ public class MainMethod extends Process {
public MainMethod(ProcessBuilder builder) { public MainMethod(ProcessBuilder builder) {
this.processBuilder = builder; this.processBuilder = builder;
this.log = LogFactory.getLog(processBuilder.getClass());
try { try {
processBuilder.environment().put( processBuilder.environment().put(
@ -156,7 +156,7 @@ public class MainMethod extends Process {
error.append(processBuilder.command().get(i)).append(" "); error.append(processBuilder.command().get(i)).append(" ");
} }
error.append("failed with exit code " + exitValue); error.append("failed with exit code " + exitValue);
log.error(error); log.error(error.toString());
} }
return exitValue; return exitValue;

View file

@ -22,10 +22,10 @@ package com.raytheon.uf.edex.ohd;
import java.io.File; import java.io.File;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.CronExpression; import org.quartz.CronExpression;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
/** /**
@ -40,6 +40,7 @@ import com.raytheon.uf.edex.core.EdexException;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 19, 2008 jelkins Initial creation * Dec 19, 2008 jelkins Initial creation
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* *
* </pre> * </pre>
* *
@ -48,6 +49,8 @@ import com.raytheon.uf.edex.core.EdexException;
*/ */
public class ScriptService implements ServiceInterface { public class ScriptService implements ServiceInterface {
private static final IUFStatusHandler logger = UFStatus
.getHandler(ScriptService.class);
/** A Cron expression representation of the cron line in the legacy system */ /** A Cron expression representation of the cron line in the legacy system */
private CronExpression cronExpression; private CronExpression cronExpression;
@ -58,10 +61,8 @@ public class ScriptService implements ServiceInterface {
/** Additional environment variables to set before running the script */ /** Additional environment variables to set before running the script */
private Map<String, String> environmentVariables; private Map<String, String> environmentVariables;
private Log logger = LogFactory.getLog(getClass());
/** The last portion of the scriptLocation */ /** The last portion of the scriptLocation */
private String scriptName; private final String scriptName;
/** /**
* Execute the script service. * Execute the script service.
@ -73,10 +74,11 @@ public class ScriptService implements ServiceInterface {
* wrong. * wrong.
* @throws EdexException * @throws EdexException
*/ */
@Override
public void execute() throws EdexException { public void execute() throws EdexException {
MainMethod m = new MainMethod(new ProcessBuilder(script MainMethod m = new MainMethod(new ProcessBuilder(
.getAbsolutePath())); script.getAbsolutePath()));
if (environmentVariables != null) { if (environmentVariables != null) {
m.getProcessBuilder().environment().putAll(environmentVariables); m.getProcessBuilder().environment().putAll(environmentVariables);

View file

@ -24,30 +24,38 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.util.FileUtil; import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
/** /**
* Performs setup operations for OHD services * Performs setup operations for OHD services
* *
* @author jelkins * <pre>
* *
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
*
* </pre>
*
* @author jelkins
* @version 1.0
*/ */
public class SetupSrv implements ServiceInterface { public class SetupSrv implements ServiceInterface {
private static final IUFStatusHandler logger = UFStatus
.getHandler(SetupSrv.class);
/** set to true when setup service has succeeded */ /** set to true when setup service has succeeded */
private static boolean isSetup = false; private static boolean isSetup = false;
Log logger = LogFactory.getLog(SetupSrv.class);
AppsDefaults appsDefaults = AppsDefaults.getInstance(); AppsDefaults appsDefaults = AppsDefaults.getInstance();
public SetupSrv() { public SetupSrv() {

View file

@ -32,8 +32,6 @@ import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.opengis.metadata.spatial.PixelOrientation; import org.opengis.metadata.spatial.PixelOrientation;
import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.PluginException;
@ -50,6 +48,9 @@ import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
import com.raytheon.uf.common.mpe.util.XmrgFile; import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.mpe.util.XmrgFile.XmrgHeader; import com.raytheon.uf.common.mpe.util.XmrgFile.XmrgHeader;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.util.FileUtil; import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao; import com.raytheon.uf.edex.database.dao.CoreDao;
@ -71,6 +72,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 26, 2011 snaples Initial creation * Jan 26, 2011 snaples Initial creation
* Jan 10, 2013 1448 bgonzale Added app context check in processArealQpe(). * Jan 10, 2013 1448 bgonzale Added app context check in processArealQpe().
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* *
* </pre> * </pre>
* *
@ -79,6 +81,8 @@ import com.vividsolutions.jts.geom.Coordinate;
*/ */
public class ArealQpeGenSrv { public class ArealQpeGenSrv {
private static final IUFStatusHandler log = UFStatus
.getHandler(ArealQpeGenSrv.class);
/** /**
* <pre> * <pre>
@ -146,8 +150,6 @@ public class ArealQpeGenSrv {
private HRAPSubGrid subGrid; private HRAPSubGrid subGrid;
private Log log = LogFactory.getLog("GenArealQPE");
private Rectangle wfoExtent; private Rectangle wfoExtent;
/** /**
@ -183,13 +185,13 @@ public class ArealQpeGenSrv {
private static final String GRIBIT = "gribit.LX"; private static final String GRIBIT = "gribit.LX";
private Map<String, Rectangle> extentsMap = new HashMap<String, Rectangle>(); private final Map<String, Rectangle> extentsMap = new HashMap<String, Rectangle>();
private Map<String, float[]> gridMap = new HashMap<String, float[]>(); private final Map<String, float[]> gridMap = new HashMap<String, float[]>();
private int dur; private int dur;
private AppsDefaults appsDefaults = AppsDefaults.getInstance(); private final AppsDefaults appsDefaults = AppsDefaults.getInstance();
private String gaq_xmrg_1hr_dir; private String gaq_xmrg_1hr_dir;
@ -205,9 +207,10 @@ public class ArealQpeGenSrv {
private boolean qpe_out; private boolean qpe_out;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private final SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
private SimpleDateFormat fdf = new SimpleDateFormat("yyyyMMddHH"); private final SimpleDateFormat fdf = new SimpleDateFormat("yyyyMMddHH");
public Object processArealQpe() { public Object processArealQpe() {
if (!AppsDefaults.getInstance().setAppContext(this)) { if (!AppsDefaults.getInstance().setAppContext(this)) {
@ -232,7 +235,7 @@ public class ArealQpeGenSrv {
/* loop on QPE durations */ /* loop on QPE durations */
for (int dd : durs) { for (int dd : durs) {
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug("Processing for " + dd + " hr duration"); log.debug("Processing for " + dd + " hr duration");
} }
processSingleQpe(dd, hrap, subGrid); processSingleQpe(dd, hrap, subGrid);
@ -377,13 +380,12 @@ public class ArealQpeGenSrv {
} catch (IOException e) { } catch (IOException e) {
log.error("Copy grib file " + mvFile.getName() log.error("Copy grib file " + mvFile.getName()
+ " to " + d2d_input_dir + File.separator + " to " + d2d_input_dir + File.separator
+ "arealQpeGenSrv" + " failed. "); + "arealQpeGenSrv" + " failed. ", e);
e.printStackTrace();
} }
} }
// Remove the xmrg file from the temp directory. // Remove the xmrg file from the temp directory.
fr.delete(); fr.delete();
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug("Removed file " + fr log.debug("Removed file " + fr
+ " from rfcqpe_temp directory."); + " from rfcqpe_temp directory.");
} }
@ -465,7 +467,6 @@ public class ArealQpeGenSrv {
xmhead = null; xmhead = null;
} catch (IOException e) { } catch (IOException e) {
log.error("Error writing RFC QPE file", e); log.error("Error writing RFC QPE file", e);
e.printStackTrace();
xmhead = null; xmhead = null;
return; return;
} }
@ -492,7 +493,6 @@ public class ArealQpeGenSrv {
xmhead = null; xmhead = null;
} catch (IOException e) { } catch (IOException e) {
log.error("Error writing Temp QPE file", e); log.error("Error writing Temp QPE file", e);
e.printStackTrace();
xmhead = null; xmhead = null;
return; return;
} }
@ -517,7 +517,6 @@ public class ArealQpeGenSrv {
wfoExtent = HRAPCoordinates.getHRAPCoordinates(); wfoExtent = HRAPCoordinates.getHRAPCoordinates();
} catch (Exception e2) { } catch (Exception e2) {
log.error("Error setting up the wfo extent", e2); log.error("Error setting up the wfo extent", e2);
e2.printStackTrace();
return; return;
} }
@ -544,7 +543,7 @@ public class ArealQpeGenSrv {
processGrids(); processGrids();
writeXmrg(dd, mosaicQpeShort); writeXmrg(dd, mosaicQpeShort);
} else { } else {
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug("Getting data for duration " + durString log.debug("Getting data for duration " + durString
+ " returned no data."); + " returned no data.");
} }
@ -584,7 +583,6 @@ public class ArealQpeGenSrv {
subGrid = hrap.getHRAPSubGrid(extent); subGrid = hrap.getHRAPSubGrid(extent);
} catch (Exception e) { } catch (Exception e) {
log.error("Error setting up HRAP subgrid", e); log.error("Error setting up HRAP subgrid", e);
e.printStackTrace();
return; return;
} }
} }
@ -698,11 +696,9 @@ public class ArealQpeGenSrv {
} catch (PluginException e1) { } catch (PluginException e1) {
log.error("Error querying grids", e1); log.error("Error querying grids", e1);
e1.printStackTrace();
return false; return false;
} catch (Exception e) { } catch (Exception e) {
log.error("Error creating rfc qpe grid", e); log.error("Error creating rfc qpe grid", e);
e.printStackTrace();
return false; return false;
} }
return true; return true;
@ -748,10 +744,7 @@ public class ArealQpeGenSrv {
y--; y--;
} }
} catch (Exception e) { } catch (Exception e) {
if (log.isDebugEnabled()) { log.error("Error in populating getData::mosaicQpeShort.", e);
log.debug("Error in populating getData::mosaicQpeShort.");
}
e.printStackTrace();
} }
} }
return; return;

View file

@ -30,11 +30,10 @@ import java.util.Scanner;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers; import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.util.FileUtil; import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.database.dao.CoreDao; import com.raytheon.uf.edex.database.dao.CoreDao;
@ -51,6 +50,7 @@ import com.raytheon.uf.edex.ohd.MainMethod;
* Nov 14, 2008 bphillip Initial creation * Nov 14, 2008 bphillip Initial creation
* 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.
* *
* </pre> * </pre>
* *
@ -65,9 +65,10 @@ public class DecodeDpaSrv {
private static final Pattern dpaPat = Pattern.compile("DPA..."); private static final Pattern dpaPat = Pattern.compile("DPA...");
private Log logger = LogFactory.getLog(getClass()); private static final IUFStatusHandler logger = UFStatus
.getHandler(DecodeDpaSrv.class);
private AppsDefaults appsDefaults = AppsDefaults.getInstance(); private final AppsDefaults appsDefaults = AppsDefaults.getInstance();
private File outFile; private File outFile;

View file

@ -20,10 +20,9 @@
package com.raytheon.uf.edex.ohd.pproc; package com.raytheon.uf.edex.ohd.pproc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.ohd.MainMethod; import com.raytheon.uf.edex.ohd.MainMethod;
@ -35,6 +34,7 @@ import com.raytheon.uf.edex.ohd.MainMethod;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 25 2008 snaples Initial creation * Mar 25 2008 snaples Initial creation
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* </pre> * </pre>
* *
* @author snaples * @author snaples
@ -42,15 +42,16 @@ import com.raytheon.uf.edex.ohd.MainMethod;
*/ */
public class DqcPreProcSrv { public class DqcPreProcSrv {
private static final IUFStatusHandler logger = UFStatus
.getHandler(DqcPreProcSrv.class);
/** The argument pattern if only hours are specified */ /** The argument pattern if only hours are specified */
private static final String DAYS_ARG = "\\d{1,2}"; private static final String DAYS_ARG = "\\d{1,2}";
/** The default number of days to process if no argument if provided */ /** The default number of days to process if no argument if provided */
private static final String defaultNumDays = "10"; private static final String defaultNumDays = "10";
private AppsDefaults appsDefaults = AppsDefaults.getInstance(); private final AppsDefaults appsDefaults = AppsDefaults.getInstance();
private Log logger = LogFactory.getLog(getClass());
public Object process(String dqcArg) throws EdexException { public Object process(String dqcArg) throws EdexException {

View file

@ -28,8 +28,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.opengis.metadata.spatial.PixelOrientation; import org.opengis.metadata.spatial.PixelOrientation;
import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.PluginException;
@ -45,6 +43,9 @@ import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
import com.raytheon.uf.common.mpe.util.XmrgFile; import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.mpe.util.XmrgFile.XmrgHeader; import com.raytheon.uf.common.mpe.util.XmrgFile.XmrgHeader;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.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;
@ -61,6 +62,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.
* *
* </pre> * </pre>
* *
@ -69,6 +71,8 @@ import com.vividsolutions.jts.geom.Coordinate;
*/ */
public class GAFF { public class GAFF {
private static final IUFStatusHandler log = UFStatus.getHandler(GAFF.class);
private static final int MISSING_VALUE = -99; private static final int MISSING_VALUE = -99;
private static final String PROC_FLAG = "MPA01 "; private static final String PROC_FLAG = "MPA01 ";
@ -162,14 +166,12 @@ public class GAFF {
private Rectangle wfoExtent = null; private Rectangle wfoExtent = null;
/** Process start time */ /** Process start time */
private long start; private final long start;
/** Process end time */ /** Process end time */
private long end; private long end;
private Log log = LogFactory.getLog("GenArealFFG"); private final GAFFDB db = new GAFFDB();
private GAFFDB db = new GAFFDB();
/** RFC Site name to RFC lookup map */ /** RFC Site name to RFC lookup map */
public static Map<String, String> RFCMAP = new HashMap<String, String>(); public static Map<String, String> RFCMAP = new HashMap<String, String>();
@ -209,12 +211,10 @@ public class GAFF {
public GAFF() { public GAFF() {
start = Calendar.getInstance().getTimeInMillis(); start = Calendar.getInstance().getTimeInMillis();
if (log.isDebugEnabled()) {
log.debug("GAFF process is starting"); log.debug("GAFF process is starting");
}
init(); init();
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug(toString()); log.debug(toString());
} }
} }
@ -234,7 +234,7 @@ public class GAFF {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
if (cal.getTimeInMillis() - this.lastRunTime < minutesBetweenRuns * 60 * 1000) { if (cal.getTimeInMillis() - this.lastRunTime < minutesBetweenRuns * 60 * 1000) {
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
float time = (cal.getTimeInMillis() - this.lastRunTime) / 1000 / 60; float time = (cal.getTimeInMillis() - this.lastRunTime) / 1000 / 60;
log.debug("Only run every 12 minutes. " + time log.debug("Only run every 12 minutes. " + time
+ " minutes since last run."); + " minutes since last run.");
@ -255,13 +255,12 @@ public class GAFF {
subGrid = hrap.getHRAPSubGrid(extent); subGrid = hrap.getHRAPSubGrid(extent);
} catch (Exception e) { } catch (Exception e) {
log.error("Error setting up HRAP subgrid", e); log.error("Error setting up HRAP subgrid", e);
e.printStackTrace();
return; return;
} }
/* loop on FFG durations */ /* loop on FFG durations */
for (int dur : this.durations) { for (int dur : this.durations) {
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug("Processing for " + dur + " duration"); log.debug("Processing for " + dur + " duration");
} }
createFFGMosaic(dur, hrap, subGrid); createFFGMosaic(dur, hrap, subGrid);
@ -306,7 +305,6 @@ public class GAFF {
wfoExtent = HRAPCoordinates.getHRAPCoordinates(); wfoExtent = HRAPCoordinates.getHRAPCoordinates();
} catch (Exception e2) { } catch (Exception e2) {
log.error("Error setting up the wfo extent", e2); log.error("Error setting up the wfo extent", e2);
e2.printStackTrace();
} }
// Initialize arrays for each calculation // Initialize arrays for each calculation
@ -331,7 +329,7 @@ public class GAFF {
Map<String, float[]> gridMap = new HashMap<String, float[]>(); Map<String, float[]> gridMap = new HashMap<String, float[]>();
for (String rfc : this.rfcNames) { for (String rfc : this.rfcNames) {
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug("Getting data for " + rfc + " for " + durString log.debug("Getting data for " + rfc + " for " + durString
+ " duration"); + " duration");
} }
@ -345,7 +343,7 @@ public class GAFF {
try { try {
uri = db.getDataURI(rfc, durString, today); uri = db.getDataURI(rfc, durString, today);
if (uri == null) { if (uri == null) {
uri = db.getDataURI(rfc+"-HiRes", durString, today); uri = db.getDataURI(rfc + "-HiRes", durString, today);
} }
if (uri == null) { if (uri == null) {
continue; continue;
@ -386,10 +384,8 @@ public class GAFF {
} catch (PluginException e1) { } catch (PluginException e1) {
log.error("Error querying grids", e1); log.error("Error querying grids", e1);
e1.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
log.error("Error creating wfo ffg grid", e); log.error("Error creating wfo ffg grid", e);
e.printStackTrace();
} }
} }
@ -432,7 +428,7 @@ public class GAFF {
y--; y--;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("Caught exception.", e);
} }
writeXmrgFile(); writeXmrgFile();
@ -479,13 +475,10 @@ public class GAFF {
xmrg.setData(this.mosaicFfgShort); xmrg.setData(this.mosaicFfgShort);
try { try {
if (log.isDebugEnabled()) {
log.debug("Writing xmrg file: " + name); log.debug("Writing xmrg file: " + name);
}
xmrg.save(name); xmrg.save(name);
} catch (IOException e) { } catch (IOException e) {
log.error("Error writing xmrg file", e); log.error("Error writing xmrg file", e);
e.printStackTrace();
} }
} }

View file

@ -19,9 +19,9 @@
**/ **/
package com.raytheon.uf.edex.ohd.pproc; package com.raytheon.uf.edex.ohd.pproc;
import org.apache.commons.logging.Log; import com.raytheon.uf.common.status.IUFStatusHandler;
import org.apache.commons.logging.LogFactory; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.DataAccessLayerException;
/** /**
@ -33,7 +33,8 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 8, 2011 mpduff Initial creation * Jan 08, 2011 mpduff Initial creation
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* *
* </pre> * </pre>
* *
@ -44,7 +45,8 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
public class GAFFAreaProcessor { public class GAFFAreaProcessor {
private static final float MISSING_VALUE_FLOAT = -99.0f; private static final float MISSING_VALUE_FLOAT = -99.0f;
private Log log = LogFactory.getLog("GenArealFFG"); private static final IUFStatusHandler log = UFStatus
.getHandler(GAFFAreaProcessor.class);
private int xor; private int xor;
@ -68,7 +70,7 @@ public class GAFFAreaProcessor {
private double avgVal = 0; private double avgVal = 0;
private GAFFDB db = new GAFFDB(); private final GAFFDB db = new GAFFDB();
/** /**
* Default Constructor. * Default Constructor.
@ -106,7 +108,7 @@ public class GAFFAreaProcessor {
* information from the blob fields. * information from the blob fields.
*/ */
Object[] lineSegsRs = db.getLineSegs(areaId); Object[] lineSegsRs = db.getLineSegs(areaId);
log.debug(lineSegsRs.length + " rows in the lineSegsRs"); log.debug(lineSegsRs.length + " rows in the lineSegsRs");
int numRows = lineSegsRs.length; int numRows = lineSegsRs.length;
rows = new int[numRows]; rows = new int[numRows];
begCol = new int[numRows]; begCol = new int[numRows];
@ -134,8 +136,10 @@ log.debug(lineSegsRs.length + " rows in the lineSegsRs");
try { try {
computeAvgFfg(areaId, lineSegsRs.length, rows, begCol, computeAvgFfg(areaId, lineSegsRs.length, rows, begCol,
endCol); endCol);
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); log.error(
"Error computing average FFG value for basin and areal coverage",
e);
} }
/* /*
* if average FFG value for basin successfully computed AND * if average FFG value for basin successfully computed AND
@ -154,9 +158,8 @@ log.debug(lineSegsRs.length + " rows in the lineSegsRs");
log.error( log.error(
"Error inserting data into ContingencyValue table", "Error inserting data into ContingencyValue table",
e); e);
e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("Error writing contingency data", e);
} }
} else { } else {
log.info("AreaId = " + areaId log.info("AreaId = " + areaId
@ -171,8 +174,6 @@ log.debug(lineSegsRs.length + " rows in the lineSegsRs");
} else { } else {
log.info("No basins found in GeoArea table"); log.info("No basins found in GeoArea table");
} }
System.out.println("leaving processAreas()");
} }
/* /*
@ -241,7 +242,7 @@ log.debug(lineSegsRs.length + " rows in the lineSegsRs");
* compute the avg ffg value as the average of all the bins within the * compute the avg ffg value as the average of all the bins within the
* area that have valid area_id data. * area that have valid area_id data.
*/ */
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug(areaId + " bincnts: total: " + totalCnt + "(= valid " log.debug(areaId + " bincnts: total: " + totalCnt + "(= valid "
+ valCnt + " + msg " + missCnt + ")"); + valCnt + " + msg " + missCnt + ")");
} }
@ -260,7 +261,7 @@ log.debug(lineSegsRs.length + " rows in the lineSegsRs");
min = 0; min = 0;
} }
if (log.isDebugEnabled()) { if (log.isPriorityEnabled(Priority.DEBUG)) {
log.debug(areaId + ": Sum/Cnt=unadjstd avg => " + sum + "/" log.debug(areaId + ": Sum/Cnt=unadjstd avg => " + sum + "/"
+ valCnt + " = " + avgVal + "; max,min=" + max + "," + min); + valCnt + " = " + avgVal + "; max,min=" + max + "," + min);
} }

View file

@ -26,11 +26,10 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.dataplugin.grid.GridConstants; import com.raytheon.uf.common.dataplugin.grid.GridConstants;
import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao; import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig; import com.raytheon.uf.edex.database.dao.DaoConfig;
@ -46,6 +45,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 11, 2011 mpduff Initial creation * Jan 11, 2011 mpduff Initial creation
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* *
* </pre> * </pre>
* *
@ -64,7 +64,8 @@ public class GAFFDB {
private static final String LINESEGS_QUERY = "select hrap_row, hrap_beg_col, " private static final String LINESEGS_QUERY = "select hrap_row, hrap_beg_col, "
+ "hrap_end_col, area from linesegs"; + "hrap_end_col, area from linesegs";
private Log log = LogFactory.getLog("GenArealFFG"); private static final IUFStatusHandler log = UFStatus
.getHandler(GAFFDB.class);
/** /**
* Default constructor. * Default constructor.
@ -131,9 +132,8 @@ public class GAFFDB {
} else { } else {
throw new Exception("Error getting Last Run Time"); throw new Exception("Error getting Last Run Time");
} }
if (log.isDebugEnabled()) {
log.debug("Last run time: " + ts.toString()); log.debug("Last run time: " + ts.toString());
}
return ts.getTime(); return ts.getTime();
} }
} catch (Exception e) { } catch (Exception e) {
@ -146,9 +146,7 @@ public class GAFFDB {
c.set(Calendar.SECOND, 0); c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0); c.set(Calendar.MILLISECOND, 0);
if (log.isDebugEnabled()) {
log.debug("Last run time set to 00Z"); log.debug("Last run time set to 00Z");
}
return c.getTimeInMillis(); return c.getTimeInMillis();
} }
@ -261,9 +259,7 @@ public class GAFFDB {
+ DEFAULT_QC_VALUE + ", " + "0, 'GRIDFFG', '" + validDate + DEFAULT_QC_VALUE + ", " + "0, 'GRIDFFG', '" + validDate
+ "', '" + postDate + "')"; + "', '" + postDate + "')";
if (log.isDebugEnabled()) {
log.debug(sql); log.debug(sql);
}
dao.executeNativeSql(sql, false); dao.executeNativeSql(sql, false);
} else { } else {
@ -306,11 +302,9 @@ public class GAFFDB {
if ((rs != null) && (rs.length > 0)) { if ((rs != null) && (rs.length > 0)) {
if ((rs[0] != null) && (rs[0] instanceof String)) { if ((rs[0] != null) && (rs[0] instanceof String)) {
hsa = (String) rs[0]; hsa = (String) rs[0];
if (log.isDebugEnabled()) {
log.debug("HSA: " + hsa); log.debug("HSA: " + hsa);
} }
} }
}
return hsa; return hsa;
} }

View file

@ -23,10 +23,12 @@ package com.raytheon.uf.edex.ohd.pproc;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import com.raytheon.uf.common.mpe.fieldgen.MpeFieldGenRequest;
import org.apache.commons.logging.LogFactory; import com.raytheon.uf.common.mpe.fieldgen.MpeFieldGenResponse;
import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.ohd.MainMethod; import com.raytheon.uf.edex.ohd.MainMethod;
@ -38,12 +40,16 @@ import com.raytheon.uf.edex.ohd.MainMethod;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 14, 2008 bphillip Initial creation * Nov 14, 2008 bphillip Initial creation
* Mar 28, 2014 2952 mpduff Changed to use ThriftSrv and UFStatus, cleanup
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
* @version 1.0 * @version 1.0
*/ */
public class MpeFieldGenSrv { public class MpeFieldGenSrv implements IRequestHandler<MpeFieldGenRequest> {
private static final IUFStatusHandler logger = UFStatus
.getHandler(MpeFieldGenSrv.class);
/** The argument pattern if only hours are specified */ /** The argument pattern if only hours are specified */
private static final String HOURS_ARG = "\\d{1,2}"; private static final String HOURS_ARG = "\\d{1,2}";
@ -54,36 +60,60 @@ public class MpeFieldGenSrv {
private static final Pattern HOURS_DATE_PATTERN = Pattern private static final Pattern HOURS_DATE_PATTERN = Pattern
.compile(HOURS_DATE_ARG); .compile(HOURS_DATE_ARG);
private static final Pattern HOURS_ARG_PATTERN = Pattern.compile(HOURS_ARG);
/** The default number of hours to process if no argument if provided */ /** The default number of hours to process if no argument if provided */
private static final String defaultMpeArg = "3"; private static final String DEFAULT_ARG = "3";
private AppsDefaults appsDefaults = AppsDefaults.getInstance(); private static final AppsDefaults appsDefaults = AppsDefaults.getInstance();
private Log logger = LogFactory.getLog(getClass()); private static final String EXECUTE_PATH = appsDefaults
.getToken("pproc_bin") + "/run_mpe_fieldgen";
public Object process(String mpeArg) throws EdexException { /**
* {@inheritDoc}
*/
@Override
public Object handleRequest(MpeFieldGenRequest request) throws Exception {
MpeFieldGenResponse response = new MpeFieldGenResponse();
int exitValue = process(request.getArgs());
response.setExitValue(exitValue);
if (!mpeArg.matches(HOURS_ARG) && !mpeArg.matches(HOURS_DATE_ARG)) { return response;
throw new EdexException("Invalid argument sent to mpe_fieldgen"); }
/**
* Execute mpe fieldgen.
*
* @param mpeArg
* Program arguments
* @return exit status
* @throws EdexException
*/
private int process(String mpeArg) throws EdexException {
if (!HOURS_ARG_PATTERN.matcher(mpeArg).matches()
&& !HOURS_DATE_PATTERN.matcher(mpeArg).matches()) {
throw new EdexException("Invalid argument sent to mpe_fieldgen: "
+ mpeArg);
} }
int exitValue = 0; int exitValue = 0;
if (appsDefaults.setAppContext(this)) {
if (mpeArg.matches(HOURS_ARG)) {
logger.info("Executing MPE FieldGen with argument: " + mpeArg); logger.info("Executing MPE FieldGen with argument: " + mpeArg);
exitValue = MainMethod.runProgram("ksh",
appsDefaults.getToken("pproc_bin") if (appsDefaults.setAppContext(this)) {
+ "/run_mpe_fieldgen", mpeArg); if (HOURS_ARG_PATTERN.matcher(mpeArg).matches()) {
exitValue = MainMethod.runProgram("ksh", EXECUTE_PATH, mpeArg);
} else if (mpeArg.matches(HOURS_DATE_ARG)) { } else if (mpeArg.matches(HOURS_DATE_ARG)) {
logger.info("Executing MPE FieldGen with arguments: " + mpeArg);
Matcher matcher = HOURS_DATE_PATTERN.matcher(mpeArg); Matcher matcher = HOURS_DATE_PATTERN.matcher(mpeArg);
if (matcher.find()) { if (matcher.find()) {
exitValue = MainMethod.runProgram("ksh", exitValue = MainMethod.runProgram("ksh", EXECUTE_PATH,
appsDefaults.getToken("pproc_bin") matcher.group(1), matcher.group(2),
+ "/run_mpe_fieldgen", matcher.group(1), matcher.group(3));
matcher.group(2), matcher.group(3));
} }
} else {
throw new EdexException(
"Invalid argument sent to mpe_fieldgen: " + mpeArg);
} }
} }
@ -94,11 +124,18 @@ public class MpeFieldGenSrv {
"MpeFieldGen process terminated abnormally with exit code: " "MpeFieldGen process terminated abnormally with exit code: "
+ exitValue); + exitValue);
} }
return exitValue; return exitValue;
} }
/**
* Run fieldgen with the defalut argument.
*
* @return exit status
* @throws EdexException
*/
public Object runHourlyMpe() throws EdexException { public Object runHourlyMpe() throws EdexException {
return process(defaultMpeArg); return process(DEFAULT_ARG);
} }
} }

View file

@ -23,8 +23,6 @@ package com.raytheon.uf.edex.ohd.pproc;
import java.io.File; import java.io.File;
import java.sql.Timestamp; import java.sql.Timestamp;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.opengis.metadata.spatial.PixelOrientation; import org.opengis.metadata.spatial.PixelOrientation;
@ -38,6 +36,8 @@ import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.StorageException; import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.hydro.spatial.HRAP; import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.uf.common.ohd.AppsDefaults; 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.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.database.dao.CoreDao; import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig; import com.raytheon.uf.edex.database.dao.DaoConfig;
@ -55,6 +55,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jan 06, 2011 5951 jnjanga Initial creation * Jan 06, 2011 5951 jnjanga Initial creation
* Jan 10, 2013 1448 bgonzale Added app context check in runOnSchedule(). * Jan 10, 2013 1448 bgonzale Added app context check in runOnSchedule().
* Jan 18, 2013 1469 bkowal Removed the hdf5 data directory. * Jan 18, 2013 1469 bkowal Removed the hdf5 data directory.
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* *
* </pre> * </pre>
* *
@ -80,7 +81,8 @@ public class MpeLightningSrv {
} }
} }
private Log logger = LogFactory.getLog(getClass()); private static final IUFStatusHandler logger = UFStatus
.getHandler(MpeLightningSrv.class);
/** /**
* Check the metadata Database for new lightning entries. * Check the metadata Database for new lightning entries.

View file

@ -20,12 +20,11 @@
package com.raytheon.uf.edex.ohd.pproc; package com.raytheon.uf.edex.ohd.pproc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.hydro.service.MpeGribProcessRequest; import com.raytheon.uf.common.hydro.service.MpeGribProcessRequest;
import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.serialization.comm.IRequestHandler; import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.ohd.MainMethod; import com.raytheon.uf.edex.ohd.MainMethod;
@ -37,7 +36,8 @@ import com.raytheon.uf.edex.ohd.MainMethod;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Feb 1, 2010 snaples Initial creation * Feb 01, 2010 snaples Initial creation
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
* </pre> * </pre>
* *
* @author snaples * @author snaples
@ -46,9 +46,10 @@ import com.raytheon.uf.edex.ohd.MainMethod;
public class MpeProcessGribSrv implements public class MpeProcessGribSrv implements
IRequestHandler<MpeGribProcessRequest> { IRequestHandler<MpeGribProcessRequest> {
private AppsDefaults appsDefaults = AppsDefaults.getInstance(); private static final IUFStatusHandler logger = UFStatus
.getHandler(MpeProcessGribSrv.class);
private Log logger = LogFactory.getLog(getClass()); private final AppsDefaults appsDefaults = AppsDefaults.getInstance();
/** /**
* The serialized incoming request contains the file names of the xmrg file * The serialized incoming request contains the file names of the xmrg file
@ -64,12 +65,11 @@ public class MpeProcessGribSrv implements
throw new EdexException("Invalid argument sent to MpeProcessGrib"); throw new EdexException("Invalid argument sent to MpeProcessGrib");
} }
int exitValue = 0; int exitValue = 0;
logger logger.info("Executing process_grib_files with arguments: xmrgfilename: "
.info("Executing process_grib_files with arguments: xmrgfilename: "
+ xmrg + " gribfilename: " + grib); + xmrg + " gribfilename: " + grib);
exitValue = MainMethod.runProgram("ksh", appsDefaults exitValue = MainMethod.runProgram("ksh",
.getToken("pproc_bin") appsDefaults.getToken("pproc_bin") + "/process_grib_files",
+ "/process_grib_files", xmrg, grib); xmrg, grib);
if (exitValue == 0) { if (exitValue == 0) {
logger.info("MpeProcessGrib execution successful"); logger.info("MpeProcessGrib execution successful");
} else { } else {