diff --git a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java
index bea147d247..8d4fc4de2c 100644
--- a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java
+++ b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java
@@ -37,11 +37,11 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* Implementation of a colormap
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2007 chammack Initial Creation.
@@ -50,9 +50,10 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
* Aug 20, 2008 dglazesk Added some interface pieces to make this more
* usable
* Jan 10, 2013 15648 ryu Added removeDuplicates() method.
- *
+ * Apr 18, 2013 1920 mpduff Default changed to true.
+ *
*
- *
+ *
* @author chammack
* @version 1
*/
@@ -67,7 +68,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
private Buffer glBuffer;
- private boolean changed = false;
+ private boolean changed = true;
/**
* Constructor used by JiBX
@@ -97,7 +98,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/**
* Creates a ColorMap using name and the list of colors in map.
- *
+ *
* @param name
* Name for the new ColorMap
* @param map
@@ -107,12 +108,11 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
this.name = name;
colors = new ArrayList();
colors.addAll(map.getColors());
- this.changed = true;
}
/**
* Do not instantiate directly, use GLTarget methods
- *
+ *
* @param name
* @param red
* @param green
@@ -139,9 +139,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.uf.common.colormap.IColorMap#getBlue()
*/
+ @Override
public float[] getBlue() {
int colorNum = colors.size();
float[] blues = new float[colorNum];
@@ -153,9 +154,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.uf.common.colormap.IColorMap#getGreen()
*/
+ @Override
public float[] getGreen() {
int colorNum = colors.size();
float[] greens = new float[colorNum];
@@ -167,9 +169,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.uf.common.colormap.IColorMap#getRed()
*/
+ @Override
public float[] getRed() {
int colorNum = colors.size();
float[] reds = new float[colorNum];
@@ -181,18 +184,20 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.uf.common.colormap.IColorMap#getSize()
*/
+ @Override
public int getSize() {
return colors.size();
}
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.uf.common.colormap.IColorMap#getAlpha()
*/
+ @Override
public float[] getAlpha() {
int colorNum = colors.size();
float[] alphas = new float[colorNum];
@@ -204,7 +209,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/**
* Return the buffer representation of the colormap
- *
+ *
* @return the colorMap buffer
*/
public synchronized Buffer getColorMap() {
@@ -233,20 +238,22 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.edex.colormap.IColorMap#getName()
*/
+ @Override
public String getName() {
return name;
}
+ @Override
public List getColors() {
return colors;
}
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#toString()
*/
@Override
@@ -254,10 +261,12 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
return "COLORMAP { " + getName() + " }";
}
+ @Override
public boolean isChanged() {
return changed;
}
+ @Override
public void setAlpha(float[] anAlpha) {
int size = anAlpha.length;
for (int i = 0; i < size; ++i) {
@@ -270,6 +279,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
changed = true;
}
+ @Override
public void setBlue(float[] aBlue) {
int size = aBlue.length;
for (int i = 0; i < size; ++i) {
@@ -282,6 +292,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
changed = true;
}
+ @Override
public void setGreen(float[] aGreen) {
int size = aGreen.length;
for (int i = 0; i < size; ++i) {
@@ -294,6 +305,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
changed = true;
}
+ @Override
public void setRed(float[] aRed) {
int size = aRed.length;
for (int i = 0; i < size; ++i) {
@@ -310,10 +322,12 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
this.colors.set(index, color);
}
+ @Override
public void setChanged(boolean aChanged) {
changed = aChanged;
}
+ @Override
public void setName(String aName) {
name = aName;
changed = true;
@@ -329,7 +343,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
* wavelength to the maximum wavelength. If the reverse flag is set, then a
* reverse spectrum is generated. The red, green, and blue indexes are
* returned through the calling arguments.
- *
+ *
* @param numOfColors
* @param minWaveLength
* @param maxWaveLength
@@ -416,10 +430,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject {
public void removeDuplicates() {
List colors = new ArrayList();
Color current = null;
- for (Color color: this.colors) {
+ for (Color color : this.colors) {
if (!color.equals(current)) {
- colors.add(color);
- current = color;
+ colors.add(color);
+ current = color;
}
}
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java
index e69744a471..fba5e152cc 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java
@@ -31,6 +31,7 @@ import javax.persistence.Transient;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
+import com.raytheon.uf.common.time.util.ImmutableDate;
/**
* FFMP basin/aggregated value holder
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPCacheRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPCacheRecord.java
deleted file mode 100644
index bccf12b826..0000000000
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPCacheRecord.java
+++ /dev/null
@@ -1,572 +0,0 @@
-package com.raytheon.uf.common.dataplugin.ffmp;
-/**
- * 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.
- **/
-
-import java.awt.Point;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Map.Entry;
-
-import com.raytheon.uf.common.cache.CacheException;
-import com.raytheon.uf.common.cache.CacheFactory;
-import com.raytheon.uf.common.cache.ICache;
-import com.raytheon.uf.common.cache.disk.DiskCache;
-import com.raytheon.uf.common.datastorage.IDataStore;
-import com.raytheon.uf.common.datastorage.Request;
-import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
-import com.raytheon.uf.common.datastorage.records.IDataRecord;
-import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager;
-import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.SOURCE_TYPE;
-import com.raytheon.uf.common.monitor.xml.DomainXML;
-import com.raytheon.uf.common.monitor.xml.SourceXML;
-import com.raytheon.uf.common.status.IUFStatusHandler;
-import com.raytheon.uf.common.status.UFStatus;
-import com.raytheon.uf.common.status.UFStatus.Priority;
-
-/**
- * Cache coherent record
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * 05/24/12 632 D. Hladky Initial release
- *
- *
- *
- * @author dhladky
- * @version 1
- */
-
-public class FFMPCacheRecord extends FFMPRecord {
-
- private final String sourceCacheName;
-
- private final String cacheName;
-
- private final String cacheDir;
-
- private ArrayList hucs = new ArrayList();
-
- //private static final boolean useCache = !Boolean
- // .getBoolean("com.raytheon.uf.common.ffmp.disableCache");
- private static final boolean useCache = false;
-
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(FFMPCacheRecord.class);
-
-
- /**
- * Public constructor
- * @param rec
- * @param sourceCacheName
- * @param cacheDir
- */
- public FFMPCacheRecord(FFMPRecord rec, String sourceCacheName, String cacheDir) {
-
- this.setSiteKey(rec.getSiteKey());
- this.setWfo(rec.getWfo());
- this.setDataKey(rec.getDataKey());
- this.setSourceName(rec.getSourceName());
- this.setPluginName(rec.getPluginName());
- this.sourceCacheName = sourceCacheName;
- this.cacheName = "FFMP-" + getWfo() + "-" + getSiteKey() + "-" +getDataKey()+ "-"
- + getSourceCacheName();
- // set a default value
- if (cacheDir == null) {
- cacheDir = "/tmp";
- }
- this.cacheDir = cacheDir;
- }
-
- public String getSourceCacheName() {
- return sourceCacheName;
- }
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @SuppressWarnings({ "unchecked" })
- private DiskCache getCache() {
-
- DiskCache diskCache = null;
- CacheFactory cf = CacheFactory.getInstance();
- try {
- diskCache = (DiskCache) cf.getCache(this.cacheName);
- } catch (CacheException e) {
- synchronized (this) {
- // make sure not done on another thread
- try {
- diskCache = (DiskCache) cf
- .getCache(this.cacheName);
- } catch (CacheException e1) {
- diskCache = createCache(this.cacheName);
- CacheFactory.getInstance().addCache(this.cacheName,
- diskCache);
- }
- }
- }
-
- return diskCache;
- }
- /**
- * Get BasinData Map from cache
- *
- * @param siteKey
- * @param sourceName
- * @return
- */
- @Override
- public FFMPBasinData getBasinData(String hucName) {
- return getBasinData(hucName, false);
- }
-
- /**
- * Get BasinData Map from cache
- *
- * @param siteKey
- * @param sourceName
- * @return
- */
- public FFMPBasinData getBasinData(String hucName, boolean lock) {
- FFMPBasinData basins = null;
-
- if (hucName != null) {
- if (useCache) {
- try {
-
- DiskCache diskCache = getCache();
- basins = (FFMPBasinData) diskCache.getFromCache(hucName, lock);
-
- if (basins == null) {
- basins = new FFMPBasinData(hucName);
- if (!hucs.contains(hucName)) {
- hucs.add(hucName);
- }
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- } else {
- basins = super.getBasinData(hucName);
- }
- }
-
- return basins;
- }
-
-
- /**
- * Create cache objects if needed
- *
- * @param siteKey
- * @return
- */
- private DiskCache createCache(String name) {
- ICache cache = new DiskCache();
- DiskCache dc = (DiskCache) cache;
- dc.setName(name);
- dc.setBaseCacheDir(getCacheDir());
- dc.setSizeMemCacheMap(2); // For FFMP hold two generally COUNTY and ALL
- dc.activateCache();
-
- return dc;
- }
-
- /**
- * Set source record to cache
- *
- * @param siteKey
- * @param sourceName
- * @param record
- */
- @Override
- public void setBasinData(FFMPBasinData basins, String hucName) {
- if (hucName != null) {
- if (useCache) {
- try {
- synchronized (basins) {
- DiskCache diskCache = getCache();
-
- try {
- diskCache.addToCache(hucName, basins);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- super.setBasinData(basins, hucName);
- }
- }
- }
-
- /**
- * Cache File reader
- *
- * @param basins
- * @param hucName
- */
- public void setCacheData(FFMPBasinData basins, String hucName) {
- if (getBasinData(hucName) != null) {
-
- basins = getBasinData(hucName, true);
- //System.out.println("Adding Cache Data: "+hucName+" "+getSourceName());
-
- synchronized (basins) {
- for (Entry entry : basins.getBasins()
- .entrySet()) {
- FFMPBasin basin = basins.get(entry.getKey());
- if (basin != null) {
- if (basin instanceof FFMPGuidanceBasin) {
- FFMPGuidanceBasin gbasin = (FFMPGuidanceBasin) basin;
- gbasin.getGuidValues().putAll(
- ((FFMPGuidanceBasin) entry.getValue())
- .getGuidValues());
- } else {
- basin.getValues().putAll(
- entry.getValue().getValues());
- }
- } else {
- basins.put(entry.getKey(), entry.getValue());
- }
- }
- }
-
- setBasinData(basins, hucName);
-
- } else {
- setBasinData(basins, hucName);
- //System.out.println("Adding Whole Object Buddy Data: "+hucName+" "+getSourceName());
- }
- }
-
- /**
- * Gets the Hash out of the datastore by HUC
- *
- * @param dataStore
- * @param huc
- */
- public void retrieveMapFromDataStore(IDataStore dataStore, String uri,
- FFMPTemplates template, String huc, Date date, String sourceName)
- throws Exception {
-
- FFMPBasinData fbd = null;
-
- boolean aggregate = true;
-
- if (huc.equals("ALL")) {
- aggregate = false;
- }
-
- fbd = getBasinData(huc, true);
- String key = getSiteKey();
-
- synchronized (template) {
-
- SourceXML source = FFMPSourceConfigurationManager.getInstance()
- .getSource(sourceName);
-
- for (DomainXML domain : template.getDomains()) {
- LinkedHashMap map = template.getMap(key,
- domain.getCwa(), huc);
-
- if (map != null && map.keySet().size() > 0) {
-
- IDataRecord rec = null;
-
- try {
- rec = dataStore.retrieve(uri + "/" + domain.getCwa(),
- huc, Request.ALL);
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM,
- "FFMPRecord: no data record for: " + uri + "/"
- + domain.getCwa());
- }
-
- if (rec != null) {
- float[] values = ((FloatDataRecord) rec).getFloatData();
-
- int j = 0;
- if (values != null) {
- // System.err.println(sourceName);
- if (source.getSourceType().equals(
- SOURCE_TYPE.GUIDANCE.getSourceType())) {
- for (Long pfaf : map.keySet()) {
- try {
- FFMPGuidanceBasin basin = (FFMPGuidanceBasin) fbd
- .get(pfaf);
-
- if (basin == null) {
- basin = new FFMPGuidanceBasin(pfaf,
- aggregate);
- fbd.put(pfaf, basin);
- }
-
- if (basin.containsKey(date, sourceName)) {
- if (basin
- .getValue(date, sourceName) == FFMPUtils.MISSING
- || basin.getValue(date,
- sourceName).isNaN()) {
-
- float curval = basin.getValue(
- date, sourceName);
-
- if (curval >= 0.0f
- && values[j] >= 0.0f) {
- basin.setValue(sourceName,
- date, (curval + values[j])/ 2);
- } else {
- basin.setValue(sourceName,
- date, values[j]);
- }
-
- }
- } else {
- basin.setValue(sourceName, date,
- values[j]);
- }
-
- j++;
- } catch (Exception e) {
- break;
- }
-
- }
- } else {
- for (Long pfaf : map.keySet()) {
- try {
- FFMPBasin basin = fbd.get(pfaf);
- if (basin == null) {
- basin = new FFMPBasin(pfaf,
- aggregate);
- fbd.put(pfaf, basin);
- }
-
- if (basin.contains(date)) {
- float curval = basin.getValue(date);
- if (curval >= 0.0f
- && values[j] >= 0.0f) {
- basin.setValue(date, (curval + values[j]) / 2);
- } else {
- basin.setValue(date, values[j]);
- }
- } else {
- basin.setValue(date, values[j]);
- }
- j++;
- } catch (Exception e) {
- break;
- }
- }
- }
- }
- }
- }
- }
- }
-
- setBasinData(fbd, huc);
- }
-
- /**
- * Gets a single basin out of the dataStore
- *
- * @param dataStore
- * @param huc
- */
- public void retrieveBasinFromDataStore(IDataStore dataStore, String uri,
- FFMPTemplates template, String huc, Date date, String sourceName,
- FFMPBasin basin) {
-
- FFMPBasinData fbd = null;
-
- try {
-
- SourceXML source = FFMPSourceConfigurationManager.getInstance()
- .getSource(sourceName);
- Long pfaf = basin.getPfaf();
- fbd = getBasinData("ALL", true);
-
- synchronized (template) {
-
- for (DomainXML domain : template.getDomains()) {
-
- LinkedHashMap map = template.getMap(getSiteKey(),
- domain.getCwa(), huc);
-
- if (map != null && map.get(pfaf) != null) {
-
- int index = 0;
- for (Long pfafToCheck : map.keySet()) {
- if (pfafToCheck.equals(pfaf)) {
- break;
- }
- index++;
- }
-
- try {
- IDataRecord rec = dataStore.retrieve(uri + "/"
- + domain.getCwa(), huc, Request
- .buildPointRequest(new Point(index, 0)));
-
- if (rec != null) {
- float[] values = ((FloatDataRecord) rec)
- .getFloatData();
-
- boolean isFFG = false;
-
- if (source.getSourceType().equals(
- SOURCE_TYPE.GUIDANCE.getSourceType())) {
- isFFG = true;
- }
-
- if (values != null) {
- // System.err.println(sourceName);
- if (isFFG) {
- ((FFMPGuidanceBasin) basin).setValue(
- sourceName, date, values[0]);
- } else {
- basin.setValue(date, values[0]);
- }
- }
- }
- } catch (Throwable e) {
- statusHandler.handle(Priority.PROBLEM,
- "ERROR Retrieving Map for URI: " + uri
- + "..." + huc, e);
- }
- }
- }
- }
-
- setBasinData(fbd, "ALL");
-
- } catch (Exception e) {
- statusHandler.handle(Priority.ERROR, "ERROR Retrieving HUC..."
- + huc);
- }
- }
-
-
- /**
- * Gets the Virtual Hash out of the datastore by HUC
- *
- * @param dataStore
- * @param huc
- */
- public void retrieveVirtualBasinFromDataStore(IDataStore dataStore,
- String uri, FFMPTemplates template, Date date, FFMPBasin basin) {
- FFMPBasinData fbd = null;
- try {
- boolean aggregate = false;
- fbd = getBasinData("ALL", true);
- String key = getDataKey();
-
- for (DomainXML domain : template.getDomains()) {
-
- LinkedHashMap lids = template
- .getVirtualGageBasins(key, domain.getCwa());
- int size = lids.size();
-
- if (size > 0) {
- try {
- IDataRecord rec = dataStore
- .retrieve(uri + "/" + domain.getCwa(), "ALL",
- Request.ALL);
-
- if (rec != null) {
- float[] values = ((FloatDataRecord) rec)
- .getFloatData();
- if (values != null) {
- int j = 0;
-
- for (Entry entry : lids
- .entrySet()) {
- FFMPVirtualGageBasinMetaData fvgbmd = entry
- .getValue();
- FFMPVirtualGageBasin vgbasin = (FFMPVirtualGageBasin) fbd
- .get(fvgbmd.getLookupId());
- if (vgbasin == null) {
- vgbasin = new FFMPVirtualGageBasin(
- fvgbmd.getLid(),
- fvgbmd.getLookupId(), aggregate);
- fbd.put(fvgbmd.getLookupId(), vgbasin);
- }
- vgbasin.setValue(date, values[j]);
- j++;
- }
- }
- }
- }
-
- catch (Throwable e) {
- statusHandler.handle(
- Priority.PROBLEM,
- "ERROR Retrieving Virtual ..."
- + domain.getCwa() + " : " + "ALL");
- }
- }
- }
-
- setBasinData(fbd, "ALL");
-
- } catch (Throwable e) {
- statusHandler.handle(Priority.ERROR, "ERROR Retrieving Virtual..."
- + "ALL");
- }
- }
-
-
- /**
- * Purges out old data
- *
- * @param date
- */
- public void purgeData(Date date) {
- for (String ihuc : hucs) {
- FFMPBasinData basinData = getBasinData(ihuc, true);
- basinData.purgeData(date);
- setBasinData(basinData, ihuc);
- }
- }
-
- /**
- * Dump cache
- */
- public void closeCache() {
- getCache().closeCache();
- }
-
- public String getCacheDir() {
- return cacheDir;
- }
-
-}
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java
index 399dd1c9fe..bbb8692a15 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java
@@ -22,11 +22,14 @@ package com.raytheon.uf.common.dataplugin.ffmp;
import java.awt.Point;
import java.io.File;
import java.io.FileNotFoundException;
+import java.lang.ref.WeakReference;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -37,6 +40,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+
import org.hibernate.annotations.Index;
import com.raytheon.uf.common.dataplugin.IDecoderGettable;
@@ -57,6 +61,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
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.util.ImmutableDate;
/**
* Record implementation for FFMP plugin
@@ -72,6 +77,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Feb 28, 2013 1729 dhladky Supressed un-necessary debug loggers
* Apr 4, 2013 1846 bkowal Added an index on refTime and forecastTime
* Apr 8, 2013 1293 bkowal Removed references to hdffileid.
+ * April, 9 2013 1890 dhladky Moved dates to referenced map in record rather than multiple dates in FFMPBasin objs.
*
*
*
@@ -131,6 +137,8 @@ public class FFMPRecord extends PersistablePluginDataObject
@Transient
private boolean isRate = false;
+
+ protected static ConcurrentMap> cacheTimes = new ConcurrentHashMap>();
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(FFMPRecord.class);
@@ -384,103 +392,96 @@ public class FFMPRecord extends PersistablePluginDataObject
}
fbd = getBasinData(huc);
+ ImmutableDate idate = getCacheDate(date);
- synchronized (template) {
+ SourceXML source = FFMPSourceConfigurationManager.getInstance()
+ .getSource(sourceName);
- SourceXML source = FFMPSourceConfigurationManager.getInstance()
- .getSource(sourceName);
+ for (DomainXML domain : template.getDomains()) {
- for (DomainXML domain : template.getDomains()) {
- LinkedHashMap map = template.getMap(getSiteKey(),
- domain.getCwa(), huc);
+ LinkedHashMap map = template.getMap(getSiteKey(), domain.getCwa(), huc);
- if (map != null && map.keySet().size() > 0) {
+ if (map != null && !map.isEmpty()) {
- IDataRecord rec = null;
+ IDataRecord rec = null;
- try {
- rec = dataStore.retrieve(uri + "/" + domain.getCwa(),
- huc, Request.ALL);
- } catch (Exception e) {
- statusHandler.handle(Priority.DEBUG,
- "FFMPRecord: no data record for: " + uri + "/"
- + domain.getCwa());
- }
+ try {
+ rec = dataStore.retrieve(uri + "/" + domain.getCwa(), huc,
+ Request.ALL);
+ } catch (Exception e) {
+ statusHandler.handle(Priority.DEBUG,
+ "FFMPRecord: no data record for: " + uri + "/"
+ + domain.getCwa());
+ }
- if (rec != null) {
- float[] values = ((FloatDataRecord) rec).getFloatData();
+ if (rec != null) {
+ float[] values = ((FloatDataRecord) rec).getFloatData();
- int j = 0;
- if (values != null) {
- // System.err.println(sourceName);
- if (source.getSourceType().equals(
- SOURCE_TYPE.GUIDANCE.getSourceType())) {
- for (Long pfaf : map.keySet()) {
- try {
- FFMPGuidanceBasin basin = (FFMPGuidanceBasin) fbd
- .get(pfaf);
+ int j = 0;
+ if (values != null) {
+ // System.err.println(sourceName);
+ if (source.getSourceType().equals(
+ SOURCE_TYPE.GUIDANCE.getSourceType())) {
+ for (Long pfaf : map.keySet()) {
+ try {
+ FFMPGuidanceBasin basin = (FFMPGuidanceBasin) fbd
+ .get(pfaf);
- if (basin == null) {
- basin = new FFMPGuidanceBasin(pfaf,
- aggregate);
- fbd.put(pfaf, basin);
- }
+ if (basin == null) {
+ basin = new FFMPGuidanceBasin(pfaf,
+ aggregate);
+ fbd.put(pfaf, basin);
+ }
- if (basin.containsKey(date, sourceName)) {
- if (basin
- .getValue(date, sourceName) == FFMPUtils.MISSING
- || basin.getValue(date,
- sourceName).isNaN()) {
+ Float curval = basin.getValue(idate,
+ sourceName);
- float curval = basin.getValue(
- date, sourceName);
+ if (curval != FFMPUtils.MISSING
+ || !curval.isNaN()) {
- if (curval >= 0.0f
- && values[j] >= 0.0f) {
- basin.setValue(sourceName,
- date, (curval + values[j])/ 2);
- } else {
- basin.setValue(sourceName,
- date, values[j]);
- }
-
- }
- } else {
- basin.setValue(sourceName, date,
+ if (curval >= 0.0f && values[j] >= 0.0f) {
+ basin.setValue(sourceName, idate,
+ (curval + values[j]) / 2);
+ } else if (values[j] >= 0.0f){
+ basin.setValue(sourceName, idate,
values[j]);
- }
-
- j++;
- } catch (Exception e) {
- break;
+ }
+ // do not overwrite original value
+ } else {
+ basin.setValue(sourceName, idate,
+ values[j]);
}
+ j++;
+ } catch (Exception e) {
+ break;
}
- } else {
- for (Long pfaf : map.keySet()) {
- try {
- FFMPBasin basin = fbd.get(pfaf);
- if (basin == null) {
- basin = new FFMPBasin(pfaf,
- aggregate);
- fbd.put(pfaf, basin);
- }
- if (basin.contains(date)) {
- float curval = basin.getValue(date);
- if (curval >= 0.0f
- && values[j] >= 0.0f) {
- basin.setValue(date, (curval + values[j])/ 2);;
- } else {
- basin.setValue(date, values[j]);
- }
- } else {
- basin.setValue(date, values[j]);
- }
- j++;
- } catch (Exception e) {
- break;
+ }
+ } else {
+ for (Long pfaf : map.keySet()) {
+ try {
+ FFMPBasin basin = fbd.get(pfaf);
+ if (basin == null) {
+ basin = new FFMPBasin(pfaf, aggregate);
+ fbd.put(pfaf, basin);
}
+
+ if (basin.contains(idate)) {
+ float curval = basin.getValue(idate);
+ if (curval >= 0.0f && values[j] >= 0.0f) {
+ basin.setValue(idate,
+ (curval + values[j]) / 2);
+ } else if (values[j] >= 0.0f) {
+ basin.setValue(idate, values[j]);
+ } // do not overwrite original value
+ } else {
+ // no value at time exists, write regardless
+ basin.setValue(idate, values[j]);
+ }
+ j++;
+ } catch (Exception e) {
+ break;
}
}
}
@@ -488,6 +489,7 @@ public class FFMPRecord extends PersistablePluginDataObject
}
}
}
+
}
/**
@@ -504,58 +506,57 @@ public class FFMPRecord extends PersistablePluginDataObject
SourceXML source = FFMPSourceConfigurationManager.getInstance()
.getSource(sourceName);
Long pfaf = basin.getPfaf();
+ ImmutableDate idate = getCacheDate(date);
- synchronized (template) {
+ for (DomainXML domain : template.getDomains()) {
- for (DomainXML domain : template.getDomains()) {
+ LinkedHashMap map = template.getMap(getSiteKey(),
+ domain.getCwa(), huc);
- LinkedHashMap map = template.getMap(getSiteKey(),
- domain.getCwa(), huc);
+ if (map != null && map.get(pfaf) != null) {
- if (map != null && map.get(pfaf) != null) {
-
- int index = 0;
- for (Long pfafToCheck : map.keySet()) {
- if (pfafToCheck.equals(pfaf)) {
- break;
- }
- index++;
+ int index = 0;
+ for (Long pfafToCheck : map.keySet()) {
+ if (pfafToCheck.equals(pfaf)) {
+ break;
}
+ index++;
+ }
- try {
- IDataRecord rec = dataStore.retrieve(uri + "/"
- + domain.getCwa(), huc, Request
- .buildPointRequest(new Point(index, 0)));
+ try {
+ IDataRecord rec = dataStore.retrieve(
+ uri + "/" + domain.getCwa(), huc,
+ Request.buildPointRequest(new Point(index, 0)));
- if (rec != null) {
- float[] values = ((FloatDataRecord) rec)
- .getFloatData();
+ if (rec != null) {
+ float[] values = ((FloatDataRecord) rec)
+ .getFloatData();
- boolean isFFG = false;
+ boolean isFFG = false;
- if (source.getSourceType().equals(
- SOURCE_TYPE.GUIDANCE.getSourceType())) {
- isFFG = true;
- }
+ if (source.getSourceType().equals(
+ SOURCE_TYPE.GUIDANCE.getSourceType())) {
+ isFFG = true;
+ }
- if (values != null) {
- // System.err.println(sourceName);
- if (isFFG) {
- ((FFMPGuidanceBasin) basin).setValue(
- sourceName, date, values[0]);
- } else {
- basin.setValue(date, values[0]);
- }
+ if (values != null) {
+ // System.err.println(sourceName);
+ if (isFFG) {
+ ((FFMPGuidanceBasin) basin).setValue(
+ sourceName, idate, values[0]);
+ } else {
+ basin.setValue(idate, values[0]);
}
}
- } catch (Throwable e) {
- statusHandler.handle(Priority.PROBLEM,
- "ERROR Retrieving Map for URI: " + uri
- + "..." + huc);
}
+ } catch (Throwable e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "ERROR Retrieving Map for URI: " + uri + "..."
+ + huc);
}
}
}
+
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "ERROR Retrieving HUC..."
+ huc);
@@ -575,56 +576,54 @@ public class FFMPRecord extends PersistablePluginDataObject
boolean aggregate = false;
fbd = getBasinData(ALL);
String key = getDataKey();
+ ImmutableDate idate = getCacheDate(date);
- synchronized (template) {
+ for (DomainXML domain : template.getDomains()) {
- for (DomainXML domain : template.getDomains()) {
+ LinkedHashMap lids = template
+ .getVirtualGageBasins(key, domain.getCwa());
- LinkedHashMap lids = template
- .getVirtualGageBasins(key, domain.getCwa());
+ if (lids != null) {
+ int size = lids.size();
- if (lids != null) {
- int size = lids.size();
+ if (size > 0) {
- if (size > 0) {
+ IDataRecord rec = null;
- IDataRecord rec = null;
-
- try {
- rec = dataStore.retrieve(
- uri + "/" + domain.getCwa(), ALL,
- Request.ALL);
- } catch (Exception e) {
- // This is a routine error. Sometimes you can not have data for a configured source
- // This suppresses spurrious messages that would inflate the loags needlessly.
- if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
- statusHandler.handle(Priority.DEBUG,
- "FFMPRecord: no data for: " + uri + "/"
- + domain.getCwa());
- }
+ try {
+ rec = dataStore.retrieve(uri + "/" + domain.getCwa(),
+ ALL, Request.ALL);
+ } catch (Exception e) {
+ // This is a routine error. Sometimes you can not have
+ // data for a configured source
+ // This suppresses spurrious messages that would inflate
+ // the loags needlessly.
+ if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
+ statusHandler.handle(Priority.DEBUG,
+ "FFMPRecord: no data for: " + uri + "/"
+ + domain.getCwa());
}
+ }
- if (rec != null) {
- float[] values = ((FloatDataRecord) rec)
- .getFloatData();
- if (values != null) {
- int j = 0;
+ if (rec != null) {
+ float[] values = ((FloatDataRecord) rec).getFloatData();
+ if (values != null) {
+ int j = 0;
- for (Entry entry : lids
- .entrySet()) {
- FFMPVirtualGageBasinMetaData fvgbmd = entry
- .getValue();
- FFMPVirtualGageBasin vgbasin = (FFMPVirtualGageBasin) fbd
- .get(fvgbmd.getLookupId());
- if (vgbasin == null) {
- vgbasin = new FFMPVirtualGageBasin(
- fvgbmd.getLid(),
- fvgbmd.getLookupId(), aggregate);
- fbd.put(fvgbmd.getLookupId(), vgbasin);
- }
- vgbasin.setValue(date, values[j]);
- j++;
+ for (Entry entry : lids
+ .entrySet()) {
+ FFMPVirtualGageBasinMetaData fvgbmd = entry
+ .getValue();
+ FFMPVirtualGageBasin vgbasin = (FFMPVirtualGageBasin) fbd
+ .get(fvgbmd.getLookupId());
+ if (vgbasin == null) {
+ vgbasin = new FFMPVirtualGageBasin(
+ fvgbmd.getLid(),
+ fvgbmd.getLookupId(), aggregate);
+ fbd.put(fvgbmd.getLookupId(), vgbasin);
}
+ vgbasin.setValue(idate, values[j]);
+ j++;
}
}
}
@@ -646,11 +645,11 @@ public class FFMPRecord extends PersistablePluginDataObject
boolean aggregate = false;
fbd = getBasinData(ALL);
String key = getDataKey();
+ ImmutableDate idate = getCacheDate(date);
for (DomainXML domain : template.getDomains()) {
- LinkedHashMap lids = template
- .getVirtualGageBasins(key, domain.getCwa());
+ LinkedHashMap lids = template.getVirtualGageBasins(key, domain.getCwa());
int size = lids.size();
if (size > 0) {
@@ -677,7 +676,7 @@ public class FFMPRecord extends PersistablePluginDataObject
fvgbmd.getLookupId(), aggregate);
fbd.put(fvgbmd.getLookupId(), vgbasin);
}
- vgbasin.setValue(date, values[j]);
+ vgbasin.setValue(idate, values[j]);
j++;
}
}
@@ -814,5 +813,45 @@ public class FFMPRecord extends PersistablePluginDataObject
setBasinData(basinData, basinData.getHucLevel());
}
}
+
+ /**
+ * Gets and maintains the list of times. This will lesson memory consumption
+ * because it means all FFMPBasin TreeMap date keys reference back to this
+ * Hash. Seeing as there are 10000+ of those this will certainly help.
+ *
+ * @param date
+ * @return
+ */
+ protected ImmutableDate getCacheDate(Date date) {
+
+ WeakReference idate = cacheTimes.get(date.getTime());
+ ImmutableDate myDate = null;
+
+ if (idate != null) {
+ myDate = idate.get();
+ }
+
+ if (myDate == null) {
+ long time = date.getTime();
+ myDate = new ImmutableDate(time);
+ idate = new WeakReference(myDate);
+ cacheTimes.putIfAbsent(time, idate);
+ }
+
+ return myDate;
+ }
+
+
+ /**
+ * Populate data from the cache files
+ * @param basins
+ * @param hucName
+ */
+ public void populate(FFMPBasinData basins, String hucName) {
+
+ setBasinData(basins, hucName);
+ //System.out.println("Adding Whole Object Cache Data: "+hucName+" "+getSourceName());
+
+ }
}
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java
index fefb4571df..ce46c14dac 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java
@@ -1274,7 +1274,7 @@ public class FFMPTemplates {
* @param huc
* @return
*/
- public LinkedHashMap getMap(String dataKey, String cwa, String huc) {
+ public synchronized LinkedHashMap getMap(String dataKey, String cwa, String huc) {
LinkedHashMap map = null;
HashMap> hucMap = null;
@@ -1389,7 +1389,7 @@ public class FFMPTemplates {
*
* @return
*/
- public LinkedHashMap getVirtualGageBasins(
+ public synchronized LinkedHashMap getVirtualGageBasins(
String dataKey, String cwa) {
LinkedHashMap map = null;
diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/DatabaseLevelMapping.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/DatabaseLevelMapping.java
similarity index 89%
rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/DatabaseLevelMapping.java
rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/DatabaseLevelMapping.java
index 592fa8ec11..dbb1cccf24 100644
--- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/DatabaseLevelMapping.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/DatabaseLevelMapping.java
@@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
-package com.raytheon.uf.viz.core.level;
+package com.raytheon.uf.common.dataplugin.level.mapping;
import java.util.ArrayList;
import java.util.List;
@@ -33,7 +33,6 @@ import com.raytheon.uf.common.dataplugin.level.LevelFactory;
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.viz.core.exception.VizCommunicationException;
/**
* Class defines a database level
@@ -46,6 +45,8 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/16/2008 #3576 rjpeter Initial version
+ * 04/17/2013 #1913 randerso Moved to common
+ *
*
*
* @author rjpeter
@@ -59,16 +60,16 @@ public class DatabaseLevelMapping {
.getHandler(DatabaseLevelMapping.class);
@XmlAttribute
- private String levelName = null;
-
- @XmlAttribute
- private String levelOneValue = null;
+ private String unit = null;
@XmlAttribute
private String levelTwoValue = null;
@XmlAttribute
- private String unit = null;
+ private String levelOneValue = null;
+
+ @XmlAttribute
+ private String levelName = null;
public String getLevelName() {
return levelName;
@@ -102,7 +103,7 @@ public class DatabaseLevelMapping {
this.unit = unit;
}
- public List getLevels() throws VizCommunicationException {
+ public List getLevels() throws CommunicationException {
String[] levelOneValues = new String[0];
String[] levelTwoValues = new String[0];
@@ -145,16 +146,11 @@ public class DatabaseLevelMapping {
}
// handle any aliasing etc
- try {
- Level level = LevelFactory.getInstance().getLevel(levelName,
- lvl1, lvl2, unit);
- if (level != null) {
- rval.add(level);
- }
- } catch (CommunicationException e) {
- throw new VizCommunicationException(e);
+ Level level = LevelFactory.getInstance().getLevel(levelName, lvl1,
+ lvl2, unit);
+ if (level != null) {
+ rval.add(level);
}
-
}
return rval;
diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMapping.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapping.java
similarity index 93%
rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMapping.java
rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapping.java
index b600ff6501..eb83bcfdf9 100644
--- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMapping.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapping.java
@@ -18,7 +18,7 @@
* further licensing information.
**/
-package com.raytheon.uf.viz.core.level;
+package com.raytheon.uf.common.dataplugin.level.mapping;
import java.util.ArrayList;
import java.util.List;
@@ -29,9 +29,9 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.serialization.ISerializableObject;
-import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Class defines a mapping from a display level to one or more database levels.
@@ -46,6 +46,7 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException;
* 11/01/2007 #518 S.Manoj Initial version
* 11/16/2009 #3120 rjpeter Modifed to better integrate with level framework.
* 11/21/2009 #3576 rjpeter Added group
+ * 04/17/2013 #1913 randerso Moved to common
*
* @author smanoj
* @version 1.0
@@ -119,7 +120,7 @@ public class LevelMapping implements ISerializableObject {
this.databaseLevels = databaseLevels;
}
- public List getLevels() throws VizCommunicationException {
+ public List getLevels() throws CommunicationException {
if (levelList == null) {
List levelList = new ArrayList();
for (DatabaseLevelMapping mapping : databaseLevels) {
diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFactory.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFactory.java
similarity index 85%
rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFactory.java
rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFactory.java
index 234bec3cd1..da3296fa38 100644
--- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFactory.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFactory.java
@@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
-package com.raytheon.uf.viz.core.level;
+package com.raytheon.uf.common.dataplugin.level.mapping;
import java.io.File;
import java.util.Collection;
@@ -29,13 +29,13 @@ import java.util.Set;
import javax.xml.bind.JAXB;
+import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.localization.PathManagerFactory;
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.viz.core.exception.VizCommunicationException;
/**
* Factory for getting level mappings
@@ -49,15 +49,19 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException;
* ------------ ---------- ----------- --------------------------
* 11/16/2009 #3120 rjpeter Initial version
* 11/21/2009 #3576 rjpeter Added group capability
+ * 04/17/2013 #1913 randerso Moved to common
*
* @author rjpeter
* @version 1.0
*/
public class LevelMappingFactory {
+ // TODO: this should move somewhere else
+ public static final String VOLUMEBROWSER_LEVEL_MAPPING_FILE = "volumebrowser/LevelMappingFile.xml";
+
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LevelMappingFactory.class);
- private static LevelMappingFactory instance = null;
+ private static Map instanceMap = new HashMap();
private Map keyToLevelMappings = new HashMap();
@@ -69,16 +73,17 @@ public class LevelMappingFactory {
private Map>> groupToMasterLevels = new HashMap>>();
- public synchronized static LevelMappingFactory getInstance() {
+ public synchronized static LevelMappingFactory getInstance(String filePath) {
+ LevelMappingFactory instance = instanceMap.get(filePath);
if (instance == null) {
- instance = new LevelMappingFactory();
+ instance = new LevelMappingFactory(filePath);
+ instanceMap.put(filePath, instance);
}
return instance;
}
- private LevelMappingFactory() {
- File path = PathManagerFactory.getPathManager().getStaticFile(
- "volumebrowser/LevelMappingFile.xml");
+ private LevelMappingFactory(String filePath) {
+ File path = PathManagerFactory.getPathManager().getStaticFile(filePath);
LevelMappingFile levelMapFile = null;
long start = System.currentTimeMillis();
try {
@@ -115,7 +120,7 @@ public class LevelMappingFactory {
}
public LevelMapping getLevelMappingForLevel(Level level)
- throws VizCommunicationException {
+ throws CommunicationException {
if (!levelToLevelMappingsInitialized) {
initializeLevelToLevelMappings();
}
@@ -126,7 +131,7 @@ public class LevelMappingFactory {
return keyToLevelMappings.values();
}
- public Set getAllLevels() throws VizCommunicationException {
+ public Set getAllLevels() throws CommunicationException {
if (!levelToLevelMappingsInitialized) {
initializeLevelToLevelMappings();
}
@@ -134,15 +139,14 @@ public class LevelMappingFactory {
}
public Map> getLevelMapForGroup(String group)
- throws VizCommunicationException {
+ throws CommunicationException {
if (!groupToMasterLevelsInitialized) {
initializeGroupToMasterLevels();
}
return groupToMasterLevels.get(group);
}
- private void initializeLevelToLevelMappings()
- throws VizCommunicationException {
+ private void initializeLevelToLevelMappings() throws CommunicationException {
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
@@ -165,8 +169,7 @@ public class LevelMappingFactory {
levelToLevelMappingsInitialized = true;
}
- private void initializeGroupToMasterLevels()
- throws VizCommunicationException {
+ private void initializeGroupToMasterLevels() throws CommunicationException {
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
Map> masterLevels = null;
diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFile.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFile.java
similarity index 91%
rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFile.java
rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFile.java
index 53021b9f09..5aac577271 100644
--- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFile.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFile.java
@@ -18,7 +18,7 @@
* further licensing information.
**/
-package com.raytheon.uf.viz.core.level;
+package com.raytheon.uf.common.dataplugin.level.mapping;
import java.util.ArrayList;
import java.util.List;
@@ -44,6 +44,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
* ------------ ---------- ----------- --------------------------
* 11/01/2007 #518 S.Manoj Initial version
* 11/16/2009 #3120 rjpeter Refactored to use factory and level mapping.
+ * 04/17/2013 #1913 randerso Moved to common
*
* @author smanoj
* @version 1.0
@@ -56,7 +57,7 @@ public class LevelMappingFile implements ISerializableObject {
STANDARD, COMPOSITE, BINARY, XSECT, TSECT, VRTGPH, DIAGRAM, ALL, SURFACE
};
- @XmlElements( { @XmlElement(name = "Level", type = LevelMapping.class) })
+ @XmlElements({ @XmlElement(name = "Level", type = LevelMapping.class) })
private List levelMappingFile;
public List getLevelMappingFile() {
diff --git a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java
index e71e9d5574..a85aa671dc 100644
--- a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java
+++ b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java
@@ -29,10 +29,8 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.UFStatus;
@@ -51,8 +49,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Jun 23, 2011 mschenke Initial creation
- *
+ * Jun 23, 2011 mschenke Initial creation
+ * Apr 12, 2013 1903 rjpeter Fix allocateLock freezing out other lock requests.
*
*
* @author mschenke
@@ -64,14 +62,26 @@ public class FileLocker {
private static class LockWaiter {
}
+ private static enum LockState {
+ ACQUIRING, IN_USE, RELEASED
+ }
+
private static class LockedFile {
- Type lockType;
+ final Type lockType;
- Thread lockingThread;
+ final Thread lockingThread;
- Set