From b8542c13325052dcb54191339ba2383f7b5b2604 Mon Sep 17 00:00:00 2001 From: David Friedman Date: Wed, 11 Jun 2014 13:37:16 +0000 Subject: [PATCH] ASM #604 - Lightning display varies depending how long CAVE has been open Change-Id: Id85b87e21833ef00e80693b8526d976ccb4bb63e Former-commit-id: a3f4fd6537f3847011e199e0f043968d9f595937 --- .../viz/lightning/LightningResource.java | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java index 9604088b04..9a916822ce 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java @@ -93,6 +93,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability; * Sep 4, 2012 15335 kshresth Will now display lightning/wind * fields when magnification set to 0 * Feb 27, 2013 DCS 152 jgerth/elau Support for WWLLN and multiple sources + * Jun 6, 2014 DR 17367 D. Friedman Fix cache object usage. * * * @@ -479,6 +480,24 @@ public class LightningResource extends */ @Override public void remove(DataTime dataTime) { + /* + * Workaround for time matching which does not know about records at the + * end of a time period that may contain data for the next period. If we + * are asked to remove the latest data time and there is only one record + * we know about, return without removing the time. + */ + if (dataTimes.indexOf(dataTime) == dataTimes.size() - 1) { + CacheObject co = cacheObjectMap.get(dataTime); + if (co != null) { + LightningFrameMetadata metadata = co.getMetadata(); + synchronized (metadata) { + if (metadata.newRecords.size() + metadata.processed.size() < 2) { + return; + } + } + } + } + dataTimes.remove(dataTime); cacheObjectMap.remove(dataTime); } @@ -522,20 +541,20 @@ public class LightningResource extends List records = entry.getValue(); - CacheObject co = cacheObjectMap - .get(dt); LightningFrameMetadata frame; - if (co == null) { - // New frame - frame = new LightningFrameMetadata(dt, - resourceData.getBinOffset(), this.lightSource); - co = CacheObject.newCacheObject(frame, resourceBuilder); - cacheObjectMap.put(dt, co); - dataTimes.add(dt); - } else { - // Frame exists - frame = co.getMetadata(); + CacheObject co; + synchronized (cacheObjectMap) { + co = cacheObjectMap.get(dt); + if (co == null) { + // New frame + LightningFrameMetadata key = new LightningFrameMetadata(dt, + resourceData.getBinOffset(), this.lightSource); + co = CacheObject.newCacheObject(key, resourceBuilder); + cacheObjectMap.put(dt, co); + dataTimes.add(dt); + } } + frame = co.getMetadata(); synchronized (frame) { // Add as new records