From a846ce98ad364f7cff3ed20439a8ef91667a12de Mon Sep 17 00:00:00 2001 From: Nathan Bowler Date: Wed, 29 Apr 2015 14:52:50 -0400 Subject: [PATCH] Omaha #4167 Propagrate hdf5 store errors StaticDataGenerator. Change-Id: I3dfc68f12fcc3255c28aec9af194e63c7f29cb77 Former-commit-id: 608581dfb5e0bfb2680af9c1ec486180d1f9a895 --- .../META-INF/MANIFEST.MF | 2 +- .../grid/staticdata/StaticDataGenerator.java | 23 +++--- .../grid/staticdata/topo/StaticTopoData.java | 74 +++++++++++-------- 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/META-INF/MANIFEST.MF index 47bfc5bb60..aef70b4ab3 100644 --- a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Grid Static Data Bundle-SymbolicName: com.raytheon.uf.edex.grid.staticdata -Bundle-Version: 1.14.1.qualifier +Bundle-Version: 1.15.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: javax.measure, diff --git a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java index 50cd0e80a0..a3eb66ecba 100644 --- a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java +++ b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java @@ -1,19 +1,19 @@ /** * 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. **/ @@ -72,12 +72,13 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao; * Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin * Mar 07, 2013 1587 bsteffen rewrite static data generation. * Mar 14, 2013 1587 bsteffen Fix persisting to datastore. - * Apr 14, 2014 16752 MPorricelli Add ensembleid to hash key to allow + * Apr 14, 2014 16752 MPorricelli Add ensembleid to hash key to allow * creation of static data for all perturbations * of Ensemble models * Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column * Sep 19, 2014 3627 mapeters Updated deprecated TimeTools usage. * Aug 06, 2013 3805 bsteffen Increase time of cluster locks. + * Apr 29, 2015 4167 nabowle Propagate exceptions to #processNotification() * * * @@ -153,7 +154,7 @@ public class StaticDataGenerator { staticRecords.addAll(processRecord(record)); } catch (Exception e) { statusHandler.handle(Priority.ERROR, - "Error creating/saving staticTopo data!", e); + "Error creating/saving staticTopo data.", e); } } } @@ -347,8 +348,12 @@ public class StaticDataGenerator { /** * Populate the message data for a static record, loads the correct type of * data based of the parameter in the record. + * + * @throws Exception + * If the static topo data cannot retrieved for a GridCoverage. */ - private void populateMessageData(GridRecord staticRecord) { + private void populateMessageData(GridRecord staticRecord) + throws Exception { if (staticRecord.getMessageData() != null) { // already populated, hits for static topo copied from the record. return; @@ -399,7 +404,7 @@ public class StaticDataGenerator { /** * Return a set with only records which are not already in the database - * + * * @throws PluginException */ private Set checkDatabase(Set staticRecords) @@ -461,7 +466,7 @@ public class StaticDataGenerator { private final int forecastTime; private final int coverageid; - + private final String ensembleid; public CacheKey(GridRecord record) { @@ -525,7 +530,7 @@ public class StaticDataGenerator { } } else if (!ensembleid.equals(other.ensembleid)) { return false; - } + } return true; } diff --git a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/topo/StaticTopoData.java b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/topo/StaticTopoData.java index dec5d236c0..451493d089 100644 --- a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/topo/StaticTopoData.java +++ b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/topo/StaticTopoData.java @@ -1,19 +1,19 @@ /** * 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. **/ @@ -53,6 +53,7 @@ import com.raytheon.uf.common.datastorage.Request; import com.raytheon.uf.common.datastorage.StorageException; import com.raytheon.uf.common.datastorage.StorageProperties; import com.raytheon.uf.common.datastorage.StorageProperties.Compression; +import com.raytheon.uf.common.datastorage.StorageStatus; import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.geospatial.CRSCache; import com.raytheon.uf.common.geospatial.MapUtil; @@ -74,7 +75,7 @@ import com.vividsolutions.jts.geom.Coordinate; /** * Class used for accessing static topography information for GFE smart inits - * + * *
  * SOFTWARE HISTORY
  * Date          Ticket#  Engineer    Description
@@ -89,9 +90,11 @@ import com.vividsolutions.jts.geom.Coordinate;
  * Feb 12, 2013  1608     randerso    Changed to call deleteDatasets
  * Aug 06, 2013  2235     bsteffen    Added Caching version of TopoQuery.
  * Aug 06, 2013  3805     bsteffen    Add timing to logging.
