Issue #1926 speed up scan startup by not requesting PDOs since we have URIs
Change-Id: I7b223d9c94fb55931b1c650b115c545c7ca24180 Former-commit-id:96cdc7ce76
[formerly 96e1427daa378280133f85a1ee24647a72c8e9af] Former-commit-id:91476c8e80
This commit is contained in:
parent
3489d95e08
commit
74a5a462de
3 changed files with 152 additions and 143 deletions
|
@ -35,6 +35,7 @@ import java.util.Set;
|
|||
import java.util.TimeZone;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
@ -108,6 +109,8 @@ import com.vividsolutions.jts.io.WKBReader;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 29, 2009 dhladky Initial creation
|
||||
* Apr 18, 2013 1926 njensen Changed inner data maps to have Long key
|
||||
* to avoid !TimeStamp.equals(Date) issue
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -142,19 +145,19 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
* DMD table data, indexed by time and volume scan (with a record for each
|
||||
* azimith and elevation)
|
||||
**/
|
||||
public HashMap<String, ConcurrentHashMap<Date, DMDScanData>> dmdData = null;
|
||||
public Map<String, ConcurrentMap<Long, DMDScanData>> dmdData = null;
|
||||
|
||||
/** tvs table data, indexed by time **/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public HashMap<String, ConcurrentHashMap<Date, ScanTableData>> tvsData = null;
|
||||
public Map<String, ConcurrentMap<Long, ScanTableData>> tvsData = null;
|
||||
|
||||
/** MESO table data, indexed by time **/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public HashMap<String, ConcurrentHashMap<Date, ScanTableData>> mdData = null;
|
||||
public Map<String, ConcurrentMap<Long, ScanTableData>> mdData = null;
|
||||
|
||||
/** cell table data, indexed by time **/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public HashMap<String, ConcurrentHashMap<Date, ScanTableData>> cellData = null;
|
||||
public Map<String, ConcurrentMap<Long, ScanTableData>> cellData = null;
|
||||
|
||||
/** Array of scan listeners **/
|
||||
private final ArrayList<IScanRadarListener> scanListeners = new ArrayList<IScanRadarListener>();
|
||||
|
@ -245,10 +248,10 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void createDataStructures() {
|
||||
dmdData = new HashMap<String, ConcurrentHashMap<Date, DMDScanData>>();
|
||||
tvsData = new HashMap<String, ConcurrentHashMap<Date, ScanTableData>>();
|
||||
mdData = new HashMap<String, ConcurrentHashMap<Date, ScanTableData>>();
|
||||
cellData = new HashMap<String, ConcurrentHashMap<Date, ScanTableData>>();
|
||||
dmdData = new HashMap<String, ConcurrentMap<Long, DMDScanData>>();
|
||||
tvsData = new HashMap<String, ConcurrentMap<Long, ScanTableData>>();
|
||||
mdData = new HashMap<String, ConcurrentMap<Long, ScanTableData>>();
|
||||
cellData = new HashMap<String, ConcurrentMap<Long, ScanTableData>>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,10 +317,10 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
setStationCoordinate(icao);
|
||||
setCwa(icao);
|
||||
|
||||
dmdData.put(icao, new ConcurrentHashMap<Date, DMDScanData>());
|
||||
cellData.put(icao, new ConcurrentHashMap<Date, ScanTableData>());
|
||||
tvsData.put(icao, new ConcurrentHashMap<Date, ScanTableData>());
|
||||
mdData.put(icao, new ConcurrentHashMap<Date, ScanTableData>());
|
||||
dmdData.put(icao, new ConcurrentHashMap<Long, DMDScanData>());
|
||||
cellData.put(icao, new ConcurrentHashMap<Long, ScanTableData>());
|
||||
tvsData.put(icao, new ConcurrentHashMap<Long, ScanTableData>());
|
||||
mdData.put(icao, new ConcurrentHashMap<Long, ScanTableData>());
|
||||
|
||||
// kill splash
|
||||
if (scanSplashDlg != null) {
|
||||
|
@ -505,11 +508,11 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
if ((scanType == ScanTables.MESO) || (scanType == ScanTables.TVS)) {
|
||||
scanType = ScanTables.CELL;
|
||||
}
|
||||
Set<Date> ds = getData(scanType, icao).keySet();
|
||||
Set<Long> ds = getData(scanType, icao).keySet();
|
||||
DataTime[] times = new DataTime[ds.size()];
|
||||
int i = 0;
|
||||
for (Date d : ds) {
|
||||
times[i] = new DataTime(d);
|
||||
for (Long d : ds) {
|
||||
times[i] = new DataTime(new Date(d));
|
||||
i++;
|
||||
}
|
||||
java.util.Arrays.sort(times);
|
||||
|
@ -545,30 +548,39 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
/**
|
||||
* Sends a String from the TABLE enum for which table data to grab
|
||||
*/
|
||||
public ConcurrentHashMap<Date, ?> getData(ScanTables table, String icao) {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public ConcurrentMap<Long, ?> getData(ScanTables table, String icao) {
|
||||
ConcurrentMap<Long, ?> data = null;
|
||||
|
||||
ConcurrentHashMap<Date, ?> data = null;
|
||||
|
||||
if (table.equals(ScanTables.CELL)) {
|
||||
if (cellData.get(icao) == null) {
|
||||
cellData.put(icao, new ConcurrentHashMap<Date, ScanTableData>());
|
||||
}
|
||||
switch (table) {
|
||||
case CELL:
|
||||
data = cellData.get(icao);
|
||||
} else if (table.equals(ScanTables.DMD)) {
|
||||
if (dmdData.get(icao) == null) {
|
||||
dmdData.put(icao, new ConcurrentHashMap<Date, DMDScanData>());
|
||||
if (data == null) {
|
||||
data = new ConcurrentHashMap<Long, ScanTableData>();
|
||||
cellData.put(icao, (ConcurrentMap<Long, ScanTableData>) data);
|
||||
}
|
||||
break;
|
||||
case DMD:
|
||||
data = dmdData.get(icao);
|
||||
} else if (table.equals(ScanTables.MESO)) {
|
||||
if (mdData.get(icao) == null) {
|
||||
mdData.put(icao, new ConcurrentHashMap<Date, ScanTableData>());
|
||||
if (data == null) {
|
||||
data = new ConcurrentHashMap<Long, DMDScanData>();
|
||||
dmdData.put(icao, (ConcurrentHashMap<Long, DMDScanData>) data);
|
||||
}
|
||||
break;
|
||||
case MESO:
|
||||
data = mdData.get(icao);
|
||||
} else if (table.equals(ScanTables.TVS)) {
|
||||
if (tvsData.get(icao) == null) {
|
||||
tvsData.put(icao, new ConcurrentHashMap<Date, ScanTableData>());
|
||||
if (data == null) {
|
||||
data = new ConcurrentHashMap<Long, ScanTableData>();
|
||||
mdData.put(icao, (ConcurrentMap<Long, ScanTableData>) data);
|
||||
}
|
||||
break;
|
||||
case TVS:
|
||||
data = tvsData.get(icao);
|
||||
if (data == null) {
|
||||
data = new ConcurrentHashMap<Long, ScanTableData>();
|
||||
tvsData.put(icao, (ConcurrentMap<Long, ScanTableData>) data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -581,25 +593,29 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
public ScanTableData<?> getTableData(ScanTables table, String icao,
|
||||
Date time) {
|
||||
ScanTableData<?> tableData = null;
|
||||
|
||||
if (table == ScanTables.CELL) {
|
||||
tableData = (ScanTableData<?>) getData(table, icao).get(time);
|
||||
} else if (table == ScanTables.DMD) {
|
||||
if (getData(table, icao).containsKey(time)) {
|
||||
tableData = ((DMDScanData) getData(table, icao).get(time))
|
||||
.getTableData(time.getTime());
|
||||
}
|
||||
} else if ((table == ScanTables.TVS) || (table == ScanTables.MESO)) {
|
||||
if (getData(table, icao).containsKey(time)) {
|
||||
tableData = (ScanTableData<?>) getData(table, icao).get(time);
|
||||
} else {
|
||||
ConcurrentMap<Long, ?> data = getData(table, icao);
|
||||
long longtime = time.getTime();
|
||||
switch (table) {
|
||||
case CELL:
|
||||
case TVS:
|
||||
case MESO:
|
||||
tableData = (ScanTableData<?>) data.get(longtime);
|
||||
if (tableData == null
|
||||
&& (table == ScanTables.TVS || table == ScanTables.MESO)) {
|
||||
tableData = getNewTableData(table, icao, time,
|
||||
getTiltAngle(table, icao));
|
||||
if (tableData != null) {
|
||||
((ConcurrentHashMap<Date, ScanTableData>) getData(table,
|
||||
icao)).put(time, tableData);
|
||||
((ConcurrentHashMap<Long, ScanTableData>) data).put(
|
||||
longtime, tableData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DMD:
|
||||
DMDScanData dmdsd = (DMDScanData) data.get(longtime);
|
||||
if (dmdsd != null) {
|
||||
tableData = dmdsd.getTableData(longtime);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return tableData;
|
||||
|
@ -612,9 +628,10 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
double tiltAngle) {
|
||||
ScanTables dmd = ScanTables.DMD;
|
||||
ScanTableData<?> tableData = null;
|
||||
if (getData(dmd, icao).containsKey(time)) {
|
||||
tableData = ((DMDScanData) getData(dmd, icao).get(time))
|
||||
.getTableData(time.getTime());
|
||||
ConcurrentMap<Long, ?> data = getData(dmd, icao);
|
||||
DMDScanData dmdsd = (DMDScanData) data.get(time.getTime());
|
||||
if (dmdsd != null) {
|
||||
tableData = dmdsd.getTableData(time.getTime());
|
||||
}
|
||||
|
||||
return tableData;
|
||||
|
@ -650,24 +667,25 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
@SuppressWarnings({ "unchecked" })
|
||||
public void setTableData(String icao, ScanTableData<?> data, Date date,
|
||||
double angle, Date scanTime, String type) {
|
||||
long longScanTime = scanTime.getTime();
|
||||
if (type.equals(ScanTables.DMD.name())) {
|
||||
if (getData(ScanTables.DMD, icao).containsKey(scanTime)) {
|
||||
if (((DMDScanData) getData(ScanTables.DMD, icao).get(scanTime))
|
||||
.containsKey(angle) == false) {
|
||||
((DMDScanData) getData(ScanTables.DMD, icao).get(scanTime))
|
||||
.addData(angle, date.getTime(), data);
|
||||
ConcurrentMap<Long, DMDScanData> dataMap = (ConcurrentMap<Long, DMDScanData>) getData(
|
||||
ScanTables.DMD, icao);
|
||||
if (dataMap.containsKey(longScanTime)) {
|
||||
DMDScanData dmdsd = dataMap.get(longScanTime);
|
||||
if (!dmdsd.containsKey(angle)) {
|
||||
dmdsd.addData(angle, date.getTime(), data);
|
||||
}
|
||||
} else { // new volume scan
|
||||
DMDScanData sdata = new DMDScanData(scanTime.getTime());
|
||||
((ConcurrentHashMap<Date, DMDScanData>) getData(ScanTables.DMD,
|
||||
icao)).put(scanTime, sdata);
|
||||
((DMDScanData) getData(ScanTables.DMD, icao).get(scanTime))
|
||||
.addData(angle, date.getTime(), data);
|
||||
DMDScanData sdata = new DMDScanData(longScanTime);
|
||||
sdata.addData(angle, date.getTime(), data);
|
||||
dataMap.put(longScanTime, sdata);
|
||||
}
|
||||
} else if (type.equals(ScanTables.CELL.name())) {
|
||||
if (!getData(ScanTables.CELL, icao).containsKey(scanTime)) {
|
||||
((ConcurrentHashMap<Date, ScanTableData<?>>) getData(
|
||||
ScanTables.CELL, icao)).put(scanTime, data);
|
||||
ConcurrentMap<Long, ScanTableData<?>> dataMap = (ConcurrentMap<Long, ScanTableData<?>>) getData(
|
||||
ScanTables.CELL, icao);
|
||||
if (!dataMap.containsKey(longScanTime)) {
|
||||
dataMap.put(longScanTime, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1318,7 +1336,7 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
// minutes
|
||||
// dmdScanData = new DMDScanData();
|
||||
dmdScanData = (DMDScanData) getData(ScanTables.DMD, icao).get(
|
||||
date);
|
||||
date.getTime());
|
||||
|
||||
TreeMap<Long, DMDTableDataRow> tmp = dmdScanData
|
||||
.getTimeHeightData(tableCol, dmdIdent);
|
||||
|
@ -1358,11 +1376,11 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
* @param set
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<Date> getTimeOrderedKeys(IMonitor monitor, String type,
|
||||
public List<Date> getTimeOrderedKeys(IMonitor monitor, String type,
|
||||
String icao) {
|
||||
ArrayList<Date> dates = new ArrayList<Date>();
|
||||
for (Date date : getData(ScanTables.valueOf(type), icao).keySet()) {
|
||||
dates.add(date);
|
||||
List<Date> dates = new ArrayList<Date>();
|
||||
for (Long date : getData(ScanTables.valueOf(type), icao).keySet()) {
|
||||
dates.add(new Date(date));
|
||||
}
|
||||
Collections.sort(dates, new SortByDate());
|
||||
return dates;
|
||||
|
@ -1818,11 +1836,12 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
}
|
||||
|
||||
public void purge() {
|
||||
long dateTime = date.getTime();
|
||||
|
||||
ConcurrentHashMap<Date, ?> data = getData(table, icao);
|
||||
ConcurrentMap<Long, ?> data = getData(table, icao);
|
||||
|
||||
for (Date idate : data.keySet()) {
|
||||
if (idate.before(date)) {
|
||||
for (Long idate : data.keySet()) {
|
||||
if (idate < dateTime) {
|
||||
data.remove(idate);
|
||||
}
|
||||
}
|
||||
|
@ -1830,20 +1849,18 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
// also check MESO and TVS
|
||||
if (table == ScanTables.CELL) {
|
||||
|
||||
ConcurrentHashMap<Date, ?> mesodata = getData(ScanTables.MESO,
|
||||
icao);
|
||||
ConcurrentMap<Long, ?> mesodata = getData(ScanTables.MESO, icao);
|
||||
|
||||
for (Date idate : mesodata.keySet()) {
|
||||
if (idate.before(date)) {
|
||||
for (Long idate : mesodata.keySet()) {
|
||||
if (idate < dateTime) {
|
||||
mesodata.remove(idate);
|
||||
}
|
||||
}
|
||||
|
||||
ConcurrentHashMap<Date, ?> tvsdata = getData(ScanTables.TVS,
|
||||
icao);
|
||||
ConcurrentMap<Long, ?> tvsdata = getData(ScanTables.TVS, icao);
|
||||
|
||||
for (Date idate : tvsdata.keySet()) {
|
||||
if (idate.before(date)) {
|
||||
for (Long idate : tvsdata.keySet()) {
|
||||
if (idate < dateTime) {
|
||||
tvsdata.remove(idate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -39,10 +38,6 @@ import javax.xml.bind.annotation.XmlType;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.scan.ScanRecord;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
|
@ -52,7 +47,6 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
|
|||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.HDF5Util;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
|
@ -68,6 +62,7 @@ import com.raytheon.uf.viz.monitor.scan.ScanMonitor;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 13, 2009 dhladky Initial creation
|
||||
* Feb 28, 2013 1731 bsteffen Optimize construction of scan resource.
|
||||
* Apr 18, 2013 1926 njensen Reuse URIs in construction of resource
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -113,14 +108,16 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
|||
firstCal.add(Calendar.MINUTE, -90);
|
||||
Date firstDate = firstCal.getTime();
|
||||
int count = 0;
|
||||
List<String> urisToLoad = new ArrayList<String>(uris.size());
|
||||
List<ScanRecord> recordsToLoad = new ArrayList<ScanRecord>(
|
||||
uris.size());
|
||||
for (String uri : uris) {
|
||||
ScanRecord record = new ScanRecord(uri);
|
||||
if (record.getDataTime().getRefTime().after(firstDate)) {
|
||||
urisToLoad.add(uri);
|
||||
recordsToLoad.add(record);
|
||||
}
|
||||
}
|
||||
ScanRecord[] records = getScanRecords(urisToLoad);
|
||||
ScanRecord[] records = recordsToLoad.toArray(new ScanRecord[0]);
|
||||
|
||||
populateRecords(records);
|
||||
for (ScanRecord record : records) {
|
||||
if ((record.getTableData() != null)
|
||||
|
@ -164,11 +161,10 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
|||
}
|
||||
}
|
||||
}
|
||||
long t4 = System.currentTimeMillis();
|
||||
|
||||
System.out
|
||||
.println("Loaded " + count + " out of " + uris.size()
|
||||
+ " objects in "
|
||||
+ (System.currentTimeMillis() - t0) + "ms");
|
||||
System.out.println("Loaded " + count + " out of " + uris.size()
|
||||
+ " objects in " + (t4 - t0) + "ms");
|
||||
// need to update the dialog here after the
|
||||
// scanResourceData has been fully populated
|
||||
getScan().setInstantiated(true);
|
||||
|
@ -189,6 +185,7 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
getScan().closeDialog(icao);
|
||||
}
|
||||
return new ScanResource(this, loadProperties);
|
||||
|
@ -231,8 +228,7 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
|||
}
|
||||
try {
|
||||
IDataRecord[] dataRecords = dataStore.retrieveDatasets(
|
||||
datasetGroupPath,
|
||||
Request.ALL);
|
||||
datasetGroupPath, Request.ALL);
|
||||
for (i = 0; i < dataRecords.length; i += 1) {
|
||||
ByteDataRecord byteData = (ByteDataRecord) dataRecords[i];
|
||||
scanRecords[i].setTableData(byteData);
|
||||
|
@ -287,16 +283,4 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
|||
}
|
||||
}
|
||||
|
||||
private ScanRecord[] getScanRecords(Collection<String> uris)
|
||||
throws VizException {
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(ScanRecord.class);
|
||||
RequestConstraint rc = new RequestConstraint(null, ConstraintType.IN);
|
||||
rc.setConstraintValueList(uris);
|
||||
request.addConstraint("dataURI", rc);
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
return response.getEntityObjects(ScanRecord.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums;
|
|||
import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
|
||||
import com.raytheon.uf.viz.monitor.scan.ScanMonitor;
|
||||
import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator;
|
||||
import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlarmType;
|
||||
|
||||
/**
|
||||
* Manager class to hold between scan dialog and alarming capabilities
|
||||
|
@ -53,6 +52,7 @@ import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlarmType;
|
|||
* Dec 2, 2010 mnash Initial creation
|
||||
*
|
||||
* 03/15/2012 13939 Mike Duff For a SCAN Alarms issue
|
||||
* Apr 18, 2013 1926 njensen Update for Long keys
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -102,7 +102,8 @@ public class SCANAlarmAlertManager {
|
|||
public void addSite(String site) {
|
||||
|
||||
if (!scheduledAlarmsMap.containsKey(site)) {
|
||||
Map<ScanTables, List<ScheduledAlarms>> siteScheduledAlarmsMap = Collections.synchronizedMap(new HashMap<ScanTables, List<ScheduledAlarms>>());
|
||||
Map<ScanTables, List<ScheduledAlarms>> siteScheduledAlarmsMap = Collections
|
||||
.synchronizedMap(new HashMap<ScanTables, List<ScheduledAlarms>>());
|
||||
siteScheduledAlarmsMap.put(ScanTables.DMD,
|
||||
new CopyOnWriteArrayList<ScheduledAlarms>());
|
||||
siteScheduledAlarmsMap.put(ScanTables.CELL,
|
||||
|
@ -111,7 +112,8 @@ public class SCANAlarmAlertManager {
|
|||
}
|
||||
|
||||
if (!alertedAlarmsMap.containsKey(site)) {
|
||||
Map<ScanTables, Set<AlertedAlarms>> siteAlertedAlarmsSet = Collections.synchronizedMap(new HashMap<ScanTables, Set<AlertedAlarms>>());
|
||||
Map<ScanTables, Set<AlertedAlarms>> siteAlertedAlarmsSet = Collections
|
||||
.synchronizedMap(new HashMap<ScanTables, Set<AlertedAlarms>>());
|
||||
siteAlertedAlarmsSet.put(ScanTables.DMD,
|
||||
new HashSet<AlertedAlarms>());
|
||||
siteAlertedAlarmsSet.put(ScanTables.CELL,
|
||||
|
@ -130,11 +132,13 @@ public class SCANAlarmAlertManager {
|
|||
private SCANAlarmAlertManager() {
|
||||
|
||||
if (scheduledAlarmsMap == null) {
|
||||
scheduledAlarmsMap = Collections.synchronizedMap(new HashMap<String, Map<ScanTables, List<ScheduledAlarms>>>());
|
||||
scheduledAlarmsMap = Collections
|
||||
.synchronizedMap(new HashMap<String, Map<ScanTables, List<ScheduledAlarms>>>());
|
||||
}
|
||||
|
||||
if (alertedAlarmsMap == null) {
|
||||
alertedAlarmsMap = Collections.synchronizedMap(new HashMap<String, Map<ScanTables, Set<AlertedAlarms>>>());
|
||||
alertedAlarmsMap = Collections
|
||||
.synchronizedMap(new HashMap<String, Map<ScanTables, Set<AlertedAlarms>>>());
|
||||
}
|
||||
|
||||
if (idents == null) {
|
||||
|
@ -197,8 +201,8 @@ public class SCANAlarmAlertManager {
|
|||
if (valCompare) {
|
||||
addAlertedAlarm(site, tableType, scanData
|
||||
.getTableCellData(0).getCellText(),
|
||||
alarm.colName, AlarmType.AbsVal, row,
|
||||
index, latestTime);
|
||||
alarm.colName, AlarmType.AbsVal, row, index,
|
||||
latestTime);
|
||||
}
|
||||
row++;
|
||||
}
|
||||
|
@ -208,12 +212,15 @@ public class SCANAlarmAlertManager {
|
|||
|
||||
if (monitor.cellData != null) {
|
||||
if (monitor.cellData.containsKey(site)) {
|
||||
Set<Date> cellData = monitor.cellData.get(site)
|
||||
Set<Long> cellData = monitor.cellData.get(site)
|
||||
.keySet();
|
||||
Date previous = null;
|
||||
if (!cellData.isEmpty()) {
|
||||
Date[] times = cellData.toArray(new Date[cellData
|
||||
.size()]);
|
||||
Date[] times = new Date[cellData.size()];
|
||||
Iterator<Long> itr = cellData.iterator();
|
||||
for (int i = 0; i < times.length; i++) {
|
||||
times[i] = new Date(itr.next());
|
||||
}
|
||||
if (times.length > 1) {
|
||||
Arrays.sort(times);
|
||||
previous = times[times.length - 2];
|
||||
|
@ -322,10 +329,10 @@ public class SCANAlarmAlertManager {
|
|||
public void clearAlarm(String site, ScanTables tableType,
|
||||
AlertedAlarms alarm) {
|
||||
Set<AlertedAlarms> alarms = alertedAlarmsMap.get(site).get(tableType);
|
||||
for (AlertedAlarms aa: alarms) {
|
||||
if (alarm.ident.equalsIgnoreCase(aa.ident) &&
|
||||
alarm.colName.equalsIgnoreCase(aa.colName) &&
|
||||
(alarm.type == aa.type) && (alarm.row == aa.row)) {
|
||||
for (AlertedAlarms aa : alarms) {
|
||||
if (alarm.ident.equalsIgnoreCase(aa.ident)
|
||||
&& alarm.colName.equalsIgnoreCase(aa.colName)
|
||||
&& (alarm.type == aa.type) && (alarm.row == aa.row)) {
|
||||
aa.cleared = true;
|
||||
break;
|
||||
}
|
||||
|
@ -390,22 +397,24 @@ public class SCANAlarmAlertManager {
|
|||
* @param col
|
||||
*/
|
||||
public void addAlertedAlarm(String site, ScanTables tableType,
|
||||
String ident, String colName, AlarmType type, int row,
|
||||
int col, Date validTime) {
|
||||
String ident, String colName, AlarmType type, int row, int col,
|
||||
Date validTime) {
|
||||
Set<AlertedAlarms> alarms = alertedAlarmsMap.get(site).get(tableType);
|
||||
if (alarms.size() == 0) {
|
||||
alarms.add(new AlertedAlarms(ident, colName, type, row, col, validTime));
|
||||
alarms.add(new AlertedAlarms(ident, colName, type, row, col,
|
||||
validTime));
|
||||
return;
|
||||
}
|
||||
for (AlertedAlarms alarm: alarms) {
|
||||
if (alarm.ident.equalsIgnoreCase(ident) &&
|
||||
alarm.colName.equalsIgnoreCase(colName) &&
|
||||
(alarm.type == type) && (alarm.row == row)) {
|
||||
for (AlertedAlarms alarm : alarms) {
|
||||
if (alarm.ident.equalsIgnoreCase(ident)
|
||||
&& alarm.colName.equalsIgnoreCase(colName)
|
||||
&& (alarm.type == type) && (alarm.row == row)) {
|
||||
if (alarm.cleared) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
alarms.add(new AlertedAlarms(ident, colName, type, row, col, validTime));
|
||||
alarms.add(new AlertedAlarms(ident, colName, type, row, col,
|
||||
validTime));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -426,15 +435,13 @@ public class SCANAlarmAlertManager {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<AlertedAlarms> getAlertedAlarms(String site,
|
||||
ScanTables tableType) {
|
||||
public Set<AlertedAlarms> getAlertedAlarms(String site, ScanTables tableType) {
|
||||
return alertedAlarmsMap.get(site).get(tableType);
|
||||
}
|
||||
|
||||
public int getAlertedAlarmCount(String site,
|
||||
ScanTables tableType) {
|
||||
public int getAlertedAlarmCount(String site, ScanTables tableType) {
|
||||
int count = 0;
|
||||
for (AlertedAlarms alarm: alertedAlarmsMap.get(site).get(tableType)) {
|
||||
for (AlertedAlarms alarm : alertedAlarmsMap.get(site).get(tableType)) {
|
||||
if (!alarm.cleared) {
|
||||
count++;
|
||||
}
|
||||
|
@ -478,13 +485,13 @@ public class SCANAlarmAlertManager {
|
|||
*/
|
||||
private void clearOldAlarms(String site, ScanTables type, Date latestTime) {
|
||||
List<AlertedAlarms> clearList = new ArrayList<AlertedAlarms>();
|
||||
for (AlertedAlarms alarm: alertedAlarmsMap.get(site).get(type)) {
|
||||
for (AlertedAlarms alarm : alertedAlarmsMap.get(site).get(type)) {
|
||||
if (latestTime.getTime() > alarm.validTime.getTime()) {
|
||||
clearList.add(alarm);
|
||||
}
|
||||
}
|
||||
|
||||
for (AlertedAlarms alarm: clearList) {
|
||||
for (AlertedAlarms alarm : clearList) {
|
||||
alertedAlarmsMap.get(site).get(type).remove(alarm);
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +612,8 @@ public class SCANAlarmAlertManager {
|
|||
public String toString() {
|
||||
return "Identifier : " + this.ident + "\nColumn : " + this.colName
|
||||
+ "\nType : " + this.type.getName() + "\nRow #: "
|
||||
+ this.row + "\nCol #:" + this.col + "\nCleared: " + cleared + "\n";
|
||||
+ this.row + "\nCol #:" + this.col + "\nCleared: "
|
||||
+ cleared + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue