Issue #2940 Better error message for bad XMRG config in FFMP

Change-Id: I0ed88a33dc7fe78dcccb7af212a3180d3124ca4f

Former-commit-id: b64527b6d538eafc4ae3cc49a32f54c9f44e118a
This commit is contained in:
Dave Hladky 2014-04-03 16:55:12 -05:00
parent ef337f77d2
commit 00019f27c1

View file

@ -100,6 +100,7 @@ import com.vividsolutions.jts.geom.Polygon;
* 05/01/2013 15684 zhao Unlock when Exception caught * 05/01/2013 15684 zhao Unlock when Exception caught
* Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL * Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL
* 09/03/2013 DR 13083 G. Zhang Added a fix in processRADAR(ArrayList<SourceBinEntry>). * 09/03/2013 DR 13083 G. Zhang Added a fix in processRADAR(ArrayList<SourceBinEntry>).
* 03 April 2014 2940 dhladky Better error message for bad configurations.
* </pre> * </pre>
* @author dhladky * @author dhladky
* @version 1 * @version 1
@ -237,25 +238,35 @@ public class FFMPProcessor {
Date recdate = null; Date recdate = null;
if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) { if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) {
radarRec = (RadarRecord) config.getSourceData( try {
source.getSourceName()).get(dataKey); radarRec = (RadarRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
if (radarRec.getMnemonic().equals("DHR")) { if (radarRec.getMnemonic().equals("DHR")) {
dhrMap = RadarRecordUtil.getDHRValues(radarRec); dhrMap = RadarRecordUtil.getDHRValues(radarRec);
statusHandler.handle(Priority.INFO, statusHandler.handle(Priority.INFO, "DHR Bias: "
"DHR Bias: " + dhrMap.get(DHRValues.BIAS_TO_USE)); + dhrMap.get(DHRValues.BIAS_TO_USE));
statusHandler.handle(Priority.INFO, statusHandler.handle(Priority.INFO, "DHR HailCap: "
"DHR HailCap: " + dhrMap.get(DHRValues.MAXPRECIPRATEALLOW)); + dhrMap.get(DHRValues.MAXPRECIPRATEALLOW));
}
recdate = radarRec.getDataTime().getRefTime();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
} }
recdate = radarRec.getDataTime().getRefTime();
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.XMRG) { } else if (type == FFMPSourceConfigurationManager.DATA_TYPE.XMRG) {
xmrg = (XmrgFile) config.getSourceData(source.getSourceName()) try {
.get(dataKey); xmrg = (XmrgFile) config.getSourceData(
this.extent = getExtents(source.getHrapGridFactor()); source.getSourceName()).get(dataKey);
setHRAPSubGrid(extent, source.getHrapGridFactor()); this.extent = getExtents(source.getHrapGridFactor());
xmrgData = xmrg.getData(extent); setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
if (xmrg.getHeader().getValidDate().getTime() > 0l) { if (xmrg.getHeader().getValidDate().getTime() > 0l) {
recdate = xmrg.getHeader().getValidDate(); recdate = xmrg.getHeader().getValidDate();
@ -285,15 +296,25 @@ public class FFMPProcessor {
} }
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.PDO) { } else if (type == FFMPSourceConfigurationManager.DATA_TYPE.PDO) {
imp = (IMonitorProcessing) config.getSourceData( try {
source.getSourceName()).get(dataKey); imp = (IMonitorProcessing) config.getSourceData(
recdate = imp.getDataTime().getRefTime(); source.getSourceName()).get(dataKey);
recdate = imp.getDataTime().getRefTime();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) { } else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) {
gribRec = (GridRecord) config.getSourceData( try {
source.getSourceName()).get(dataKey); gribRec = (GridRecord) config.getSourceData(
gribData = config.getGribData(gribRec); source.getSourceName()).get(dataKey);
recdate = gribRec.getDataTime().getRefTime(); gribData = config.getGribData(gribRec);
recdate = gribRec.getDataTime().getRefTime();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
} }
statusHandler.handle( statusHandler.handle(
@ -350,7 +371,6 @@ public class FFMPProcessor {
cwaGeometries, radarRec)); cwaGeometries, radarRec));
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.WARN, "caught an Exception while generating Source Bin List"); statusHandler.handle(Priority.WARN, "caught an Exception while generating Source Bin List");
e.printStackTrace();
if (!checkLockStatus()) { if (!checkLockStatus()) {
ClusterLockUtils.unlock(sourceBinTaskName, sourceId); ClusterLockUtils.unlock(sourceBinTaskName, sourceId);
} }
@ -502,7 +522,6 @@ public class FFMPProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new Exception("FFMPProcessor: Failed to process source: " throw new Exception("FFMPProcessor: Failed to process source: "
+ source.getSourceName(), e); + source.getSourceName(), e);
} }
@ -591,7 +610,6 @@ public class FFMPProcessor {
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace();
throw new Exception( throw new Exception(
"FFMPProcessor: Failed to process source domain: " "FFMPProcessor: Failed to process source domain: "
+ source.getSourceName() + ": " + source.getSourceName() + ": "
@ -679,7 +697,6 @@ public class FFMPProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new Exception( throw new Exception(
"FFMPProcessor: Failed to Guidance Transition Delay source " "FFMPProcessor: Failed to Guidance Transition Delay source "
+ source.getSourceName()); + source.getSourceName());
@ -687,7 +704,6 @@ public class FFMPProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new Exception("FFMPProcessor: Failed to process source: " throw new Exception("FFMPProcessor: Failed to process source: "
+ source.getSourceName()); + source.getSourceName());
} }
@ -703,20 +719,30 @@ public class FFMPProcessor {
Date recdate = null; Date recdate = null;
if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) { if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) {
radarRec = (RadarRecord) config.getSourceData( try {
source.getSourceName()).get(dataKey); radarRec = (RadarRecord) config.getSourceData(
if (radarRec.getMnemonic().equals("DHR")) { source.getSourceName()).get(dataKey);
dhrMap = RadarRecordUtil.getDHRValues(radarRec); if (radarRec.getMnemonic().equals("DHR")) {
dhrMap = RadarRecordUtil.getDHRValues(radarRec);
}
recdate = radarRec.getDataTime().getRefTime();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
} }
recdate = radarRec.getDataTime().getRefTime();
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.XMRG) { } else if (type == FFMPSourceConfigurationManager.DATA_TYPE.XMRG) {
xmrg = (XmrgFile) config.getSourceData(source.getSourceName()).get( try {
dataKey); xmrg = (XmrgFile) config.getSourceData(source.getSourceName()).get(
this.extent = getExtents(source.getHrapGridFactor()); dataKey);
setHRAPSubGrid(extent, source.getHrapGridFactor()); this.extent = getExtents(source.getHrapGridFactor());
xmrgData = xmrg.getData(extent); setHRAPSubGrid(extent, source.getHrapGridFactor());
recdate = xmrg.getHeader().getValidDate(); xmrgData = xmrg.getData(extent);
recdate = xmrg.getHeader().getValidDate();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
} }
// set the time // set the time
@ -762,9 +788,11 @@ public class FFMPProcessor {
coor = rc.asGridCell(imp.getGridGeometry(), coor = rc.asGridCell(imp.getGridGeometry(),
PixelInCell.CELL_CENTER); PixelInCell.CELL_CENTER);
} catch (TransformException e) { } catch (TransformException e) {
e.printStackTrace(); statusHandler.error("VGB PDO transform error!", e);
continue;
} catch (FactoryException e) { } catch (FactoryException e) {
e.printStackTrace(); statusHandler.error("VGB PDO factory error!", e);
continue;
} }
val = processPDO(coor, 1.0); val = processPDO(coor, 1.0);
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) { } else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) {
@ -776,7 +804,7 @@ public class FFMPProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); statusHandler.error("Unable to process VGB: "+type, e);
} }
} }
} }
@ -833,7 +861,7 @@ public class FFMPProcessor {
* @param geo * @param geo
* @return * @return
*/ */
private float processPDO(Long pfaf, String cwa) { private float processPDO(Long pfaf, String cwa) throws Exception {
ArrayList<SourceBinEntry> entries = null; ArrayList<SourceBinEntry> entries = null;
float arealWeight = 0; float arealWeight = 0;
@ -861,9 +889,11 @@ public class FFMPProcessor {
center = rc.asGridCell(imp.getGridGeometry(), center = rc.asGridCell(imp.getGridGeometry(),
PixelInCell.CELL_CENTER); PixelInCell.CELL_CENTER);
} catch (TransformException e) { } catch (TransformException e) {
e.printStackTrace(); statusHandler.error("PDO transform error!", e);
throw new Exception(e);
} catch (FactoryException e) { } catch (FactoryException e) {
e.printStackTrace(); statusHandler.error("PDO factory error!", e);
throw new Exception(e);
} }
if ((center.x >= 0) && (center.x < imp.getNx()) if ((center.x >= 0) && (center.x < imp.getNx())
@ -936,7 +966,7 @@ public class FFMPProcessor {
* @param geo * @param geo
* @return * @return
*/ */
private float processXMRG(Long pfaf, String cwa) { private float processXMRG(Long pfaf, String cwa) throws Exception {
ArrayList<SourceBinEntry> entries = null; ArrayList<SourceBinEntry> entries = null;
float arealWeight = 0.0f; float arealWeight = 0.0f;
@ -965,11 +995,14 @@ public class FFMPProcessor {
.getGridGeometry(), PixelInCell.CELL_CENTER); .getGridGeometry(), PixelInCell.CELL_CENTER);
} catch (TransformException e) { } catch (TransformException e) {
e.printStackTrace(); statusHandler.error("SBL Transform exception: ", e);
throw new Exception(e);
} catch (FactoryException e) { } catch (FactoryException e) {
e.printStackTrace(); statusHandler.error("SBL Factory exception: ", e);
throw new Exception(e);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); statusHandler.error("SBL General exception: ", e);
throw new Exception(e);
} }
double xx = center.x - hrapgrid.getExtent().x; double xx = center.x - hrapgrid.getExtent().x;
@ -1106,9 +1139,6 @@ public class FFMPProcessor {
if (radarRec.getMnemonic().equals("DHR")) { if (radarRec.getMnemonic().equals("DHR")) {
for (int j = 0; j < dataVals.length; j++) { for (int j = 0; j < dataVals.length; j++) {
//float fval = (float) ScanUtils.getDecodedDHRValue(dataVals[j]);
try { try {
val += ScanUtils.getZRvalue2(dataVals[j],//fval,// DR 13083 val += ScanUtils.getZRvalue2(dataVals[j],//fval,// DR 13083
dhrMap.get(DHRValues.ZRMULTCOEFF), dhrMap.get(DHRValues.ZRMULTCOEFF),
@ -1151,7 +1181,7 @@ public class FFMPProcessor {
* @param geo * @param geo
* @return * @return
*/ */
private float processGrib(Long pfaf, String cwa) { private float processGrib(Long pfaf, String cwa) throws Exception {
ArrayList<SourceBinEntry> entries = null; ArrayList<SourceBinEntry> entries = null;
float arealWeight = 0.0f; float arealWeight = 0.0f;
@ -1180,8 +1210,10 @@ public class FFMPProcessor {
PixelInCell.CELL_CENTER); PixelInCell.CELL_CENTER);
} catch (TransformException e) { } catch (TransformException e) {
statusHandler.handle(Priority.ERROR, "Error transforming pfaf! " +pfaf); statusHandler.handle(Priority.ERROR, "Error transforming pfaf! " +pfaf);
throw new Exception(e);
} catch (FactoryException e) { } catch (FactoryException e) {
statusHandler.handle(Priority.ERROR, "Error in geometry! " +pfaf); statusHandler.handle(Priority.ERROR, "Error in geometry! " +pfaf);
throw new Exception(e);
} }
if (((int) center.x >= 0) && ((int) center.x < getNx()) if (((int) center.x >= 0) && ((int) center.x < getNx())
@ -1264,7 +1296,7 @@ public class FFMPProcessor {
try { try {
hrapgrid = new HRAPSubGrid(rectangle, hrapGribFactor); hrapgrid = new HRAPSubGrid(rectangle, hrapGribFactor);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); statusHandler.error("Cant load HRAP sub grid!", e);
} }
} }
@ -1290,7 +1322,7 @@ public class FFMPProcessor {
rect.setBounds(rect.x * hrapGridFactor, rect.y * hrapGridFactor, rect.setBounds(rect.x * hrapGridFactor, rect.y * hrapGridFactor,
rect.width * hrapGridFactor, rect.height * hrapGridFactor); rect.width * hrapGridFactor, rect.height * hrapGridFactor);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); statusHandler.error("Can't get HRAP extents! ", e);
} }
return rect; return rect;
} }
@ -1757,5 +1789,39 @@ public class FFMPProcessor {
public String getSourceID() { public String getSourceID() {
return sourceId; return sourceId;
} }
/**
* Fire off a semi-useful message for purpose of diagnostics.
* @param type
*/
private void fireBadConfigMessage(
FFMPSourceConfigurationManager.DATA_TYPE type, Exception e) {
StringBuffer sb = new StringBuffer();
sb.append(type + " Source: " + source.getSourceName()
+ " has a non-functional configuration! \n");
sb.append("DataKey: " + dataKey + " SiteKey: " + siteKey + " \n");
if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) {
if (radarRec != null) {
sb.append("Record: " + radarRec.getDataURI() + " \n");
}
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.XMRG) {
if (xmrg != null) {
sb.append("XMRG File: " + xmrg.getFile().getAbsolutePath()
+ " \n");
}
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.PDO) {
if (imp != null) {
sb.append("PDO Record: " + imp.getClass().getName() + " Size: "+ imp.getDataArray().length+ "\n");
}
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) {
if (gribRec != null) {
sb.append("Record: " + gribRec.getDataURI() + " \n");
}
}
statusHandler.handle(Priority.ERROR, sb.toString(), e);
}
} }