Issue #1504 GFE: Model data not always appearing automatically without CAVE restart

Change-Id: I1e52c111ec50a860a226d85bed6f0ab6dfebed58

Former-commit-id: 62671efc2a [formerly 1fe63a2d5e20226f6124a9ca27b9f6272c49226c]
Former-commit-id: 20b0761048
This commit is contained in:
Ron Anderson 2013-01-21 16:53:47 -06:00
parent 1057580201
commit 44807ba0d5
11 changed files with 273 additions and 323 deletions

View file

@ -73,6 +73,7 @@ import com.raytheon.viz.gfe.core.griddata.IGridData;
* to use IFPClient
* 02/23/12 #346 dgilling Implement a dispose method.
* 03/01/12 #346 dgilling Re-order dispose method.
* 01/21/12 #1504 randerso Cleaned up old debug logging to improve performance
*
* </pre>
*
@ -411,6 +412,7 @@ public class DbParm extends Parm {
// normal mode
if (normal) {
Arrays.sort(grids);
// Now replace the existing grids with the new ones
replaceGrids(affectedTimeRange, grids);
@ -757,10 +759,10 @@ public class DbParm extends Parm {
List<LockRequest> lreq = new ArrayList<LockRequest>(timesToSave.size());
for (int i = 0; i < timesToSave.size(); i++) {
String msg = "Reverting " + getParmID() + " tr="
+ timesToSave.get(i);
statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: "
+ msg));
// String msg = "Reverting " + getParmID() + " tr="
// + timesToSave.get(i);
// statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: "
// + msg));
boolean success = true;
IGridData[] grids = null;

View file

@ -97,24 +97,6 @@ class ParmID(JUtil.JavaWrapperClass):
def getParmId(self):
return self.__pid.getParmId()
def setParmName(self, parmName):
self.__pid.setParmName(parmName)
def setParmLevel(self, parmLevel):
self.__pid.setParmLevel(parmLevel)
def setDbId(self, dbId):
self.__pid.setDbId(dbId.toJavaObj())
def setCompositeName(self, compositeName):
self.__pid.setCompositeName(compositeName)
def setShortParmId(self, shortParmId):
self.__pid.setShortParmId(shortParmId)
def setParmId(self, parmId):
self.__pid.setParmId(parmId)
@staticmethod
def shortSerializer(parmID):
return JavaParmID.shortSerializer(parmID.javaParmId())

View file

@ -108,7 +108,7 @@
<route id="gfeVtecChangeNotification">
<from uri="jms-generic:topic:edex.alerts.vtec"/>
<doTry>
<bean ref="serializationUtil" method="transformFromThrift" />
<bean ref="serializationUtil" method="transformFromThrift" />
<bean ref="vtecChangeListener" method="handleNotification" />
<doCatch>
<exception>java.lang.Throwable</exception>
@ -130,7 +130,7 @@
</doTry>
</route>
</camelContext>
<!-- Beans to define a custom jms connection which will allow a durable subscription -->
<bean id="gfeNotifyConnectionFactory" class="org.apache.qpid.client.AMQConnectionFactory">
<constructor-arg type="java.lang.String" value="amqp://guest:guest@gfeNotify/edex?brokerlist='tcp://${broker.addr}?retries='9999'&amp;connecttimeout='5000'&amp;connectdelay='5000''&amp;maxprefetch='0'&amp;sync_publish='all'&amp;sync_ack='true'"/>

View file

@ -21,6 +21,7 @@
package com.raytheon.edex.plugin.gfe.cache.d2dparms;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@ -40,15 +41,18 @@ import com.raytheon.edex.plugin.gfe.server.database.D2DGridDatabase;
import com.raytheon.edex.plugin.gfe.server.database.D2DSatDatabase;
import com.raytheon.edex.plugin.gfe.server.database.D2DSatDatabaseManager;
import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
import com.raytheon.uf.common.parameter.mapping.ParameterMapper;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotification;
import com.raytheon.uf.common.message.WsId;
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.common.util.mapping.MultipleMappingException;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.site.SiteAwareRegistry;
@ -62,6 +66,10 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
* 01/08/09 1674 bphillip Initial creation
* 11/05/12 #1310 dgilling Modify cache to listen to plugin
* purged topic.
* 01/18/13 #1504 randerso Moved D2D to GFE parameter name translation from
* D2DParmIdCache toGfeIngestNotificationFilter.
* Added code to match wind components and send
* GridUpdateNotifications.
* </pre>
*
* @author bphillip
@ -77,8 +85,19 @@ public class D2DParmIdCache {
private static final Pattern RangeFilter = Pattern
.compile("(.*?)\\d{1,2}hr");
private static final Map<String, String> WIND_COMP_PARMS;
static {
WIND_COMP_PARMS = new HashMap<String, String>();
WIND_COMP_PARMS.put("uw", "vw");
WIND_COMP_PARMS.put("vw", "uw");
WIND_COMP_PARMS.put("ws", "wd");
WIND_COMP_PARMS.put("wd", "ws");
}
/** Map containing the ParmIDs */
private Map<String, Set<String>> parmIds;
private Map<DatabaseID, Set<ParmID>> parmIds;
private Map<ParmID, Set<TimeRange>> windComps;
private static D2DParmIdCache instance;
@ -93,7 +112,8 @@ public class D2DParmIdCache {
* Constructs a new D2DParmIdCache
*/
public D2DParmIdCache() {
parmIds = new HashMap<String, Set<String>>();
parmIds = new HashMap<DatabaseID, Set<ParmID>>();
windComps = new HashMap<ParmID, Set<TimeRange>>();
}
/**
@ -140,53 +160,18 @@ public class D2DParmIdCache {
}
private void putParmIDInternal(ParmID parmId) {
DatabaseID dbId = parmId.getDbId();
synchronized (parmIds) {
Set<ParmID> dbParms = parmIds.get(dbId);
// Add the database entry to the map if it does not exist
if (!parmIds.containsKey(parmId.getDbId().toString())) {
parmIds.put(parmId.getDbId().toString(), new HashSet<String>());
if (dbParms == null) {
dbParms = new HashSet<ParmID>();
parmIds.put(dbId, dbParms);
}
// Insert the ParmID into the map
String parmStr = parmId.toString();
// Ensure that the staticTopo parameter has the correct
// capitalization, or the smart init scripts will not be able to
// find it
String parmName = parmId.getParmName();
if (parmName.equalsIgnoreCase("staticTopo")) {
parmStr = parmStr.replace("statictopo", "staticTopo");
} else if (parmName.equalsIgnoreCase("staticspacing")) {
parmStr = parmStr.replace("staticspacing", "staticSpacing");
} else if (parmName.equalsIgnoreCase("staticXspacing")) {
parmStr = parmStr.replace("staticxspacing", "staticXspacing");
} else if (parmName.equalsIgnoreCase("staticYspacing")) {
parmStr = parmStr.replace("staticyspacing", "staticYspacing");
} else if (parmName.equalsIgnoreCase("staticCoriolis")) {
parmStr = parmStr.replace("staticcoriolis", "staticCoriolis");
} else {
String gfeParamName = null;
try {
gfeParamName = ParameterMapper.getInstance().lookupAlias(
parmId.getParmName(), "gfeParamName");
} catch (MultipleMappingException e) {
statusHandler.handle(Priority.WARN,
e.getLocalizedMessage(), e);
gfeParamName = e.getArbitraryMapping();
}
parmStr = parmStr.replaceFirst(
parmId.getParmName(),
gfeParamName);
}
parmIds.get(parmId.getDbId().toString()).add(parmStr);
}
}
/**
* Places a parmId into the cache
*
* @param parmId
* String representation of a ParmID
*/
public void putParmID(String parmId) {
putParmID(new ParmID(parmId));
// Insert the ParmID into the map
dbParms.add(parmId);
}
}
/**
@ -209,18 +194,10 @@ public class D2DParmIdCache {
* @return The ParmIDs in the given DatabaseID
*/
public List<ParmID> getParmIDs(DatabaseID dbId) {
Set<String> parmStrings = null;
List<ParmID> parms = Collections.emptyList();
synchronized (parmIds) {
if (parmIds.containsKey(dbId.toString())) {
parmStrings = new HashSet<String>(parmIds.get(dbId.toString()));
}
}
List<ParmID> parms = Collections.emptyList();
if (parmStrings != null) {
parms = new ArrayList<ParmID>(parmStrings.size());
for (String parmStr : parmStrings) {
parms.add(new ParmID(parmStr));
parms = new ArrayList<ParmID>(parmIds.get(dbId));
}
}
return parms;
@ -244,14 +221,9 @@ public class D2DParmIdCache {
* @return The list of DatabaseIDs
*/
public List<DatabaseID> getDatabaseIDs() {
Set<String> dbStrs;
List<DatabaseID> dbIds = null;
synchronized (parmIds) {
dbStrs = new HashSet<String>(parmIds.keySet());
}
List<DatabaseID> dbIds = new ArrayList<DatabaseID>(dbStrs.size());
for (String dbId : dbStrs) {
dbIds.add(new DatabaseID(dbId));
dbIds = new ArrayList<DatabaseID>(parmIds.keySet());
}
return dbIds;
}
@ -382,6 +354,19 @@ public class D2DParmIdCache {
for (DatabaseID dbId : dbsToRemove) {
GridParmManager.removeDbFromMap(dbId);
}
// purge the windComps
List<ParmID> wcToRemove = new ArrayList<ParmID>();
synchronized (windComps) {
for (ParmID id : windComps.keySet()) {
if (dbsToRemove.contains(id.getDbId())) {
wcToRemove.add(id);
}
}
for (ParmID id : wcToRemove) {
windComps.remove(id);
}
}
statusHandler.handle(Priority.EVENTA,
"Total time to build D2DParmIdCache for " + siteID
+ " took " + (System.currentTimeMillis() - start)
@ -397,7 +382,7 @@ public class D2DParmIdCache {
public long getSize() {
long size = 0;
synchronized (parmIds) {
for (Set<String> parms : parmIds.values()) {
for (Set<ParmID> parms : parmIds.values()) {
size += parms.size();
}
}
@ -410,4 +395,63 @@ public class D2DParmIdCache {
buildCache(null);
}
}
public void processGridUpdateNotification(GridUpdateNotification gun) {
ParmID parmId = gun.getParmId();
String otherCompName = WIND_COMP_PARMS.get(parmId.getParmName());
if (otherCompName == null) {
// if it's not a wind component just add it to the cache
putParmID(parmId);
} else {
Set<TimeRange> windTrs = null;
synchronized (windComps) {
// add this parms times to windComps map
Set<TimeRange> trs = windComps.get(parmId);
if (trs == null) {
trs = new HashSet<TimeRange>();
windComps.put(parmId, trs);
}
trs.addAll(gun.getHistories().keySet());
// get the other components times
ParmID otherCompId = new ParmID(otherCompName,
parmId.getDbId(), parmId.getParmLevel());
Set<TimeRange> otherTrs = windComps.get(otherCompId);
// if we have both components
if (otherTrs != null) {
// find times where we have both components
windTrs = new HashSet<TimeRange>(trs);
windTrs.retainAll(otherTrs);
// remove the matching times since we don't need them
// anymore
trs.removeAll(windTrs);
otherTrs.removeAll(windTrs);
}
}
// if we found any matching times for both components
if (windTrs != null && !windTrs.isEmpty()) {
// add the wind parmId to the cache
ParmID windId = new ParmID("wind", parmId.getDbId(),
parmId.getParmLevel());
putParmID(windId);
// create GridUpdateNotifications for the wind parm
Map<TimeRange, List<GridDataHistory>> history = new HashMap<TimeRange, List<GridDataHistory>>();
ArrayList<GridUpdateNotification> guns = new ArrayList<GridUpdateNotification>(
windTrs.size());
for (TimeRange tr : windTrs) {
history.put(tr, Arrays.asList(new GridDataHistory(
GridDataHistory.OriginType.INITIALIZED, windId, tr,
null, (WsId) null)));
guns.add(new GridUpdateNotification(windId, tr, history,
null, windId.getDbId().getSiteId()));
}
SendNotifications.send(guns);
}
}
}
}

View file

@ -34,7 +34,9 @@ import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotificatio
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 1/10/09 1674 bphillip Initial creation
* 10/06/09 3172 njensen Based on grib notification
* 10/06/09 3172 njensen Based on grib notification
* 01/18/13 #1504 randerso Changed to send full GridUpdateNotification
* to D2DParmIdCache
*
* </pre>
*
@ -53,8 +55,8 @@ public class D2DParmIdFilter {
public void updateParmIdCache(List<? extends GfeNotification> notifications) {
for (GfeNotification notify : notifications) {
if (notify instanceof GridUpdateNotification) {
D2DParmIdCache.getInstance().putParmID(
((GridUpdateNotification) notify).getParmId());
D2DParmIdCache.getInstance().processGridUpdateNotification(
(GridUpdateNotification) notify);
}
}
}

View file

@ -105,9 +105,11 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
* 08/07/09 #2763 njensen Refactored queryByD2DParmId
* 09/10/12 DR15137 ryu Changed for MOSGuide D2D mxt/mnt grids for consistency
* with A1.
* 10/10/12 #1260 randerso Added check to ensure db can be created before
* 10/10/12 #1260 randerso Added check to ensure db can be created before
* adding it to the inventory
* 12/06/12 #1394 rjpeter Optimized D2D grid access.
* 01/21/12 #1504 randerso Back ported change to use ParameterMapper into 13.1.2
*
* </pre>
*
* @author bphillip
@ -321,13 +323,13 @@ public class GFEDao extends DefaultPluginDao {
}
if (sess != null) {
try {
sess.close();
sess.close();
} catch (Exception e) {
statusHandler.error(
"Error occurred closing database session", e);
}
}
}
}
return failedToSave.toArray(new GFERecord[failedToSave.size()]);
@ -460,9 +462,9 @@ public class GFEDao extends DefaultPluginDao {
dataStore.delete(groupsToDelete);
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
statusHandler.handle(Priority.DEBUG,
"Deleted: " + Arrays.toString(groupsToDelete)
+ " from " + hdf5File.getName());
statusHandler.handle(Priority.DEBUG,
"Deleted: " + Arrays.toString(groupsToDelete)
+ " from " + hdf5File.getName());
}
} catch (Exception e) {
statusHandler.handle(
@ -657,10 +659,10 @@ public class GFEDao extends DefaultPluginDao {
s = getHibernateTemplate().getSessionFactory().openSession();
// TODO: clean up so we only make one db query
SortedMap<DataTime, Integer> rawTimes = queryByD2DParmId(id, s);
List<TimeRange> gribTimes = new ArrayList<TimeRange>();
List<TimeRange> gribTimes = new ArrayList<TimeRange>();
for (DataTime dt : rawTimes.keySet()) {
gribTimes.add(dt.getValidPeriod());
}
}
try {
if (isMos(id)) {
@ -670,26 +672,26 @@ public class GFEDao extends DefaultPluginDao {
.getValidPeriod();
TimeRange time = info.getTimeConstraints()
.constraintTime(gribTime.getEnd());
if (timeRange.getEnd().equals(time.getEnd())
|| !info.getTimeConstraints().anyConstraints()) {
if (timeRange.getEnd().equals(time.getEnd())
|| !info.getTimeConstraints().anyConstraints()) {
GridRecord retVal = (GridRecord) s.get(
GridRecord.class, timeEntry.getValue());
retVal.setPluginName(GridConstants.GRID);
return retVal;
}
retVal.setPluginName(GridConstants.GRID);
return retVal;
}
}
} else if (D2DGridDatabase.isNonAccumDuration(id, gribTimes)) {
for (Map.Entry<DataTime, Integer> timeEntry : rawTimes
.entrySet()) {
TimeRange gribTime = timeEntry.getKey()
.getValidPeriod();
if (timeRange.getStart().equals(gribTime.getEnd())
|| timeRange.equals(gribTime)) {
if (timeRange.getStart().equals(gribTime.getEnd())
|| timeRange.equals(gribTime)) {
GridRecord retVal = (GridRecord) s.get(
GridRecord.class, timeEntry.getValue());
retVal.setPluginName(GridConstants.GRID);
return retVal;
}
retVal.setPluginName(GridConstants.GRID);
return retVal;
}
}
} else {
for (Map.Entry<DataTime, Integer> timeEntry : rawTimes
@ -698,15 +700,15 @@ public class GFEDao extends DefaultPluginDao {
.getValidPeriod();
TimeRange time = info.getTimeConstraints()
.constraintTime(gribTime.getStart());
if ((timeRange.getStart().equals(time.getStart()) || !info
.getTimeConstraints().anyConstraints())) {
if ((timeRange.getStart().equals(time.getStart()) || !info
.getTimeConstraints().anyConstraints())) {
GridRecord retVal = (GridRecord) s.get(
GridRecord.class, timeEntry.getValue());
retVal.setPluginName(GridConstants.GRID);
return retVal;
}
retVal.setPluginName(GridConstants.GRID);
return retVal;
}
}
}
} catch (GfeConfigurationException e) {
throw new DataAccessLayerException(
"Error getting configuration for "
@ -720,7 +722,7 @@ public class GFEDao extends DefaultPluginDao {
statusHandler.error(
"Error occurred closing database session", e);
}
}
}
}
return null;
@ -743,48 +745,48 @@ public class GFEDao extends DefaultPluginDao {
@SuppressWarnings("unchecked")
public SortedMap<DataTime, Integer> queryByD2DParmId(ParmID id, Session s)
throws DataAccessLayerException {
String levelName = GridTranslator.getLevelName(id.getParmLevel());
String levelName = GridTranslator.getLevelName(id.getParmLevel());
double[] levelValues = GridTranslator.getLevelValue(id.getParmLevel());
boolean levelOnePresent = (levelValues[0] != Level
.getInvalidLevelValue());
boolean levelTwoPresent = (levelValues[1] != Level
.getInvalidLevelValue());
Level level = null;
boolean levelOnePresent = (levelValues[0] != Level
.getInvalidLevelValue());
boolean levelTwoPresent = (levelValues[1] != Level
.getInvalidLevelValue());
Level level = null;
// to have a level 2, must have a level one
try {
if (levelOnePresent && levelTwoPresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0], levelValues[1]);
} else if (levelOnePresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0]);
} else {
level = LevelFactory.getInstance().getLevel(levelName, 0.0);
// to have a level 2, must have a level one
try {
if (levelOnePresent && levelTwoPresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0], levelValues[1]);
} else if (levelOnePresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0]);
} else {
level = LevelFactory.getInstance().getLevel(levelName, 0.0);
}
} catch (CommunicationException e) {
logger.error(e.getLocalizedMessage(), e);
}
} catch (CommunicationException e) {
logger.error(e.getLocalizedMessage(), e);
}
if (level == null) {
logger.warn("Unable to query D2D parms, ParmID " + id
+ " does not map to a level");
if (level == null) {
logger.warn("Unable to query D2D parms, ParmID " + id
+ " does not map to a level");
return new TreeMap<DataTime, Integer>();
}
}
SQLQuery modelQuery = s.createSQLQuery(SQL_D2D_GRID_PARM_QUERY);
modelQuery.setLong("level_id", level.getId());
DatabaseID dbId = id.getDbId();
try {
IFPServerConfig config = IFPServerConfigManager
.getServerConfig(dbId.getSiteId());
try {
IFPServerConfig config = IFPServerConfigManager
.getServerConfig(dbId.getSiteId());
modelQuery.setString(GridInfoConstants.DATASET_ID,
config.d2dModelNameMapping(dbId.getModelName()));
} catch (GfeConfigurationException e) {
throw new DataAccessLayerException(
"Error occurred looking up model name mapping", e);
}
} catch (GfeConfigurationException e) {
throw new DataAccessLayerException(
"Error occurred looking up model name mapping", e);
}
String abbreviation = null;
try {
@ -793,38 +795,38 @@ public class GFEDao extends DefaultPluginDao {
} catch (MultipleMappingException e) {
statusHandler.handle(Priority.WARN, e.getLocalizedMessage(), e);
abbreviation = e.getArbitraryMapping();
}
}
abbreviation = abbreviation.toLowerCase();
abbreviation = abbreviation.toLowerCase();
modelQuery.setString("abbrev", abbreviation);
modelQuery.setString("hourAbbrev", abbreviation + "%hr");
List<?> results = modelQuery.list();
Integer modelId = null;
if (results.size() == 0) {
if (results.size() == 0) {
return new TreeMap<DataTime, Integer>();
} else if (results.size() > 1) {
// hours matched, take hour with least number that matches exact
// param
Pattern p = Pattern.compile("^" + abbreviation + "(\\d+)hr$");
int lowestHr = -1;
} else if (results.size() > 1) {
// hours matched, take hour with least number that matches exact
// param
Pattern p = Pattern.compile("^" + abbreviation + "(\\d+)hr$");
int lowestHr = -1;
for (Object[] rows : (List<Object[]>) results) {
String param = ((String) rows[0]).toLowerCase();
if (param.equals(abbreviation) && (lowestHr < 0)) {
if (param.equals(abbreviation) && (lowestHr < 0)) {
modelId = (Integer) rows[1];
} else {
Matcher matcher = p.matcher(param);
if (matcher.matches()) {
int hr = Integer.parseInt(matcher.group(1));
if ((lowestHr < 0) || (hr < lowestHr)) {
} else {
Matcher matcher = p.matcher(param);
if (matcher.matches()) {
int hr = Integer.parseInt(matcher.group(1));
if ((lowestHr < 0) || (hr < lowestHr)) {
modelId = (Integer) rows[1];
lowestHr = hr;
lowestHr = hr;
}
}
}
}
}
} else {
} else {
modelId = (Integer) ((Object[]) results.get(0))[1];
}
}
Query timeQuery = s.createQuery(HQL_D2D_GRID_TIME_QUERY);
timeQuery.setInteger("info_id", modelId);
@ -832,7 +834,7 @@ public class GFEDao extends DefaultPluginDao {
List<Object[]> timeResults = timeQuery.list();
if (timeResults.isEmpty()) {
return new TreeMap<DataTime, Integer>();
}
}
SortedMap<DataTime, Integer> dataTimes = new TreeMap<DataTime, Integer>();
for (Object[] rows : timeResults) {
@ -848,7 +850,7 @@ public class GFEDao extends DefaultPluginDao {
try {
s = getHibernateTemplate().getSessionFactory().openSession();
if (id.getParmName().equalsIgnoreCase("wind")) {
if (id.getParmName().equalsIgnoreCase("wind")) {
String idString = id.toString();
Matcher idWindMatcher = WIND_PATTERN.matcher(idString);
@ -858,53 +860,53 @@ public class GFEDao extends DefaultPluginDao {
List<TimeRange> uTimeList = new ArrayList<TimeRange>(
results.size());
for (DataTime o : results.keySet()) {
uTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
uTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
ParmID vWindId = new ParmID(idWindMatcher.replaceAll("vW"));
results = queryByD2DParmId(vWindId, s);
Set<TimeRange> vTimeList = new HashSet<TimeRange>(
results.size(), 1);
for (DataTime o : results.keySet()) {
vTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
vTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
for (TimeRange tr : uTimeList) {
if (vTimeList.contains(tr)) {
timeList.add(new TimeRange(tr.getStart(), tr.getStart()));
}
for (TimeRange tr : uTimeList) {
if (vTimeList.contains(tr)) {
timeList.add(new TimeRange(tr.getStart(), tr.getStart()));
}
}
if (!timeList.isEmpty()) {
return timeList;
}
if (!timeList.isEmpty()) {
return timeList;
}
ParmID sWindId = new ParmID(idWindMatcher.replaceAll("ws"));
results = queryByD2DParmId(sWindId, s);
List<TimeRange> sTimeList = new ArrayList<TimeRange>(
results.size());
for (DataTime o : results.keySet()) {
sTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
sTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
ParmID dWindId = new ParmID(idWindMatcher.replaceAll("wd"));
results = queryByD2DParmId(dWindId, s);
Set<TimeRange> dTimeList = new HashSet<TimeRange>(
results.size(), 1);
for (DataTime o : results.keySet()) {
dTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
dTimeList.add(new TimeRange(o.getValidPeriod().getStart(),
3600 * 1000));
}
for (TimeRange tr : sTimeList) {
if (dTimeList.contains(tr)) {
timeList.add(new TimeRange(tr.getStart(), tr.getStart()));
}
for (TimeRange tr : sTimeList) {
if (dTimeList.contains(tr)) {
timeList.add(new TimeRange(tr.getStart(), tr.getStart()));
}
} else {
}
} else {
SortedMap<DataTime, Integer> results = queryByD2DParmId(id, s);
if (isMos(id)) {
for (DataTime o : results.keySet()) {
@ -913,10 +915,10 @@ public class GFEDao extends DefaultPluginDao {
}
} else {
for (DataTime o : results.keySet()) {
timeList.add(o.getValidPeriod());
}
timeList.add(o.getValidPeriod());
}
}
}
} finally {
if (s != null) {
try {

View file

@ -21,7 +21,6 @@ package com.raytheon.edex.plugin.gfe.server.notify;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -54,10 +53,13 @@ import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotificatio
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.message.WsId;
import com.raytheon.uf.common.parameter.mapping.ParameterMapper;
import com.raytheon.uf.common.serialization.SerializationUtil;
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.common.time.TimeRange;
import com.raytheon.uf.common.util.mapping.MultipleMappingException;
import com.raytheon.uf.edex.core.EDEXUtil;
/**
@ -71,6 +73,8 @@ import com.raytheon.uf.edex.core.EDEXUtil;
* ------------ ---------- ----------- --------------------------
* Aug 12, 2011 dgilling Initial creation
* Sep 19, 2012 jdynina DR 15442 fix
* Jan 18, 2013 #1504 randerso Moved D2D to GFE parameter name translation from
* D2DParmIdCache to GfeIngestNotificationFilter
*
* </pre>
*
@ -80,7 +84,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
public class GfeIngestNotificationFilter {
private static final transient IUFStatusHandler handler = UFStatus
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GfeIngestNotificationFilter.class);
private SmartInitQueue smartInitQueue = null;
@ -106,8 +110,7 @@ public class GfeIngestNotificationFilter {
}
}
public void filterGridRecords(List<GridRecord> gridRecords,
Date arrivalTime)
public void filterGridRecords(List<GridRecord> gridRecords, Date arrivalTime)
throws Exception {
StringBuilder initNameBuilder = new StringBuilder(120);
@ -126,7 +129,8 @@ public class GfeIngestNotificationFilter {
try {
config = IFPServerConfigManager.getServerConfig(site);
} catch (GfeConfigurationException e) {
handler.error("Unable to retrieve site config for " + site, e);
statusHandler.error("Unable to retrieve site config for "
+ site, e);
continue;
}
for (GridRecord grid : gridRecords) {
@ -152,24 +156,30 @@ public class GfeIngestNotificationFilter {
}
String abbrev = grid.getParameter().getAbbreviation();
String level = GridTranslator.getShortLevelName(
grid
.getLevel().getMasterLevel().getName(), grid
.getLevel().getLevelonevalue(), grid.getLevel()
.getLeveltwovalue());
ParmID parmID = new ParmID(abbrev, dbId, level);
String gfeParmName = null;
try {
gfeParmName = ParameterMapper.getInstance()
.lookupAlias(abbrev, "gfeParamName");
} catch (MultipleMappingException e) {
statusHandler.handle(Priority.WARN,
e.getLocalizedMessage(), e);
gfeParmName = e.getArbitraryMapping();
}
if (!gridInv.containsKey(parmID)) {
gridInv.put(parmID, new ArrayList<TimeRange>());
String level = GridTranslator.getShortLevelName(grid
ParmID parmID = new ParmID(gfeParmName, dbId, level);
List<TimeRange> trs = gridInv.get(parmID);
if (trs == null) {
trs = new ArrayList<TimeRange>();
gridInv.put(parmID, trs);
}
TimeRange validPeriod = grid.getDataTime().getValidPeriod();
if (validPeriod.getDuration() > 0) {
gridInv.get(parmID).add(validPeriod);
trs.add(validPeriod);
} else {
gridInv.get(parmID).add(
new TimeRange(grid.getDataTime()
.getValidPeriod().getStart(),
3600 * 1000));
trs.add(new TimeRange(grid.getDataTime()
.getValidPeriod().getStart(), 3600 * 1000));
}
List<String> siteInitModules = config.initModels(gfeModel);
@ -201,23 +211,20 @@ grid
// DR 15442 - move last for loop out of the for loop at line 110
for (ParmID parmId : gridInv.keySet()) {
Map<TimeRange, List<GridDataHistory>> hist = new HashMap<TimeRange, List<GridDataHistory>>();
try {
List<TimeRange> trs = gridInv.get(parmId);
Collections.sort(trs);
for (TimeRange time : trs) {
List<GridDataHistory> histList = new ArrayList<GridDataHistory>();
histList.add(new GridDataHistory(
GridDataHistory.OriginType.INITIALIZED,
parmId, time, null, (WsId) null));
GridDataHistory.OriginType.INITIALIZED, parmId,
time, null, (WsId) null));
Map<TimeRange, List<GridDataHistory>> hist = new HashMap<TimeRange, List<GridDataHistory>>();
hist.put(time, histList);
guns.add(new GridUpdateNotification(parmId, time, hist,
null, parmId.getDbId().getSiteId()));
}
guns.add(new GridUpdateNotification(parmId,
new TimeRange(trs.get(0).getStart(), trs.get(
trs.size() - 1).getEnd()), hist, null,
parmId.getDbId().getSiteId()));
} catch (Exception e) {
handler.error("Unable to retrieve grid history for "
statusHandler.error("Unable to retrieve grid history for "
+ parmId.toString(), e);
}
}
@ -225,7 +232,8 @@ grid
try {
sendNotifications(guns);
} catch (Exception e) {
handler.error("Unable to send grib ingest notifications", e);
statusHandler.error("Unable to send grib ingest notifications",
e);
}
smartInitQueue.addInits(inits.values());
@ -233,8 +241,7 @@ grid
}
public void filterSatelliteRecords(List<SatelliteRecord> records,
Date arrivalTime)
throws Exception {
Date arrivalTime) throws Exception {
StringBuilder initNameBuilder = new StringBuilder(120);
Set<String> activeSites = GFESiteActivation.getInstance()
@ -249,7 +256,8 @@ grid
try {
config = IFPServerConfigManager.getServerConfig(site);
} catch (GfeConfigurationException e) {
handler.error("Error retrieiving site config for " + site, e);
statusHandler.error(
"Error retrieiving site config for " + site, e);
continue;
}
@ -298,8 +306,8 @@ grid
try {
sendNotifications(guns);
} catch (Exception e) {
handler.error("Unable to send satellite ingest notifications",
e);
statusHandler.error(
"Unable to send satellite ingest notifications", e);
}
smartInitQueue.addInits(inits.values());

View file

@ -62,7 +62,7 @@
<pipeline>
<bean ref="stringToFile" />
<bean ref="satelliteDecoder" method="decode" />
<to uri="directvm:persistIndexAlert" />
<to uri="directvm:persistIndexAlert" />
</pipeline>
<doCatch>
<exception>java.lang.Throwable</exception>

View file

@ -50,6 +50,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdap
* 8/19/09 2899 njensen Rewrote equals() for performance
* 5/08/12 #600 dgilling Implement clone().
* 6/25/12 #766 dgilling Fix isValid().
* 01/18/13 #1504 randerso Removed setters since class should be immutable
*
* </pre>
*
@ -487,42 +488,6 @@ public class DatabaseID implements Serializable, Comparable<DatabaseID>,
return date;
}
public void setSiteId(String siteId) {
this.siteId = siteId;
}
public void setFormat(DataType format) {
this.format = format;
}
public void setFormat(String format) {
if (format.equals("GRID")) {
this.format = DataType.GRID;
} else {
this.format = DataType.NONE;
}
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public void setModelTime(String modelTime) {
this.modelTime = modelTime;
}
public void setModelId(String modelId) {
this.modelId = modelId.intern();
}
public void setShortModelId(String shortModelId) {
this.shortModelId = shortModelId;
}
public Date getModelTimeAsDate() {
if (this.modelTime.equals(NO_MODEL_TIME)) {
return new Date(0);

View file

@ -47,6 +47,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdap
* ------------ ---------- ----------- --------------------------
* 3/6/08 875 bphillip Initial Creation
* 5/8/12 #600 dgilling Implement clone().
* 01/18/13 #1504 randerso Removed setters since class should be immutable
*
* </pre>
*
@ -95,12 +96,7 @@ public class ParmID implements Comparable<ParmID>, Serializable,
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(parmName).append("_");
buffer.append(parmLevel).append(":");
buffer.append(dbId.toString());
return buffer.toString();
return this.parmId;
}
/*
@ -140,7 +136,6 @@ public class ParmID implements Comparable<ParmID>, Serializable,
this.parmName = parmName;
this.parmLevel = defaultLevel();
this.dbId = new DatabaseID(parmModel);
this.compositeName = parmName + "_" + defaultLevel();
encodeIdentifier();
}
@ -158,7 +153,6 @@ public class ParmID implements Comparable<ParmID>, Serializable,
this.parmName = parmName;
this.parmLevel = level;
this.dbId = new DatabaseID(parmModel);
this.compositeName = parmName + "_" + level;
encodeIdentifier();
}
@ -170,7 +164,6 @@ public class ParmID implements Comparable<ParmID>, Serializable,
*/
public ParmID(String parmIdentifier) {
decodeIdentifier(parmIdentifier);
this.compositeName = this.parmName + "_" + this.parmLevel;
encodeIdentifier();
}
@ -186,7 +179,6 @@ public class ParmID implements Comparable<ParmID>, Serializable,
this.parmName = parmName;
this.parmLevel = defaultLevel();
this.dbId = dbId;
this.compositeName = parmName + "_" + defaultLevel();
encodeIdentifier();
}
@ -204,7 +196,6 @@ public class ParmID implements Comparable<ParmID>, Serializable,
this.parmName = parmName;
this.parmLevel = level;
this.dbId = dbId;
this.compositeName = parmName + "_" + level;
encodeIdentifier();
}
@ -333,11 +324,9 @@ public class ParmID implements Comparable<ParmID>, Serializable,
*/
private void encodeIdentifier() {
this.compositeName = this.parmName + "_" + this.parmLevel;
shortParmId = this.compositeName + ":" + dbId.getShortModelId();
if (parmId == null || parmId.length() == 0) {
parmId = this.compositeName + ":" + dbId.getModelId();
}
parmId = this.compositeName + ":" + dbId.getModelId();
}
/**
@ -442,30 +431,6 @@ public class ParmID implements Comparable<ParmID>, Serializable,
return true;
}
public void setParmName(String parmName) {
this.parmName = parmName;
}
public void setParmLevel(String parmLevel) {
this.parmLevel = parmLevel;
}
public void setDbId(DatabaseID dbId) {
this.dbId = dbId;
}
public void setCompositeName(String compositeName) {
this.compositeName = compositeName;
}
public void setShortParmId(String shortParmId) {
this.shortParmId = shortParmId;
}
public void setParmId(String parmId) {
this.parmId = parmId;
}
/*
* (non-Javadoc)
*

View file

@ -48,50 +48,30 @@ class ParmID(object):
else:
self.parmLevel = level
self.compositeName = self.parmName + "_" + self.parmLevel
self.__encodeIdentifier()
elif parmIdentifier is not None:
self.__decodeIdentifier(parmIdentifier)
self.compositeName = self.parmName + "_" + self.parmLevel
self.__encodeIdentifier()
def getParmName(self):
return self.parmName
def setParmName(self, parmName):
self.parmName = parmName
def getParmLevel(self):
return self.parmLevel
def setParmLevel(self, parmLevel):
self.parmLevel = parmLevel
def getDbId(self):
return self.dbId
def setDbId(self, dbId):
self.dbId = dbId
def getCompositeName(self):
return self.compositeName
def setCompositeName(self, compositeName):
self.compositeName = compositeName
def getShortParmId(self):
return self.shortParmId
def setShortParmId(self, shortParmId):
self.shortParmId = shortParmId
def getParmId(self):
return self.parmId
def setParmId(self, parmId):
self.parmId = parmId
def __decodeIdentifier(self, parmIdentifier):
parts = parmIdentifier.split(":")
nameLevel = parts[0].split("_")
@ -104,9 +84,9 @@ class ParmID(object):
self.parmLevel = self.defaultLevel()
def __encodeIdentifier(self):
self.compositeName = self.parmName + "_" + self.parmLevel
self.shortParmId = self.compositeName + ":" + self.dbId.getShortModelId()
if self.parmId is None or len(self.parmId) == 0:
self.parmId = self.compositeName + ":" + self.dbId.getModelId()
self.parmId = self.compositeName + ":" + self.dbId.getModelId()
def isValid(self):
if len(self.parmName) is None or len(self.parmLevel) is None or self.dbId is None: