Merge "Issue #2940 Better error message for bad XMRG config in FFMP" into omaha_14.3.1

Former-commit-id: f38816d168 [formerly dc0b598fd4] [formerly f38816d168 [formerly dc0b598fd4] [formerly 132d63ac44 [formerly 28b33188773001c34946464093319dc2a1117be9]]]
Former-commit-id: 132d63ac44
Former-commit-id: 8e141a137a [formerly 5314b412b4]
Former-commit-id: b9351199b8
This commit is contained in:
Richard Peter 2014-05-02 10:05:59 -05:00 committed by Gerrit Code Review
commit 9326b9d125
2 changed files with 28 additions and 9 deletions

View file

@ -136,6 +136,7 @@ import com.raytheon.uf.edex.plugin.ffmp.common.FFTIRatioDiff;
* re-query with every update. * re-query with every update.
* 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
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Apr 24, 2014 2940 dhladky Prevent storage of bad records.
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -697,10 +698,10 @@ public class FFMPGenerator extends CompositeProductGenerator implements
FFMPProcessor ffmp = new FFMPProcessor(config, generator, FFMPProcessor ffmp = new FFMPProcessor(config, generator,
ffmpRec, template); ffmpRec, template);
ffmpRec = ffmp.processFFMP(ffmpProduct); ffmpRec = ffmp.processFFMP(ffmpProduct);
ffmpRec.constructDataURI();
if (ffmpRec != null) { if (ffmpRec != null) {
ffmpRec.constructDataURI();
persistRecord(ffmpRec); persistRecord(ffmpRec);
processDataContainer(ffmpRec, siteKey); processDataContainer(ffmpRec, siteKey);
// Now that we have the data container, // Now that we have the data container,

View file

@ -37,6 +37,7 @@ import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.datum.PixelInCell; import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.TransformException; import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.dataplugin.exception.MalformedDataException;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin; import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasinData; import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasinData;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPDataContainer; import com.raytheon.uf.common.dataplugin.ffmp.FFMPDataContainer;
@ -260,9 +261,7 @@ public class FFMPProcessor {
try { try {
xmrg = (XmrgFile) config.getSourceData( xmrg = (XmrgFile) config.getSourceData(
source.getSourceName()).get(dataKey); source.getSourceName()).get(dataKey);
this.extent = getExtents(source.getHrapGridFactor()); xmrgData = getXMRGData();
setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
} catch (Exception e) { } catch (Exception e) {
fireBadConfigMessage(type, e); fireBadConfigMessage(type, e);
return; return;
@ -610,6 +609,7 @@ public class FFMPProcessor {
} }
catch (Exception e) { catch (Exception e) {
ffmpRec = null;
throw new Exception( throw new Exception(
"FFMPProcessor: Failed to process source domain: " "FFMPProcessor: Failed to process source domain: "
+ source.getSourceName() + ": " + source.getSourceName() + ": "
@ -704,6 +704,7 @@ public class FFMPProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
ffmpRec = null;
throw new Exception("FFMPProcessor: Failed to process source: " throw new Exception("FFMPProcessor: Failed to process source: "
+ source.getSourceName()); + source.getSourceName());
} }
@ -735,9 +736,7 @@ public class FFMPProcessor {
try { try {
xmrg = (XmrgFile) config.getSourceData(source.getSourceName()).get( xmrg = (XmrgFile) config.getSourceData(source.getSourceName()).get(
dataKey); dataKey);
this.extent = getExtents(source.getHrapGridFactor()); xmrgData = getXMRGData();
setHRAPSubGrid(extent, source.getHrapGridFactor());
xmrgData = xmrg.getData(extent);
recdate = xmrg.getHeader().getValidDate(); recdate = xmrg.getHeader().getValidDate();
} catch (Exception e) { } catch (Exception e) {
fireBadConfigMessage(type, e); fireBadConfigMessage(type, e);
@ -804,6 +803,7 @@ public class FFMPProcessor {
} }
} catch (Exception e) { } catch (Exception e) {
ffmpRec = null;
statusHandler.error("Unable to process VGB: "+type, e); statusHandler.error("Unable to process VGB: "+type, e);
} }
} }
@ -1820,8 +1820,26 @@ public class FFMPProcessor {
sb.append("Record: " + gribRec.getDataURI() + " \n"); sb.append("Record: " + gribRec.getDataURI() + " \n");
} }
} }
// null out the record it is garbage.
ffmpRec = null;
statusHandler.handle(Priority.ERROR, sb.toString(), e); statusHandler.handle(Priority.ERROR, sb.toString(), e);
} }
/**
* Gets the XMRG data array
*
* @return
*/
private short[][] getXMRGData() throws Exception {
this.extent = getExtents(source.getHrapGridFactor());
setHRAPSubGrid(extent, source.getHrapGridFactor());
if (xmrg.getHrapExtent() != null) {
xmrgData = xmrg.getData(extent);
} else {
throw new MalformedDataException("The XMRG data is malformed or the file is non-readable.");
}
return xmrgData;
}
} }