Omaha #3373 fixed jaxb pooling performance issues

Change-Id: Icf7949e956f2b21ba156f4f0a19a2c41d0037681

Former-commit-id: 2ec52d8956b77aad30d46d7b4b2202c868b38a4d
This commit is contained in:
Brian Clements 2014-07-21 17:05:29 -05:00
parent 4e94590075
commit 37d97b9e48
4 changed files with 41 additions and 24 deletions

View file

@ -81,7 +81,8 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
* Oct 15, 2013 2473 bsteffen Remove deprecated method calls.
* Nov 19, 2013 2478 rjpeter Make update process update database also.
* Dec 06, 2013 2170 rjpeter Update to pass PluginDataObject[] to notification.
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
* Jul 21, 2014 3373 bclement JAXB manager api changes
* </pre>
*
* @author bphillip
@ -124,7 +125,7 @@ public class EnsembleGridAssembler implements IDecoderPostProcessor {
SingleTypeJAXBManager<CompositeModel> jaxbManager;
try {
jaxbManager = new SingleTypeJAXBManager<CompositeModel>(
jaxbManager = new SingleTypeJAXBManager<CompositeModel>(true,
CompositeModel.class);
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM,

View file

@ -27,6 +27,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.JAXBException;
import org.opengis.metadata.spatial.PixelOrientation;
import com.raytheon.edex.plugin.grib.exception.GribException;
@ -74,6 +76,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jan 04, 2013 15653 M.Porricelli Shift subgrid domain westward like
* AWIPSI
* Oct 15, 2013 2473 bsteffen Rewrite deprecated code.
* Jul 21, 2014 3373 bclement JAXB managers only live during initializeGrids()
*
* </pre>
*
@ -86,15 +89,6 @@ public class GribSpatialCache {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GribSpatialCache.class);
private static final SingleTypeJAXBManager<GridCoverage> GRID_COVERAGE_JAXB = SingleTypeJAXBManager
.createWithoutException(GridCoverage.class);
private static final SingleTypeJAXBManager<SubGridDef> SUB_GRID_DEF_JAXB = SingleTypeJAXBManager
.createWithoutException(SubGridDef.class);
private static final SingleTypeJAXBManager<DefaultSubGridCenterPoint> SUB_GRID_CENTER_JAXB = SingleTypeJAXBManager
.createWithoutException(DefaultSubGridCenterPoint.class);
/** The singleton instance */
private static GribSpatialCache instance;
@ -429,17 +423,20 @@ public class GribSpatialCache {
* Loads and validates subGridDef pointed to by filePath. If definition
* empty/invalid returns null.
*
* @param subGridDefJaxb
* @param filePath
* @param defaultCenter
* @return
*/
private SubGridDef loadSubGridDef(final String filePath,
final Coordinate defaultCenter) {
private SubGridDef loadSubGridDef(
final SingleTypeJAXBManager<SubGridDef> subGridDefJaxb,
final String filePath, final Coordinate defaultCenter) {
SubGridDef rval = null;
File f = new File(filePath);
if (f.length() > 0) {
try {
rval = SUB_GRID_DEF_JAXB.unmarshalFromXmlFile(f);
rval = subGridDefJaxb.unmarshalFromXmlFile(f);
if ((rval.getReferenceModel() == null && rval
.getReferenceGrid() == null)
|| (rval.getModelNames() == null)
@ -498,14 +495,28 @@ public class GribSpatialCache {
Map<Integer, Set<String>> gridNameMap = new HashMap<Integer, Set<String>>();
Map<String, GridCoverage> spatialNameMap = new HashMap<String, GridCoverage>();
Map<String, SubGridDef> subGridDefMap = new HashMap<String, SubGridDef>();
SingleTypeJAXBManager<GridCoverage> gridCovJaxb;
SingleTypeJAXBManager<SubGridDef> subGridDefJaxb;
try {
subGridDefJaxb = new SingleTypeJAXBManager<SubGridDef>(true,
SubGridDef.class);
gridCovJaxb = new SingleTypeJAXBManager<GridCoverage>(true,
GridCoverage.class);
} catch (JAXBException e) {
statusHandler.error("Unable to create grid JAXB managers", e);
return;
}
do {
ct = ClusterLockUtils.lock("grib", "spatialCache", 120000, true);
} while (!LockState.SUCCESSFUL.equals(ct.getLockState()));
try {
for (FileData fd : fdl.getCoverageFileList()) {
try {
GridCoverage grid = GRID_COVERAGE_JAXB
GridCoverage grid = gridCovJaxb
.unmarshalFromXmlFile(fd.getFilePath());
String name = grid.getName();
grid = insert(grid);
@ -535,8 +546,8 @@ public class GribSpatialCache {
}
for (FileData fd : fdl.getSubGridFileList()) {
try {
SubGridDef subGridDef = loadSubGridDef(fd.getFilePath(),
defaultCenterPoint);
SubGridDef subGridDef = loadSubGridDef(subGridDefJaxb,
fd.getFilePath(), defaultCenterPoint);
if (subGridDef == null) {
continue;
}
@ -599,12 +610,14 @@ public class GribSpatialCache {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationFile defaultSubGridLocationFile = pm
.getStaticLocalizationFile("/grib/defaultSubGridCenterPoint.xml");
SingleTypeJAXBManager<DefaultSubGridCenterPoint> subGridCenterJaxb = new SingleTypeJAXBManager<DefaultSubGridCenterPoint>(
DefaultSubGridCenterPoint.class);
if ((defaultSubGridLocationFile != null)
&& defaultSubGridLocationFile.exists()) {
try {
DefaultSubGridCenterPoint defaultSubGridLocation = defaultSubGridLocationFile
.jaxbUnmarshal(DefaultSubGridCenterPoint.class,
SUB_GRID_CENTER_JAXB);
subGridCenterJaxb);
if ((defaultSubGridLocation != null)
&& (defaultSubGridLocation.getCenterLatitude() != null)
&& (defaultSubGridLocation.getCenterLongitude() != null)) {

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
* ------------- -------- ----------- --------------------------
* Mar 09, 2010 4758 bphillip Initial Creation
* Oct 15, 2013 2473 bsteffen Remove deprecated method calls.
* Jul 21, 2014 3373 bclement JAXB manager API changes
*
* </pre>
*
@ -127,7 +128,7 @@ public class Grib1ParameterLookup {
try {
JAXBManager jaxbManager = new SingleTypeJAXBManager<Grib1ParameterSet>(
Grib1ParameterSet.class);
true, Grib1ParameterSet.class);
if (baseParameterFile.exists()) {
Grib1ParameterSet parameterSet = baseParameterFile
.jaxbUnmarshal(Grib1ParameterSet.class, jaxbManager);

View file

@ -28,8 +28,8 @@ import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -46,6 +46,7 @@ import com.raytheon.uf.common.status.UFStatus;
* ------------- -------- ----------- --------------------------
* Feb 27, 2012 bsteffen Initial creation
* Dec 16, 2013 2574 bsteffen Update deprecated method call.
* Jul 21, 2014 3373 bclement changed to use single type JAXB manager
*
* </pre>
*
@ -72,9 +73,10 @@ public class DatasetInfoLookup {
}
private void init() {
JAXBManager manager = null;
SingleTypeJAXBManager<DatasetInfoSet> manager = null;
try {
manager = new JAXBManager(DatasetInfoSet.class);
manager = new SingleTypeJAXBManager<DatasetInfoSet>(true,
DatasetInfoSet.class);
} catch (JAXBException e) {
statusHandler
.error("Error loading context for DatasetInfo, no datasetInfo will be loaded.",
@ -98,8 +100,8 @@ public class DatasetInfoLookup {
return;
}
try {
DatasetInfoSet set = manager.unmarshalFromXmlFile(
DatasetInfoSet.class, file.getFile());
DatasetInfoSet set = manager.unmarshalFromXmlFile(file
.getFile());
for (DatasetInfo info : set.getInfos()) {
infoMap.put(info.getDatasetId(), info);
}