Merge "Issue #1926 consistently fast scan startup" into omaha_13.4.1
Former-commit-id: a1aa0b81b3d03fb972cdc341c811e560ece16a0e
This commit is contained in:
commit
20e5ca5eee
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
|
||||
* Apr 18, 2013 1926 njensen Changed inner data maps to have Long key
|
||||
* to avoid !TimeStamp.equals(Date) issue
|
||||
* Apr 26, 2013 1926 njensen Optimized getAvailableUris()
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -445,34 +446,6 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
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
|
||||
*
|
||||
|
@ -1277,41 +1250,40 @@ public class ScanMonitor extends ResourceMonitor implements IScanDialogListener
|
|||
return uri;
|
||||
}
|
||||
|
||||
public String[] getAvailableUris(ScanTables type, String icao) {
|
||||
List<String> uriList = new ArrayList<String>();
|
||||
SimpleDateFormat datef = new SimpleDateFormat(datePattern);
|
||||
datef.setTimeZone(TimeZone.getTimeZone("Zulu"));
|
||||
String addedSQL = "";
|
||||
public List<String> getAvailableUris(ScanTables type, String icao) {
|
||||
List<String> uriList = null;
|
||||
String sql = null;
|
||||
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 {
|
||||
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 {
|
||||
List<Object[]> results = DirectDbQuery.executeQuery(sql,
|
||||
"metadata", QueryLanguage.SQL);
|
||||
|
||||
uriList = new ArrayList<String>(results.size());
|
||||
if (results.size() > 0) {
|
||||
for (Object[] ob : results) {
|
||||
uriList.add((String) ob[0]);
|
||||
}
|
||||
}
|
||||
} 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.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -177,16 +176,12 @@ public class ScanResource extends
|
|||
|
||||
PluginDataObject[] pdos = (PluginDataObject[]) object;
|
||||
ScanRecord scan = null;
|
||||
List<String> uris = Arrays.asList(getScan().getAvailableUris(
|
||||
getTable(), resourceData.icao));
|
||||
for (PluginDataObject pdo : pdos) {
|
||||
try {
|
||||
scan = (ScanRecord) pdo;
|
||||
if (uris.contains(scan.getDataURI())) {
|
||||
if (scan.getType().equals(getTable().name())) {
|
||||
addRecord(scan);
|
||||
}
|
||||
}
|
||||
if (scan.getIcao().equals(resourceData.icao)
|
||||
&& scan.getType().equals(getTable().name()))
|
||||
addRecord(scan);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error updating SCAN resource", e);
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.monitor.scan.resource;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -97,8 +96,8 @@ public class ScanResourceData extends AbstractRequestableResourceData {
|
|||
protected AbstractVizResource<?, ?> constructResource(
|
||||
LoadProperties loadProperties, PluginDataObject[] objects)
|
||||
throws VizException {
|
||||
List<String> uris = Arrays.asList(getScan().getAvailableUris(
|
||||
ScanTables.valueOf(tableType), icao));
|
||||
List<String> uris = getScan().getAvailableUris(
|
||||
ScanTables.valueOf(tableType), icao);
|
||||
try {
|
||||
long t0 = System.currentTimeMillis();
|
||||
// Forces ScanMonitor to grab data back for one extra hour 1/2 past
|
||||
|
|
|
@ -133,15 +133,16 @@ public class LPIResource extends
|
|||
"Label");
|
||||
getCapability(LabelableCapability.class).setLabelField("Label");
|
||||
|
||||
File file = new File(resourceData.getFilename());
|
||||
String filename = resourceData.getFilename();
|
||||
File file = new File(filename);
|
||||
if (!file.isAbsolute()) {
|
||||
filename = FileUtil.join(VizApp.getMapsDir(), filename);
|
||||
file = PathManagerFactory.getPathManager().getStaticFile(
|
||||
FileUtil.join(VizApp.getMapsDir(),
|
||||
resourceData.getFilename()));
|
||||
filename);
|
||||
}
|
||||
if (file == null || file.exists() == false) {
|
||||
throw new VizException("Could not find lpi file",
|
||||
new FileNotFoundException(String.valueOf(file)));
|
||||
new FileNotFoundException(filename));
|
||||
}
|
||||
|
||||
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