Omaha #4707 Do not open pointset netcdf files in memory.

Former-commit-id: 0b0c567677a25e45e4940509153f50910983fed2
This commit is contained in:
Ben Steffensmeier 2015-09-10 12:37:10 -05:00
parent c71988f4bc
commit 878339f5b6
2 changed files with 11 additions and 8 deletions

View file

@ -31,8 +31,8 @@
<doTry>
<pipeline>
<bean ref="stringToFile" />
<bean ref="extractWMOHeader" method="remove" />
<bean ref="pointsetNetcdfDecoder" method="decode(${header.ingestFileName}, ${body})" />
<bean ref="getFileWithoutWmoHeader" />
<bean ref="pointsetNetcdfDecoder" method="decode" />
<to uri="direct-vm:persistIndexAlert" />
</pipeline>
<doCatch>

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.edex.plugin.pointset.netcdf;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.Buffer;
@ -104,7 +105,7 @@ public class PointSetNetcdfDecoder {
private ParameterLookup parameterLookup;
public PointSetRecord[] decode(String name, byte[] data) {
public PointSetRecord[] decode(File file) {
if (levelFactory == null) {
levelFactory = LevelFactory.getInstance();
}
@ -112,25 +113,27 @@ public class PointSetNetcdfDecoder {
parameterLookup = ParameterLookup.getInstance();
}
try {
NetcdfFile file = NetcdfFile.openInMemory(name, data);
NetcdfFile netcdfFile = NetcdfFile.open(file.getAbsolutePath());
Map<String, String> locationCache = new HashMap<String, String>();
List<PointSetRecord> records = new ArrayList<>();
for (ProductDescription description : descriptions
.getDescriptions()) {
PointSetRecord record = processDescription(file, description,
locationCache);
PointSetRecord record = processDescription(netcdfFile,
description, locationCache);
if (record != null) {
records.add(record);
}
}
if (records.isEmpty()) {
logger.warn("No valid pointsets were found in file: {}", name);
logger.warn("No valid pointsets were found in file: {}",
file.getName());
return EMPTY_POINTSET_ARRAY;
} else {
return records.toArray(EMPTY_POINTSET_ARRAY);
}
} catch (ParseException | IOException | StorageException e) {
logger.error("Unable to decode pointset from file: {}", name, e);
logger.error("Unable to decode pointset from file: {}",
file.getName(), e);
}
return EMPTY_POINTSET_ARRAY;
}