- * 
+ * Apr 29, 2015  4167     nabowle     Propagate exceptions from
+ *                                    #initStopoData(GridCoverage)
+ *
  * 
- * + * * @author bphillip * @version 1.0 */ @@ -147,7 +150,7 @@ public class StaticTopoData { /** * Gets the singleton instance of StaticTopoData - * + * * @return The singleton instance */ public static synchronized StaticTopoData getInstance() { @@ -268,7 +271,7 @@ public class StaticTopoData { * Prepare DataSource for interpolation. Since TiledTopoSource loads all * data on demand this will inititialize the source but will not request any * data. - * + * * @throws FactoryException * @throws MismatchedDimensionException * @throws TransformException @@ -313,7 +316,7 @@ public class StaticTopoData { /** * Splits the Pacific grid into east and west hemisphere chunks to reduce * memory usage - * + * * @throws Exception */ private void splitPacific() throws Exception { @@ -354,7 +357,7 @@ public class StaticTopoData { /** * Checks to see if the topo file exists - * + * * @return True if the file exists */ private boolean topoFileExists() { @@ -371,7 +374,7 @@ public class StaticTopoData { /** * Initializes the attributes so they can be easily retrieved - * + * * @throws Exception */ private void initAttributes() throws Exception { @@ -394,7 +397,7 @@ public class StaticTopoData { * Initializes the topography data for the given site. The data is extracted * from the static topo file and resampled according to the site location * information - * + * * @param modelName * The site for which to initalize the topo data * @param config @@ -425,18 +428,30 @@ public class StaticTopoData { inGeom.getGridRange().getHigh(0) + 1, inGeom.getGridRange().getHigh(1) + 1 }); siteDataStore.addDataRecord(outRecord, sp); - siteDataStore.store(StoreOp.REPLACE); + StorageStatus storestatus = siteDataStore.store(StoreOp.REPLACE); long endTimeMillis = System.currentTimeMillis(); - statusHandler.handle(Priority.INFO, - "Stopo data successfully initialized for " + coverage.getName() - + " in " + (endTimeMillis - startTimeMillis) + "ms"); + if (storestatus.hasExceptions()) { + throw storestatus.getExceptions()[0]; + } else { + statusHandler.handle( + Priority.INFO, + "Stopo data successfully initialized for " + + coverage.getName() + " in " + + (endTimeMillis - startTimeMillis) + "ms"); + } } /** * Private method used by the initialization code to see if the static topo * data for a coverage has been initialized + * + * @throws StorageException + * @throws SerializationException + * If the topography data cannot be initialized for the given + * site */ - public boolean checkModelTopo(GridCoverage coverage) { + public boolean checkModelTopo(GridCoverage coverage) + throws SerializationException, StorageException { ClusterTask ct = ClusterLockUtils.lock(TASK_NAME, coverage.spatialKey(), 120000, false); @@ -451,11 +466,6 @@ public class StaticTopoData { + coverage.getName()); initStopoData(coverage); } - } catch (Exception e) { - statusHandler.handle( - Priority.INFO, - "Error storing static topo data for " - + coverage.getName(), e); } finally { ClusterLockUtils.unlock(ct, false); } @@ -466,7 +476,7 @@ public class StaticTopoData { /** * Chekcs if the static topo data for a model exists in the file - * + * * @param modelName * The model to check * @return True if the data exists, else false @@ -491,12 +501,18 @@ public class StaticTopoData { /** * Retrieves the static topo data for the given site - * + * * @param modelName * The site for which to get the static topo data * @return The static topo data + * @throws StorageException + * @throws SerializationException + * If the topography data cannot be initialized for the given + * site + * */ - public FloatDataRecord getStopoData(GridCoverage coverage) { + public FloatDataRecord getStopoData(GridCoverage coverage) + throws SerializationException, StorageException { if (!topoExists(coverage)) { while (!checkModelTopo(coverage)) { } @@ -518,7 +534,7 @@ public class StaticTopoData { /** * Extracts the the topo data from each of the topo data sets. - * + * * @param inGeom * The geometry of the data to be requested * @return A float array containing the extracted topo data @@ -582,7 +598,7 @@ public class StaticTopoData { /** * Reads the raw data from the topo files - * + * * @param name * The name of the topo data set * @param llLat @@ -667,7 +683,7 @@ public class StaticTopoData { /** * Creates a grid geometry object from the provided information - * + * * @param crs * The coordinate reference system * @param llCoord @@ -718,7 +734,7 @@ public class StaticTopoData { /** * Retrieves a slab of data from a data set and returns a float array * containing the data - * + * * @param name * The name of the data set to get the data slab from * @param minX