Issue #1926 consistently fast scan startup
Change-Id: If8d8cc4dd98a7c0b81bb2264a41d520895831b21 Former-commit-id:26b58e9354
[formerly26b58e9354
[formerly 10bd3ed35f766bdd61f130082a6917d6841f3351]] Former-commit-id:3caf85558d
Former-commit-id:388dcb9e78
This commit is contained in:
parent
cec8443e3f
commit
233af8de55
6 changed files with 51 additions and 63 deletions
|
@ -111,6 +111,7 @@ import com.vividsolutions.jts.io.WKBReader;
|
||||||
* Jan 29, 2009 dhladky Initial creation
|
* Jan 29, 2009 dhladky Initial creation
|
||||||
* Apr 18, 2013 1926 njensen Changed inner data maps to have Long key
|
* Apr 18, 2013 1926 njensen Changed inner data maps to have Long key
|
||||||
* to avoid !TimeStamp.equals(Date) issue
|
* to avoid !TimeStamp.equals(Date) issue
|
||||||
|
* Apr 26, 2013 1926 njensen Optimized getAvailableUris()
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author dhladky
|
* @author dhladky
|
||||||
|
@ -445,34 +446,6 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
||||||
return scanRec;
|
return scanRec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get list of records
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param interval
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ScanRecord[] getScanRecords(ScanTables type, String icao)
|
|
||||||
throws VizException {
|
|
||||||
List<ScanRecord> recordList = new ArrayList<ScanRecord>();
|
|
||||||
String[] uriList = getAvailableUris(type, icao);
|
|
||||||
|
|
||||||
for (String uri : uriList) {
|
|
||||||
Map<String, Object> vals = new HashMap<String, Object>();
|
|
||||||
vals.put("pluginName", "scan");
|
|
||||||
vals.put("dataURI", uri);
|
|
||||||
|
|
||||||
ScanRecord scanRec = (ScanRecord) Loader.loadData(vals);
|
|
||||||
File loc = HDF5Util.findHDF5Location(scanRec);
|
|
||||||
IDataStore dataStore = DataStoreFactory.getDataStore(loc);
|
|
||||||
if (scanRec != null) {
|
|
||||||
scanRec.retrieveMapFromDataStore(dataStore);
|
|
||||||
recordList.add(scanRec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return recordList.toArray(new ScanRecord[recordList.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tilt angle at which the table is currently at
|
* Return the tilt angle at which the table is currently at
|
||||||
*
|
*
|
||||||
|
@ -1277,41 +1250,40 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getAvailableUris(ScanTables type, String icao) {
|
public List<String> getAvailableUris(ScanTables type, String icao) {
|
||||||
List<String> uriList = new ArrayList<String>();
|
List<String> uriList = null;
|
||||||
SimpleDateFormat datef = new SimpleDateFormat(datePattern);
|
String sql = null;
|
||||||
datef.setTimeZone(TimeZone.getTimeZone("Zulu"));
|
|
||||||
String addedSQL = "";
|
|
||||||
if (type == ScanTables.DMD) {
|
if (type == ScanTables.DMD) {
|
||||||
addedSQL = "' and lastelevationangle = 't'";
|
sql = "(select datauri from scan where type = '"
|
||||||
|
+ type.name()
|
||||||
|
+ "' and icao = '"
|
||||||
|
+ icao
|
||||||
|
+ "' and lastelevationangle ='t')"
|
||||||
|
+ " union (select datauri from scan where type = '"
|
||||||
|
+ type.name()
|
||||||
|
+ "' and icao = '"
|
||||||
|
+ icao
|
||||||
|
+ "' and lastelevationangle = 'f' order by reftime desc, tilt desc limit 1)";
|
||||||
} else {
|
} else {
|
||||||
addedSQL = "'";
|
sql = "(select datauri from scan where type = '" + type.name()
|
||||||
|
+ "' and icao = '" + icao + "')";
|
||||||
}
|
}
|
||||||
String sql = "(select datauri from scan where type = '"
|
|
||||||
+ type.name()
|
|
||||||
+ "' and icao = '"
|
|
||||||
+ icao
|
|
||||||
+ addedSQL
|
|
||||||
+ " order by reftime desc) "
|
|
||||||
+ "union (select datauri from scan where type = '"
|
|
||||||
+ type.name()
|
|
||||||
+ "' and icao = '"
|
|
||||||
+ icao
|
|
||||||
+ "' and lastelevationangle = 'f' order by reftime desc, tilt desc limit 1)";
|
|
||||||
try {
|
try {
|
||||||
List<Object[]> results = DirectDbQuery.executeQuery(sql,
|
List<Object[]> results = DirectDbQuery.executeQuery(sql,
|
||||||
"metadata", QueryLanguage.SQL);
|
"metadata", QueryLanguage.SQL);
|
||||||
|
|
||||||
|
uriList = new ArrayList<String>(results.size());
|
||||||
if (results.size() > 0) {
|
if (results.size() > 0) {
|
||||||
for (Object[] ob : results) {
|
for (Object[] ob : results) {
|
||||||
uriList.add((String) ob[0]);
|
uriList.add((String) ob[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (VizException e) {
|
} catch (VizException e) {
|
||||||
e.printStackTrace();
|
statusHandler.error("Error retrieving scan uris", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return uriList.toArray(new String[uriList.size()]);
|
return uriList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.monitor.scan.resource;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -177,16 +176,12 @@ public class ScanResource extends
|
||||||
|
|
||||||
PluginDataObject[] pdos = (PluginDataObject[]) object;
|
PluginDataObject[] pdos = (PluginDataObject[]) object;
|
||||||
ScanRecord scan = null;
|
ScanRecord scan = null;
|
||||||
List<String> uris = Arrays.asList(getScan().getAvailableUris(
|
|
||||||
getTable(), resourceData.icao));
|
|
||||||
for (PluginDataObject pdo : pdos) {
|
for (PluginDataObject pdo : pdos) {
|
||||||
try {
|
try {
|
||||||
scan = (ScanRecord) pdo;
|
scan = (ScanRecord) pdo;
|
||||||
if (uris.contains(scan.getDataURI())) {
|
if (scan.getIcao().equals(resourceData.icao)
|
||||||
if (scan.getType().equals(getTable().name())) {
|
&& scan.getType().equals(getTable().name()))
|
||||||
addRecord(scan);
|
addRecord(scan);
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error updating SCAN resource", e);
|
"Error updating SCAN resource", e);
|
||||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.monitor.scan.resource;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -97,8 +96,8 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
||||||
protected AbstractVizResource<?, ?> constructResource(
|
protected AbstractVizResource<?, ?> constructResource(
|
||||||
LoadProperties loadProperties, PluginDataObject[] objects)
|
LoadProperties loadProperties, PluginDataObject[] objects)
|
||||||
throws VizException {
|
throws VizException {
|
||||||
List<String> uris = Arrays.asList(getScan().getAvailableUris(
|
List<String> uris = getScan().getAvailableUris(
|
||||||
ScanTables.valueOf(tableType), icao));
|
ScanTables.valueOf(tableType), icao);
|
||||||
try {
|
try {
|
||||||
long t0 = System.currentTimeMillis();
|
long t0 = System.currentTimeMillis();
|
||||||
// Forces ScanMonitor to grab data back for one extra hour 1/2 past
|
// Forces ScanMonitor to grab data back for one extra hour 1/2 past
|
||||||
|
|
|
@ -133,15 +133,16 @@ public class LPIResource extends
|
||||||
"Label");
|
"Label");
|
||||||
getCapability(LabelableCapability.class).setLabelField("Label");
|
getCapability(LabelableCapability.class).setLabelField("Label");
|
||||||
|
|
||||||
File file = new File(resourceData.getFilename());
|
String filename = resourceData.getFilename();
|
||||||
|
File file = new File(filename);
|
||||||
if (!file.isAbsolute()) {
|
if (!file.isAbsolute()) {
|
||||||
|
filename = FileUtil.join(VizApp.getMapsDir(), filename);
|
||||||
file = PathManagerFactory.getPathManager().getStaticFile(
|
file = PathManagerFactory.getPathManager().getStaticFile(
|
||||||
FileUtil.join(VizApp.getMapsDir(),
|
filename);
|
||||||
resourceData.getFilename()));
|
|
||||||
}
|
}
|
||||||
if (file == null || file.exists() == false) {
|
if (file == null || file.exists() == false) {
|
||||||
throw new VizException("Could not find lpi file",
|
throw new VizException("Could not find lpi file",
|
||||||
new FileNotFoundException(String.valueOf(file)));
|
new FileNotFoundException(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
points = new ArrayList<LPIPoint>();
|
points = new ArrayList<LPIPoint>();
|
||||||
|
|
17
deltaScripts/13.4.1/createScanIndexes.sh
Normal file
17
deltaScripts/13.4.1/createScanIndexes.sh
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# DR #1926 - this update script will create a scan index
|
||||||
|
|
||||||
|
PSQL="/awips2/psql/bin/psql"
|
||||||
|
|
||||||
|
echo "INFO: Creating scan_icao_type_idx"
|
||||||
|
${PSQL} -U awips -d metadata -c "CREATE INDEX scan_icao_type_idx ON scan USING btree (icao COLLATE pg_catalog.\"default\", type COLLATE pg_catalog.\"default\");"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: Failed to create index."
|
||||||
|
echo "FATAL: The update has failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "INFO: Index created successfully!"
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,4 @@
|
||||||
|
CREATE INDEX scan_icao_type_idx
|
||||||
|
ON scan
|
||||||
|
USING btree
|
||||||
|
(icao COLLATE pg_catalog."default", type COLLATE pg_catalog."default");
|
Loading…
Add table
Reference in a new issue