Issue #354: Refactor AbstractParmManager to better handle ISC parm
pre-loading. Former-commit-id:d68e3a7eea
[formerly e2c66b33fd8c71b0da6518c419296ab8141a07e3] Former-commit-id:494fbe93db
This commit is contained in:
parent
b3df043f97
commit
bc61eb1e43
2 changed files with 60 additions and 105 deletions
|
@ -1,81 +0,0 @@
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
**/
|
|
||||||
package com.raytheon.viz.gfe.core;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
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 com.raytheon.viz.gfe.core.parm.Parm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Add Description
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Dec 5, 2011 dgilling Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author dgilling
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ISCParmInitJob extends Job {
|
|
||||||
|
|
||||||
private DataManager dataMgr;
|
|
||||||
|
|
||||||
private List<Parm> parms;
|
|
||||||
|
|
||||||
public ISCParmInitJob(DataManager dataMgr, Parm[] parmList) {
|
|
||||||
super("GFE ISC Parm initialization");
|
|
||||||
setSystem(true);
|
|
||||||
this.dataMgr = dataMgr;
|
|
||||||
this.parms = Arrays.asList(parmList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
|
|
||||||
* IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
IISCDataAccess iscAccess = dataMgr.getIscDataAccess();
|
|
||||||
for (Parm parm : parms) {
|
|
||||||
if (!monitor.isCanceled()) {
|
|
||||||
iscAccess.getISCParm(parm);
|
|
||||||
} else {
|
|
||||||
return Status.CANCEL_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -62,7 +62,6 @@ import com.raytheon.viz.gfe.GFEServerException;
|
||||||
import com.raytheon.viz.gfe.PythonPreferenceStore;
|
import com.raytheon.viz.gfe.PythonPreferenceStore;
|
||||||
import com.raytheon.viz.gfe.core.DataManager;
|
import com.raytheon.viz.gfe.core.DataManager;
|
||||||
import com.raytheon.viz.gfe.core.IParmManager;
|
import com.raytheon.viz.gfe.core.IParmManager;
|
||||||
import com.raytheon.viz.gfe.core.ISCParmInitJob;
|
|
||||||
import com.raytheon.viz.gfe.core.internal.NotificationRouter.AbstractGFENotificationObserver;
|
import com.raytheon.viz.gfe.core.internal.NotificationRouter.AbstractGFENotificationObserver;
|
||||||
import com.raytheon.viz.gfe.core.msgs.IAvailableSourcesChangedListener;
|
import com.raytheon.viz.gfe.core.msgs.IAvailableSourcesChangedListener;
|
||||||
import com.raytheon.viz.gfe.core.msgs.IDisplayedParmListChangedListener;
|
import com.raytheon.viz.gfe.core.msgs.IDisplayedParmListChangedListener;
|
||||||
|
@ -90,6 +89,9 @@ import com.raytheon.viz.gfe.core.parm.vcparm.VCModule;
|
||||||
* 02/23/2012 #346 dgilling Ensure all Parms are disposed when calling
|
* 02/23/2012 #346 dgilling Ensure all Parms are disposed when calling
|
||||||
* dispose method.
|
* dispose method.
|
||||||
* 03/01/2012 #346 dgilling Use identity-based ListenerLists.
|
* 03/01/2012 #346 dgilling Use identity-based ListenerLists.
|
||||||
|
* 03/01/2012 #354 dgilling Modify setParms to always load (but not
|
||||||
|
* necessarily display) the ISC parms that
|
||||||
|
* correspond to a visible mutable parm.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -240,8 +242,6 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
|
|
||||||
private AbstractGFENotificationObserver<SiteActivationNotification> siteActivationListener;
|
private AbstractGFENotificationObserver<SiteActivationNotification> siteActivationListener;
|
||||||
|
|
||||||
private ISCParmInitJob iscInit;
|
|
||||||
|
|
||||||
private JobPool notificationPool;
|
private JobPool notificationPool;
|
||||||
|
|
||||||
protected AbstractParmManager(final DataManager dataManager) {
|
protected AbstractParmManager(final DataManager dataManager) {
|
||||||
|
@ -417,10 +417,6 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
module.dispose();
|
module.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iscInit != null) {
|
|
||||||
iscInit.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationPool.cancel();
|
notificationPool.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,15 +772,46 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- private
|
/**
|
||||||
// ----------------------------------------------------------------
|
* Helper function for <code>setParms</code>. Takes the toBeLoaded and
|
||||||
// ParmMgr::setParmsDependencies()
|
* removeParms lists, calculates non-visible ISC dependencies, and then
|
||||||
// Helper function for setParms(). Takes the toBeLoaded, addedParms,
|
* returns the updated lists through the calling arguments.
|
||||||
// removeParms, and modParms lists, calculates dependencies, and then
|
*
|
||||||
// returns the updated lists through the calling arguments.
|
* @param toBeLoaded
|
||||||
// -- implementation
|
* @param removeParms
|
||||||
// ---------------------------------------------------------
|
*/
|
||||||
// ---------------------------------------------------------------------------
|
private void setParmsRemoveISCDeps(List<ParmIDVisDep> toBeLoaded,
|
||||||
|
Collection<ParmID> removeParms) {
|
||||||
|
List<ParmID> removeList = new ArrayList<ParmID>(removeParms);
|
||||||
|
|
||||||
|
for (int i = 0; i < removeList.size(); i++) {
|
||||||
|
List<ParmID> depParms = dependentParms(removeList.get(i), true);
|
||||||
|
for (ParmID pid : depParms) {
|
||||||
|
int index = pivdIndex(toBeLoaded, pid);
|
||||||
|
if ((index != -1) && (!toBeLoaded.get(index).isVisible())) {
|
||||||
|
removeList.add(toBeLoaded.get(index).getParmID());
|
||||||
|
toBeLoaded.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ParmID pid : removeList) {
|
||||||
|
if (!removeParms.contains(pid)) {
|
||||||
|
removeParms.add(pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for <code>setParms</code>. Takes the toBeLoaded,
|
||||||
|
* addedParms, removeParms, and modParms lists, calculates dependencies, and
|
||||||
|
* then returns the updated lists through the calling arguments.
|
||||||
|
*
|
||||||
|
* @param toBeLoaded
|
||||||
|
* @param addParms
|
||||||
|
* @param removeParms
|
||||||
|
* @param modParms
|
||||||
|
*/
|
||||||
private void setParmsDependencies(List<ParmIDVisDep> toBeLoaded,
|
private void setParmsDependencies(List<ParmIDVisDep> toBeLoaded,
|
||||||
Collection<ParmIDVis> addParms, Collection<ParmID> removeParms,
|
Collection<ParmIDVis> addParms, Collection<ParmID> removeParms,
|
||||||
Collection<Parm> modParms) {
|
Collection<Parm> modParms) {
|
||||||
|
@ -793,8 +820,13 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
// non-displayed. If any are missing from the "tobeloaded", then
|
// non-displayed. If any are missing from the "tobeloaded", then
|
||||||
// add them as undisplayed.
|
// add them as undisplayed.
|
||||||
for (int i = 0; i < toBeLoaded.size(); i++) {
|
for (int i = 0; i < toBeLoaded.size(); i++) {
|
||||||
|
// Here's a derivation from AWIPS1...
|
||||||
|
// We've hard-coded the third parameter in the dependentParms() call
|
||||||
|
// to true so that the ISC parms that correspond to the visible
|
||||||
|
// mutable parms are always loaded in the ParmManager. This was
|
||||||
|
// found to significantly improve performance when loading ISC data.
|
||||||
List<ParmID> depParms = dependentParms(toBeLoaded.get(i)
|
List<ParmID> depParms = dependentParms(toBeLoaded.get(i)
|
||||||
.getParmID(), iscMode());
|
.getParmID(), true);
|
||||||
|
|
||||||
for (ParmID depParm : depParms) {
|
for (ParmID depParm : depParms) {
|
||||||
// if not present, then add it to "tobeloaded" list
|
// if not present, then add it to "tobeloaded" list
|
||||||
|
@ -934,6 +966,16 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
toBeLoaded = setParmsMakeParmIDVisDep(addParms, modParms,
|
toBeLoaded = setParmsMakeParmIDVisDep(addParms, modParms,
|
||||||
removeParms);
|
removeParms);
|
||||||
|
|
||||||
|
// Here's a derivation from AWIPS1...
|
||||||
|
// We've modified setParmsDependencies to always ensure that the ISC
|
||||||
|
// parms that correspond to parms from the mutable database are
|
||||||
|
// always loaded (but not necessary visible) in the ParmManager.
|
||||||
|
// However, this change made it impossible to unload parms if they
|
||||||
|
// were a dependency to an invisible VCParm. Hence, this new
|
||||||
|
// function was added which removes the mutable parm and the ISC
|
||||||
|
// parm(s) if none of them should be visible.
|
||||||
|
setParmsRemoveISCDeps(toBeLoaded, removeParms);
|
||||||
|
|
||||||
// statusHandler.debug("PASS " + (i + 1)
|
// statusHandler.debug("PASS " + (i + 1)
|
||||||
// + " toBeLoaded before dependencies="
|
// + " toBeLoaded before dependencies="
|
||||||
// + toBeLoaded.toString());
|
// + toBeLoaded.toString());
|
||||||
|
@ -1164,12 +1206,6 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
}
|
}
|
||||||
setParms(addParms, deletions);
|
setParms(addParms, deletions);
|
||||||
|
|
||||||
if (iscInit != null) {
|
|
||||||
iscInit.cancel();
|
|
||||||
}
|
|
||||||
iscInit = new ISCParmInitJob(dataManager, getDisplayedParms());
|
|
||||||
iscInit.schedule();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1187,7 +1223,7 @@ public abstract class AbstractParmManager implements IParmManager {
|
||||||
Collection<Parm> modParms, Collection<ParmID> removeParms) {
|
Collection<Parm> modParms, Collection<ParmID> removeParms) {
|
||||||
// only try to unload old undisplayed, if there are already parms
|
// only try to unload old undisplayed, if there are already parms
|
||||||
// being removed.
|
// being removed.
|
||||||
if (removeParms.size() == 0) {
|
if (removeParms.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue