diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-decode.xml b/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-decode.xml index 6aea82142a..34c2867963 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-decode.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/res/spring/grib-decode.xml @@ -86,7 +86,7 @@ - + diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java index 76c46e1bd9..ba9de0e745 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java @@ -21,18 +21,21 @@ package com.raytheon.edex.plugin.grib; import java.io.File; import java.io.IOException; +import java.util.Map; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; import ucar.grib.GribChecker; import ucar.unidata.io.RandomAccessFile; -import com.raytheon.edex.esb.Headers; import com.raytheon.edex.plugin.grib.exception.GribException; import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.python.decoder.PythonDecoder; /** @@ -43,54 +46,53 @@ import com.raytheon.uf.edex.python.decoder.PythonDecoder; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 3/12/10 4758 bphillip Initial creation + * 02/12/2013 1615 bgonzale public decode method to a Processor exchange method. * * * @author njensen * @version 1.0 */ -public class GribDecoder { +public class GribDecoder implements Processor { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(GribDecoder.class); - public GribDecoder() { + /** + * @see org.apache.camel.Processor.process(Exchange) + */ + @Override + public void process(Exchange exchange) throws Exception { + final String DATA_TYPE = "dataType"; + final String GRIB = "grib"; - } + File file = (File) exchange.getIn().getBody(); + Map headers = exchange.getIn().getHeaders(); - public GridRecord[] decode(File file, Headers headers) { - GridRecord[] records = null; RandomAccessFile raf = null; int edition = 0; + GridRecord[] records = null; try { raf = new RandomAccessFile(file.getAbsolutePath(), "r"); raf.order(RandomAccessFile.BIG_ENDIAN); edition = GribChecker.getEdition(raf); + exchange.getIn().setHeader(DATA_TYPE, GRIB + edition); - if (edition == 1) { + switch (edition) { + case 1: records = new Grib1Decoder().decode(file.getAbsolutePath()); - } else if (edition == 2) { - PythonDecoder pythonDecoder = new PythonDecoder(); - pythonDecoder.setPluginName("grib"); - pythonDecoder.setPluginFQN("com.raytheon.edex.plugin.grib"); - pythonDecoder.setModuleName("GribDecoder"); - pythonDecoder.setRecordClassname(GridRecord.class.toString()); - pythonDecoder.setCache(true); - try { - PluginDataObject[] pdos = pythonDecoder.decode(file); - records = new GridRecord[pdos.length]; - for (int i = 0; i < pdos.length; i++) { - records[i] = (GridRecord) pdos[i]; - } - } catch (Exception e) { - throw new GribException("Error decoding grib file!", e); - } - } else { + break; + case 2: + records = decodeGrib2(file); + break; + default: throw new GribException("Unknown grib version detected [" + edition + "]"); } + String datasetId = (String) headers.get("datasetid"); String secondaryId = (String) headers.get("secondaryid"); String ensembleId = (String) headers.get("ensembleid"); + if (secondaryId != null || datasetId != null || ensembleId != null) { for (GridRecord record : records) { if (datasetId != null) { @@ -120,6 +122,36 @@ public class GribDecoder { "Unable to close RandomAccessFile!", e); } } + exchange.getIn().setBody(records); + } + + /** + * Decode a grib 2 file. + * + * @param file + * Grib 2 file + * @return Array of GribRecords parsed from the file. + * @throws PluginException + */ + private GridRecord[] decodeGrib2(File file) + throws PluginException { + GridRecord[] records = null; + PythonDecoder pythonDecoder = new PythonDecoder(); + + pythonDecoder.setPluginName("grib"); + pythonDecoder.setPluginFQN("com.raytheon.edex.plugin.grib"); + pythonDecoder.setModuleName("GribDecoder"); + pythonDecoder.setRecordClassname(GridRecord.class.toString()); + pythonDecoder.setCache(true); + try { + PluginDataObject[] pdos = pythonDecoder.decode(file); + records = new GridRecord[pdos.length]; + for (int i = 0; i < pdos.length; i++) { + records[i] = (GridRecord) pdos[i]; + } + } catch (Exception e) { + throw new GribException("Error decoding grib file!", e); + } return records; } } diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-ingest.xml b/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-ingest.xml index 7d12a23e85..89eb975ba5 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-ingest.xml +++ b/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-ingest.xml @@ -56,11 +56,17 @@ + + Radar-SBN + + + Radar-Local + diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/ProcessEvent.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/ProcessEvent.java index ff93d8ea8b..b257fa8673 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/ProcessEvent.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/ProcessEvent.java @@ -36,6 +36,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 25, 2012 #1292 bgonzale Initial creation + * Feb 12, 2013 #1615 bgonzale Changed pluginName to dataType. * * * @@ -59,7 +60,7 @@ public class ProcessEvent extends StatisticsEvent { private String message; @DynamicSerializeElement - private String pluginName; + private String dataType; @DynamicSerializeElement private String fileName; @@ -99,10 +100,10 @@ public class ProcessEvent extends StatisticsEvent { } /** - * @return the pluginName + * @return the dataType */ - public String getPluginName() { - return pluginName; + public String getDataType() { + return dataType; } /** @@ -136,11 +137,11 @@ public class ProcessEvent extends StatisticsEvent { } /** - * @param pluginName - * the pluginName to set + * @param dataType + * the dataType to set */ - public void setPluginName(String pluginName) { - this.pluginName = pluginName; + public void setDataType(String dataType) { + this.dataType = dataType; } /** diff --git a/edexOsgi/com.raytheon.uf.edex.cpgsrv/src/com/raytheon/uf/edex/cpgsrv/CompositeProductGenerator.java b/edexOsgi/com.raytheon.uf.edex.cpgsrv/src/com/raytheon/uf/edex/cpgsrv/CompositeProductGenerator.java index 1fb74705d4..9d4b78ce5d 100644 --- a/edexOsgi/com.raytheon.uf.edex.cpgsrv/src/com/raytheon/uf/edex/cpgsrv/CompositeProductGenerator.java +++ b/edexOsgi/com.raytheon.uf.edex.cpgsrv/src/com/raytheon/uf/edex/cpgsrv/CompositeProductGenerator.java @@ -59,6 +59,7 @@ import com.raytheon.uf.edex.database.plugin.PluginDao; * 02/07/2009 1981 dhladky Initial Creation. * 30NOV2012 1372 dhladky Added statistics. * 02/05/2013 1580 mpduff EventBus refactor. + * 02/12/2013 1615 bgonzale Changed ProcessEvent pluginName to dataType. * * * @@ -442,7 +443,7 @@ public abstract class CompositeProductGenerator implements String pluginName = getPluginDataObjects()[0].getPluginName(); if (pluginName != null) { - processEvent.setPluginName(pluginName); + processEvent.setDataType(pluginName); } Long dequeueTime = message.getDeQueuedTime(); diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java index 4699f5f66b..b76f7b2f81 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java @@ -45,6 +45,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * Dec 1, 2008 chammack Initial creation * Feb 05, 2013 1580 mpduff EventBus refactor. + * Feb 12, 2013 1615 bgonzale Changed ProcessEvent pluginName to dataType. * * * @@ -127,10 +128,14 @@ public class ProcessUtil { StringBuilder sb = new StringBuilder(128); ProcessEvent processEvent = new ProcessEvent(); + String dataType = getHeaderProperty(headers, "dataType"); String pluginName = getHeaderProperty(headers, "pluginName"); - if (pluginName != null) { + if (dataType != null) { + sb.append(dataType); + processEvent.setDataType(dataType); + } else if (pluginName != null) { sb.append(pluginName); - processEvent.setPluginName(pluginName); + processEvent.setDataType(pluginName); } String fileName = getHeaderProperty(headers, "ingestFileName"); diff --git a/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml index 90c2d74058..13264c5463 100644 --- a/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml +++ b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml @@ -2,7 +2,7 @@ - +