Omaha #3353 Fix deadlock that freezes cave.

Change-Id: I4afa5c505178f30ada5dd58612b0703ab9529e6b

Former-commit-id: acbde703a2 [formerly 871fa68ddf242f1e63286939b1324fc3197c7336]
Former-commit-id: 398a8d6043
This commit is contained in:
Roger Ferrel 2014-09-30 12:37:13 -05:00
parent 472d9bd206
commit 334b156d2e
3 changed files with 139 additions and 19 deletions

View file

@ -67,6 +67,7 @@ import com.raytheon.uf.common.dataplugin.warning.config.BulletActionGroup;
import com.raytheon.uf.common.dataplugin.warning.config.DialogConfiguration; import com.raytheon.uf.common.dataplugin.warning.config.DialogConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.GridSpacing; import com.raytheon.uf.common.dataplugin.warning.config.GridSpacing;
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration; import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
import com.raytheon.uf.common.dataplugin.warning.gis.GenerateGeospatialDataResult;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData; import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialDataSet; import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialDataSet;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory; import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory;
@ -231,6 +232,7 @@ import com.vividsolutions.jts.io.WKTReader;
* 09/15/2014 3353 rferrel No longer have null parent shell for the GenerateGeoDataSetDialog. * 09/15/2014 3353 rferrel No longer have null parent shell for the GenerateGeoDataSetDialog.
* 09/17/2014 ASM #15465 Qinglu Lin get backupOfficeShort and backupOfficeLoc from backup WFO config.xml, and pop up AlertViz if * 09/17/2014 ASM #15465 Qinglu Lin get backupOfficeShort and backupOfficeLoc from backup WFO config.xml, and pop up AlertViz if
* any of them is missing. * any of them is missing.
* 11/03/2014 3353 rferrel Ignore GeoSpatialData notification when this is the instance layer will do an update.
* </pre> * </pre>
* *
* @author mschenke * @author mschenke
@ -242,13 +244,21 @@ public class WarngenLayer extends AbstractStormTrackResource {
.getHandler(WarngenLayer.class); .getHandler(WarngenLayer.class);
String uniqueFip = null; String uniqueFip = null;
String backupOfficeShort = null; String backupOfficeShort = null;
String backupOfficeLoc = null; String backupOfficeLoc = null;
Map<String, Double> geomArea = new HashMap<String, Double>(); Map<String, Double> geomArea = new HashMap<String, Double>();
Map<String, Point> geomCentroid = new HashMap<String, Point>(); Map<String, Point> geomCentroid = new HashMap<String, Point>();
/**
* Geospatial data generator notifications caused by instance's actions.
* When notification arrives no futher work needs to be done.
*/
private final Set<String> ignoreNotifications = new HashSet<String>();
private static class GeospatialDataList { private static class GeospatialDataList {
private static final String LOCAL_GEOM = "localGeometry"; private static final String LOCAL_GEOM = "localGeometry";
@ -654,21 +664,33 @@ public class WarngenLayer extends AbstractStormTrackResource {
@Override @Override
public void notificationArrived(NotificationMessage[] messages) { public void notificationArrived(NotificationMessage[] messages) {
boolean initWarngen = false;
for (NotificationMessage message : messages) { for (NotificationMessage message : messages) {
try { try {
Object payload = message.getMessagePayload(); Object payload = message.getMessagePayload();
if (payload instanceof String) { if (payload instanceof GenerateGeospatialDataResult) {
System.out GenerateGeospatialDataResult result = (GenerateGeospatialDataResult) payload;
.println("Geometry Metadata has been updated based on " synchronized (warngenLayer.ignoreNotifications) {
+ payload + " shapefile data"); String curKey = result.getArea() + "."
warngenLayer.siteMap.clear(); + result.getSite();
warngenLayer.init(warngenLayer.configuration);
if (warngenLayer.ignoreNotifications
.contains(curKey)) {
warngenLayer.ignoreNotifications.remove(curKey);
} else {
siteMap.remove(curKey);
initWarngen = true;
}
}
} }
} catch (NotificationException e) { } catch (NotificationException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM,
e.printStackTrace(); "Getting notification message's payload", e);
} }
} }
if (initWarngen) {
warngenLayer.init(warngenLayer.configuration);
}
} }
} }
@ -1220,12 +1242,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e); e);
} }
}// end synchronize
customMaps.loadCustomMaps(Arrays.asList(config.getMaps())); customMaps.loadCustomMaps(Arrays.asList(config.getMaps()));
createAreaAndCentroidMaps(); createAreaAndCentroidMaps();
this.configuration = config; this.configuration = config;
}// end synchronize
System.out.println("Total time to init warngen config = " System.out.println("Total time to init warngen config = "
+ (System.currentTimeMillis() - t0) + "ms"); + (System.currentTimeMillis() - t0) + "ms");
} }
@ -1267,6 +1290,16 @@ public class WarngenLayer extends AbstractStormTrackResource {
} else { } else {
// This makes sure dialog exists and is open // This makes sure dialog exists and is open
createDialog(); createDialog();
/*
* Add to list prior to opening the genDialog. That
* way if the notfication arrives prior to or after
* closing the genDialog the notfication will be
* ignored.
*/
synchronized (ignoreNotifications) {
ignoreNotifications.add(currKey);
}
GenerateGeoDataSetDialog genDialog = new GenerateGeoDataSetDialog( GenerateGeoDataSetDialog genDialog = new GenerateGeoDataSetDialog(
dialog.getShell(), site, gmd); dialog.getShell(), site, gmd);
@ -1490,10 +1523,12 @@ public class WarngenLayer extends AbstractStormTrackResource {
boolean shortTag = false; boolean shortTag = false;
boolean locTag = false; boolean locTag = false;
String infoType = null; String infoType = null;
if (backupOfficeShort == null || backupOfficeShort.trim().length() == 0) { if (backupOfficeShort == null
|| backupOfficeShort.trim().length() == 0) {
shortTag = true; shortTag = true;
} }
if (backupOfficeLoc == null || backupOfficeLoc.trim().length() == 0) { if (backupOfficeLoc == null
|| backupOfficeLoc.trim().length() == 0) {
locTag = true; locTag = true;
} }
if (shortTag && locTag) { if (shortTag && locTag) {
@ -1506,8 +1541,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
} }
} }
if (infoType != null) { if (infoType != null) {
statusHandler.handle(Priority.CRITICAL, "Info for " + infoType + " in " + backupSite + statusHandler.handle(Priority.CRITICAL, "Info for "
"'s config.xml is missing."); + infoType + " in " + backupSite
+ "'s config.xml is missing.");
} }
} }
} }
@ -1601,7 +1637,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
public enum GeoFeatureType { public enum GeoFeatureType {
COUNTY("county", "FIPS"), MARINE("marinezones", "ID"); COUNTY("county", "FIPS"), MARINE("marinezones", "ID");
final private String tableName; final private String tableName;
final private String fipsField; final private String fipsField;
private GeoFeatureType(String tableName, String fipsField) { private GeoFeatureType(String tableName, String fipsField) {
this.tableName = tableName; this.tableName = tableName;
this.fipsField = fipsField; this.fipsField = fipsField;
@ -1649,7 +1687,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
else if (type == GeoFeatureType.MARINE) else if (type == GeoFeatureType.MARINE)
templateName = "specialMarineWarning"; templateName = "specialMarineWarning";
else else
throw new IllegalArgumentException("Unsupported geo feature type " + type); throw new IllegalArgumentException(
"Unsupported geo feature type " + type);
WarngenConfiguration config = WarngenConfiguration.loadConfig( WarngenConfiguration config = WarngenConfiguration.loadConfig(
templateName, getLocalizedSite(), null); templateName, getLocalizedSite(), null);
loadGeodataForConfiguration(config); loadGeodataForConfiguration(config);

View file

@ -47,6 +47,7 @@ import com.raytheon.uf.common.dataplugin.warning.config.AreaSourceConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.DialogConfiguration; import com.raytheon.uf.common.dataplugin.warning.config.DialogConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.GeospatialConfiguration; import com.raytheon.uf.common.dataplugin.warning.config.GeospatialConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration; import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
import com.raytheon.uf.common.dataplugin.warning.gis.GenerateGeospatialDataResult;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData; import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialDataSet; import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialDataSet;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory; import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory;
@ -109,6 +110,7 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
* Apr 29, 2014 3033 jsanchez Properly handled site and back up site files. * Apr 29, 2014 3033 jsanchez Properly handled site and back up site files.
* Jul 15, 2014 3352 rferrel Better logging and threading added. * Jul 15, 2014 3352 rferrel Better logging and threading added.
* Aug 21, 2014 3353 rferrel Added getGeospatialTimeset and cluster locking of METADATA_FILE. * Aug 21, 2014 3353 rferrel Added getGeospatialTimeset and cluster locking of METADATA_FILE.
* generateGeoSpatialList now sends GenerateGeospatialDataResult.
* </pre> * </pre>
* *
* @author rjpeter * @author rjpeter
@ -457,12 +459,15 @@ public class GeospatialDataGenerator {
persistGeoData(site, lastRunTimeMap, curTime, dataSet); persistGeoData(site, lastRunTimeMap, curTime, dataSet);
if (updaterEndpoint != null) { if (updaterEndpoint != null) {
GenerateGeospatialDataResult result = new GenerateGeospatialDataResult();
String updatedTimeStamp = getTimeStamp(curTime, String updatedTimeStamp = getTimeStamp(curTime,
lastRunTime); lastRunTime);
result.setTimestamp(updatedTimeStamp);
result.setSite(site);
result.setArea(metaData.getAreaSource());
try { try {
EDEXUtil.getMessageProducer().sendAsync( EDEXUtil.getMessageProducer().sendAsync(
updaterEndpoint, updatedTimeStamp); updaterEndpoint, result);
} catch (EdexException e) { } catch (EdexException e) {
statusHandler.error("Could not send message to " statusHandler.error("Could not send message to "
+ updaterEndpoint, e); + updaterEndpoint, e);

View file

@ -0,0 +1,76 @@
/**
* 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.
**/
package com.raytheon.uf.common.dataplugin.warning.gis;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* The results from a GenerateGeospatialDataRequest.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 3, 2014 3353 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
@DynamicSerialize
public class GenerateGeospatialDataResult {
@DynamicSerializeElement
private String timestamp;
@DynamicSerializeElement
private String site;
@DynamicSerializeElement
private String area;
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
}