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
* 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>).
* 03 April 2014 2940 dhladky Better error message for bad configurations.
* </pre>
* @author dhladky
* @version 1
@ -237,25 +238,35 @@ public class FFMPProcessor {
Date recdate = null;
if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) {
radarRec = (RadarRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
try {
radarRec = (RadarRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
if (radarRec.getMnemonic().equals("DHR")) {
dhrMap = RadarRecordUtil.getDHRValues(radarRec);
statusHandler.handle(Priority.INFO,
"DHR Bias: " + dhrMap.get(DHRValues.BIAS_TO_USE));
statusHandler.handle(Priority.INFO,
"DHR HailCap: " + dhrMap.get(DHRValues.MAXPRECIPRATEALLOW));
if (radarRec.getMnemonic().equals("DHR")) {
dhrMap = RadarRecordUtil.getDHRValues(radarRec);
statusHandler.handle(Priority.INFO, "DHR Bias: "
+ dhrMap.get(DHRValues.BIAS_TO_USE));
statusHandler.handle(Priority.INFO, "DHR HailCap: "
+ 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) {
xmrg = (XmrgFile) config.getSourceData(source.getSourceName())
.get(dataKey);
this.extent = getExtents(source.getHrapGridFactor());
setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
try {
xmrg = (XmrgFile) config.getSourceData(
source.getSourceName()).get(dataKey);
this.extent = getExtents(source.getHrapGridFactor());
setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
if (xmrg.getHeader().getValidDate().getTime() > 0l) {
recdate = xmrg.getHeader().getValidDate();
@ -285,15 +296,25 @@ public class FFMPProcessor {
}
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.PDO) {
imp = (IMonitorProcessing) config.getSourceData(
source.getSourceName()).get(dataKey);
recdate = imp.getDataTime().getRefTime();
try {
imp = (IMonitorProcessing) config.getSourceData(
source.getSourceName()).get(dataKey);
recdate = imp.getDataTime().getRefTime();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) {
gribRec = (GridRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
gribData = config.getGribData(gribRec);
recdate = gribRec.getDataTime().getRefTime();
try {
gribRec = (GridRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
gribData = config.getGribData(gribRec);
recdate = gribRec.getDataTime().getRefTime();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
}
statusHandler.handle(
@ -350,7 +371,6 @@ public class FFMPProcessor {
cwaGeometries, radarRec));
} catch (Exception e) {
statusHandler.handle(Priority.WARN, "caught an Exception while generating Source Bin List");
e.printStackTrace();
if (!checkLockStatus()) {
ClusterLockUtils.unlock(sourceBinTaskName, sourceId);
}
@ -502,7 +522,6 @@ public class FFMPProcessor {
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("FFMPProcessor: Failed to process source: "
+ source.getSourceName(), e);
}
@ -591,7 +610,6 @@ public class FFMPProcessor {
}
catch (Exception e) {
e.printStackTrace();
throw new Exception(
"FFMPProcessor: Failed to process source domain: "
+ source.getSourceName() + ": "
@ -679,7 +697,6 @@ public class FFMPProcessor {
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception(
"FFMPProcessor: Failed to Guidance Transition Delay source "
+ source.getSourceName());
@ -687,7 +704,6 @@ public class FFMPProcessor {
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("FFMPProcessor: Failed to process source: "
+ source.getSourceName());
}
@ -703,20 +719,30 @@ public class FFMPProcessor {
Date recdate = null;
if (type == FFMPSourceConfigurationManager.DATA_TYPE.RADAR) {
radarRec = (RadarRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
if (radarRec.getMnemonic().equals("DHR")) {
dhrMap = RadarRecordUtil.getDHRValues(radarRec);
try {
radarRec = (RadarRecord) config.getSourceData(
source.getSourceName()).get(dataKey);
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) {
xmrg = (XmrgFile) config.getSourceData(source.getSourceName()).get(
dataKey);
this.extent = getExtents(source.getHrapGridFactor());
setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
recdate = xmrg.getHeader().getValidDate();
try {
xmrg = (XmrgFile) config.getSourceData(source.getSourceName()).get(
dataKey);
this.extent = getExtents(source.getHrapGridFactor());
setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
recdate = xmrg.getHeader().getValidDate();
} catch (Exception e) {
fireBadConfigMessage(type, e);
return;
}
}
// set the time
@ -762,9 +788,11 @@ public class FFMPProcessor {
coor = rc.asGridCell(imp.getGridGeometry(),
PixelInCell.CELL_CENTER);
} catch (TransformException e) {
e.printStackTrace();
statusHandler.error("VGB PDO transform error!", e);
continue;
} catch (FactoryException e) {
e.printStackTrace();
statusHandler.error("VGB PDO factory error!", e);
continue;
}
val = processPDO(coor, 1.0);
} else if (type == FFMPSourceConfigurationManager.DATA_TYPE.GRID) {
@ -776,7 +804,7 @@ public class FFMPProcessor {
}
} catch (Exception e) {
e.printStackTrace();
statusHandler.error("Unable to process VGB: "+type, e);
}
}
}
@ -833,7 +861,7 @@ public class FFMPProcessor {
* @param geo
* @return
*/
private float processPDO(Long pfaf, String cwa) {
private float processPDO(Long pfaf, String cwa) throws Exception {
ArrayList<SourceBinEntry> entries = null;
float arealWeight = 0;
@ -861,9 +889,11 @@ public class FFMPProcessor {
center = rc.asGridCell(imp.getGridGeometry(),
PixelInCell.CELL_CENTER);
} catch (TransformException e) {
e.printStackTrace();
statusHandler.error("PDO transform error!", e);
throw new Exception(e);
} catch (FactoryException e) {
e.printStackTrace();
statusHandler.error("PDO factory error!", e);
throw new Exception(e);
}
if ((center.x >= 0) && (center.x < imp.getNx())
@ -936,7 +966,7 @@ public class FFMPProcessor {
* @param geo
* @return
*/
private float processXMRG(Long pfaf, String cwa) {
private float processXMRG(Long pfaf, String cwa) throws Exception {
ArrayList<SourceBinEntry> entries = null;
float arealWeight = 0.0f;
@ -965,11 +995,14 @@ public class FFMPProcessor {
.getGridGeometry(), PixelInCell.CELL_CENTER);
} catch (TransformException e) {
e.printStackTrace();
statusHandler.error("SBL Transform exception: ", e);
throw new Exception(e);
} catch (FactoryException e) {
e.printStackTrace();
statusHandler.error("SBL Factory exception: ", e);
throw new Exception(e);
} catch (Exception e) {
e.printStackTrace();
statusHandler.error("SBL General exception: ", e);
throw new Exception(e);
}
double xx = center.x - hrapgrid.getExtent().x;
@ -1106,9 +1139,6 @@ public class FFMPProcessor {
if (radarRec.getMnemonic().equals("DHR")) {
for (int j = 0; j < dataVals.length; j++) {
//float fval = (float) ScanUtils.getDecodedDHRValue(dataVals[j]);
try {
val += ScanUtils.getZRvalue2(dataVals[j],//fval,// DR 13083
dhrMap.get(DHRValues.ZRMULTCOEFF),
@ -1151,7 +1181,7 @@ public class FFMPProcessor {
* @param geo
* @return
*/
private float processGrib(Long pfaf, String cwa) {
private float processGrib(Long pfaf, String cwa) throws Exception {
ArrayList<SourceBinEntry> entries = null;
float arealWeight = 0.0f;
@ -1180,8 +1210,10 @@ public class FFMPProcessor {
PixelInCell.CELL_CENTER);
} catch (TransformException e) {
statusHandler.handle(Priority.ERROR, "Error transforming pfaf! " +pfaf);
throw new Exception(e);
} catch (FactoryException e) {
statusHandler.handle(Priority.ERROR, "Error in geometry! " +pfaf);
throw new Exception(e);
}
if (((int) center.x >= 0) && ((int) center.x < getNx())
@ -1264,7 +1296,7 @@ public class FFMPProcessor {
try {
hrapgrid = new HRAPSubGrid(rectangle, hrapGribFactor);
} 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.width * hrapGridFactor, rect.height * hrapGridFactor);
} catch (Exception e) {
e.printStackTrace();
statusHandler.error("Can't get HRAP extents! ", e);
}
return rect;
}
@ -1757,5 +1789,39 @@ public class FFMPProcessor {
public String getSourceID() {
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);
}
}