Issue #1735 Speed ups for AcarsSoundingRecords and conversion to ThriftClient in MonitorDataUtil.
Change-Id: Iaa88a15c0406bf5b0c9ffeb5af7f31701be226a9 Former-commit-id:04ab641171
[formerly1258e12e11
] [formerly842852d975
] [formerly4c15be46a0
[formerly842852d975
[formerly 7cf9c217010a260281480eccdcc4e0b8d83fcd1f]]] Former-commit-id:4c15be46a0
Former-commit-id: 7701c00608738698fe5760f22807ef2cffec9b97 [formerlye3bacfb9f0
] Former-commit-id:0b7d85a43f
This commit is contained in:
parent
48f984f712
commit
a8534ec26f
8 changed files with 172 additions and 74 deletions
|
@ -95,7 +95,6 @@ class Monitor(MonitorP.Monitor):
|
|||
def __compare(self, taf):
|
||||
now = time.time()
|
||||
text, maxval = [], -1.0
|
||||
#data = Globals.DRC.getLLWS(self.info['ident'])
|
||||
data = LLWSData.retrieve(self.info['ident'], self.info)
|
||||
if data is None:
|
||||
data = []
|
||||
|
|
|
@ -196,7 +196,6 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
|
|||
} else {
|
||||
this.derParLibrary = derParLibrary;
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
DataTree newTree = null;
|
||||
newTree = createBaseTree();
|
||||
if (newTree == null) {
|
||||
|
@ -224,9 +223,6 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Time to initialize "
|
||||
+ this.getClass().getSimpleName() + ": "
|
||||
+ (System.currentTimeMillis() - startTime) + "ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -50,6 +54,7 @@ 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.datastructure.DataCubeContainer;
|
||||
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||
import com.raytheon.viz.aviation.climatology.ClimateMenuDlg;
|
||||
import com.raytheon.viz.aviation.model.ForecastModel;
|
||||
|
@ -95,6 +100,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* file exists.
|
||||
* 10/02/2012 1229 rferrel Made dialog non-blocking.
|
||||
* 10/09/2012 1229 rferrel Changes for non-blocking TafMonitorDlg.
|
||||
* 04/10/2013 1735 rferrel Changes for taf monitor speed up.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -186,11 +192,21 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
ForecastModel.getInstance().setBackupRestartUtility(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
return new GridLayout(1, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
font.dispose();
|
||||
|
@ -211,6 +227,13 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
@ -271,6 +294,25 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
createLabel();
|
||||
createList();
|
||||
createComposite();
|
||||
initAcarsSounding();
|
||||
}
|
||||
|
||||
/**
|
||||
* To speed up the display of the monitor this method starts up the Data
|
||||
* Cube for the acarssounding inventory which can take over a second for the
|
||||
* initial retrieval. This may cause blocking issues that slows the display
|
||||
* of the monitor.
|
||||
*/
|
||||
private void initAcarsSounding() {
|
||||
Job job = new Job("AviationDialog") {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
DataCubeContainer.getInventory("acarssounding");
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.schedule();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -221,7 +221,7 @@ public class CigVisByHourTabComp extends Composite implements ICigVisTabComp {
|
|||
* Data to set.
|
||||
*/
|
||||
public void setCigVisData(CigVisDistDataManager data) {
|
||||
data = data;
|
||||
this.data = data;
|
||||
cigVisCanvasComp.setCigVisData(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.viz.aviation.monitor;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -31,18 +32,21 @@ import com.raytheon.edex.plugin.ccfp.CcfpRecord;
|
|||
import com.raytheon.uf.common.dataplugin.acarssounding.ACARSSoundingRecord;
|
||||
import com.raytheon.uf.common.dataplugin.binlightning.BinLightningRecord;
|
||||
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
|
||||
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.requests.TimeQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
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.DataTime;
|
||||
import com.raytheon.uf.viz.core.catalog.CatalogQuery;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.comm.Loader;
|
||||
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* Utility functions for data requesting
|
||||
* Utility functions for data requesting.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -50,6 +54,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 10, 2009 njensen Initial creation
|
||||
* Apr 10, 2013 1735 rferrel Convert to ThinClient and DbQueryRequests.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,22 +77,24 @@ public class MonitorDataUtil {
|
|||
* Get the lightning data newer than a particular time
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
* @return records
|
||||
*/
|
||||
public static BinLightningRecord[] getLightningData(long time) {
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(BinLightningRecord.class);
|
||||
|
||||
Map<String, RequestConstraint> map = new HashMap<String, RequestConstraint>();
|
||||
map.put("pluginName", new RequestConstraint("binlightning"));
|
||||
map.put("startTime", new RequestConstraint(SDF.format(new Date(time)),
|
||||
RequestConstraint.ConstraintType.GREATER_THAN_EQUALS));
|
||||
LayerProperty lp = new LayerProperty();
|
||||
lp.setNumberOfImages(999);
|
||||
request.setConstraints(map);
|
||||
request.setLimit(999);
|
||||
|
||||
try {
|
||||
lp.setEntryQueryParameters(map);
|
||||
List<Object> objs = Loader.loadData(lp, "select", 10000);
|
||||
BinLightningRecord[] records = new BinLightningRecord[objs.size()];
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
records[i] = (BinLightningRecord) objs.get(i);
|
||||
}
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
BinLightningRecord[] records = response
|
||||
.getEntityObjects(BinLightningRecord.class);
|
||||
return records;
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
@ -96,39 +103,49 @@ public class MonitorDataUtil {
|
|||
return new BinLightningRecord[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain ccfp records greater then or equal to time.
|
||||
*
|
||||
* @param time
|
||||
* @return records
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static CcfpRecord[] getCcfpData(long time) {
|
||||
Map<String, RequestConstraint> map = new HashMap<String, RequestConstraint>();
|
||||
map.put("pluginName", new RequestConstraint("ccfp"));
|
||||
map.put("dataTime.refTime",
|
||||
new RequestConstraint(SDF.format(new Date(time)),
|
||||
RequestConstraint.ConstraintType.GREATER_THAN_EQUALS));
|
||||
try {
|
||||
String[] catalog = CatalogQuery.performQuery("dataTime", map);
|
||||
String[] times = catalog;
|
||||
DataTime[] dts = null;
|
||||
Arrays.sort(catalog);
|
||||
if (catalog.length > 3) {
|
||||
dts = new DataTime[3];
|
||||
dts[0] = new DataTime(catalog[catalog.length - 1]);
|
||||
dts[1] = new DataTime(catalog[catalog.length - 2]);
|
||||
dts[2] = new DataTime(catalog[catalog.length - 3]);
|
||||
} else {
|
||||
dts = new DataTime[times.length];
|
||||
for (int i = 0; i < catalog.length; i++) {
|
||||
dts[i] = new DataTime(catalog[catalog.length - i - 1]);
|
||||
}
|
||||
}
|
||||
map.remove("dataTime.refTime");
|
||||
LayerProperty lp = new LayerProperty();
|
||||
lp.setNumberOfImages(999);
|
||||
lp.setSelectedEntryTimes(dts);
|
||||
TimeQueryRequest tqRequest = new TimeQueryRequest();
|
||||
tqRequest.setPluginName("ccfp");
|
||||
tqRequest.setQueryTerms(map);
|
||||
|
||||
lp.setEntryQueryParameters(map);
|
||||
List<Object> objs = Loader.loadData(lp, "select", 10000);
|
||||
CcfpRecord[] records = new CcfpRecord[objs.size()];
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
records[i] = (CcfpRecord) objs.get(i);
|
||||
List<DataTime> dtList = (List<DataTime>) ThriftClient
|
||||
.sendRequest(tqRequest);
|
||||
String[] dts = new String[dtList.size()];
|
||||
for (int index = 0; index < dts.length; ++index) {
|
||||
dts[index] = dtList.get(index).toString();
|
||||
}
|
||||
map.put("pluginName", new RequestConstraint("ccfp"));
|
||||
Arrays.sort(dts, Collections.reverseOrder());
|
||||
|
||||
if (dts.length > 3) {
|
||||
dts = Arrays.copyOf(dts, 3);
|
||||
}
|
||||
|
||||
map.remove("dataTime.refTime");
|
||||
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(CcfpRecord.class);
|
||||
request.setLimit(999);
|
||||
request.setConstraints(map);
|
||||
RequestConstraint dataTimeRC = new RequestConstraint();
|
||||
dataTimeRC.setConstraintType(ConstraintType.IN);
|
||||
dataTimeRC.setConstraintValueList(dts);
|
||||
request.addConstraint("dataTime", dataTimeRC);
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
CcfpRecord[] records = response.getEntityObjects(CcfpRecord.class);
|
||||
return records;
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
@ -138,6 +155,13 @@ public class MonitorDataUtil {
|
|||
return new CcfpRecord[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent radar vertical wind profile.
|
||||
*
|
||||
* @param radar
|
||||
* @param time
|
||||
* @return records
|
||||
*/
|
||||
public static RadarRecord[] getVerticalWindProfile(String radar, long time) {
|
||||
Map<String, RequestConstraint> map = new HashMap<String, RequestConstraint>();
|
||||
map.put("pluginName", new RequestConstraint("radar"));
|
||||
|
@ -147,28 +171,37 @@ public class MonitorDataUtil {
|
|||
map.put("icao", new RequestConstraint(radar.toLowerCase()));
|
||||
map.put("mnemonic", new RequestConstraint("VWP"));
|
||||
|
||||
LayerProperty lp = new LayerProperty();
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(RadarRecord.class);
|
||||
|
||||
try {
|
||||
lp.setEntryQueryParameters(map);
|
||||
DataTime[] dt = lp.getEntryTimes();
|
||||
DataTime[] dt = DataCubeContainer.performTimeQuery(map, true);
|
||||
map.remove("dataTime.refTime");
|
||||
request.setConstraints(map);
|
||||
if (dt.length > 0) {
|
||||
lp.setSelectedEntryTimes(new DataTime[] { dt[dt.length - 1] });
|
||||
}
|
||||
|
||||
List<Object> objs = Loader.loadData(lp, "select", 10000);
|
||||
|
||||
RadarRecord[] records = new RadarRecord[objs.size()];
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
records[i] = (RadarRecord) objs.get(i);
|
||||
request.addConstraint("dataTime",
|
||||
new RequestConstraint(SDF.format(dt[0].getRefTime())));
|
||||
}
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
RadarRecord[] records = response
|
||||
.getEntityObjects(RadarRecord.class);
|
||||
return records;
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Error retrieving radar vertical wind profile data", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ACARS most recent sounding record for a station that is greater then
|
||||
* or equal to time.
|
||||
*
|
||||
* @param stationId
|
||||
* @param time
|
||||
* @return records
|
||||
*/
|
||||
public static ACARSSoundingRecord[] getAcarsSoundingRecords(
|
||||
String stationId, long time) {
|
||||
Map<String, RequestConstraint> map = new HashMap<String, RequestConstraint>();
|
||||
|
@ -179,24 +212,26 @@ public class MonitorDataUtil {
|
|||
map.put("location.stationId",
|
||||
new RequestConstraint(stationId.substring(1)));
|
||||
|
||||
LayerProperty lp = new LayerProperty();
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(ACARSSoundingRecord.class);
|
||||
|
||||
try {
|
||||
lp.setEntryQueryParameters(map);
|
||||
DataTime[] dt = lp.getEntryTimes();
|
||||
DataTime[] dt = DataCubeContainer.performTimeQuery(map, true);
|
||||
map.remove("dataTime.refTime");
|
||||
request.setConstraints(map);
|
||||
|
||||
if (dt.length > 0) {
|
||||
lp.setSelectedEntryTimes(new DataTime[] { dt[dt.length - 1] });
|
||||
}
|
||||
|
||||
List<Object> objs = Loader.loadData(lp, "select", 10000);
|
||||
|
||||
ACARSSoundingRecord[] records = new ACARSSoundingRecord[objs.size()];
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
records[i] = (ACARSSoundingRecord) objs.get(i);
|
||||
request.addConstraint("dataTime",
|
||||
new RequestConstraint(SDF.format(dt[0].getRefTime())));
|
||||
}
|
||||
DbQueryResponse response = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(request);
|
||||
ACARSSoundingRecord[] records = response
|
||||
.getEntityObjects(ACARSSoundingRecord.class);
|
||||
return records;
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Error retrieving Acars Sounding Records data", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class PythonMonitorJob extends AbstractQueueJob<MonitorRequest> {
|
|||
* Places request on static queue.
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
* @return true if request is accepted.
|
||||
*/
|
||||
public static boolean offerRequest(MonitorRequest req) {
|
||||
try {
|
||||
|
|
|
@ -288,6 +288,11 @@ public class TafMonitorDlg extends CaveSWTDialog implements
|
|||
currentDlg = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -297,6 +302,11 @@ public class TafMonitorDlg extends CaveSWTDialog implements
|
|||
return mainLayout;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
SiteGridManager.clear();
|
||||
|
@ -304,6 +314,13 @@ public class TafMonitorDlg extends CaveSWTDialog implements
|
|||
tveDlg.disposeDialog();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
@ -323,6 +340,11 @@ public class TafMonitorDlg extends CaveSWTDialog implements
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
|
||||
*/
|
||||
@Override
|
||||
protected void preOpened() {
|
||||
checkNow();
|
||||
|
|
|
@ -66,13 +66,17 @@ public class DbQueryResponse implements ISerializableObject {
|
|||
return getResults().size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] getEntityObjects(Class<T> entityType) {
|
||||
return getFieldObjects(ENTITY_RESULT_KEY, entityType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] getFieldObjects(String fieldKey, Class<T> fieldType) {
|
||||
List<Map<String, Object>> results = getResults();
|
||||
T[] entities = (T[]) Array.newInstance(entityType, results.size());
|
||||
T[] entities = (T[]) Array.newInstance(fieldType, results.size());
|
||||
int i = 0;
|
||||
for (Map<String, Object> result : results) {
|
||||
entities[i++] = entityType.cast(result.get(ENTITY_RESULT_KEY));
|
||||
entities[i++] = fieldType.cast(result.get(fieldKey));
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue