Omaha #4816: Fix baseline code to support refactored PythonJobCoordinator API.

Change-Id: I906946954158e2c5fa39195e8869bca815720aa0

Former-commit-id: c30f24c376f2548126fe08369951bd5a4cf78225
This commit is contained in:
David Gillingham 2015-12-14 14:14:27 -06:00
parent 7509fd4f01
commit 60313a2120
23 changed files with 168 additions and 213 deletions

View file

@ -26,10 +26,12 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
import com.raytheon.uf.common.dataplugin.gfe.reference.GroupID;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
import com.raytheon.viz.gfe.core.msgs.IEditAreaGroupInvChangedListener;
import com.raytheon.viz.gfe.core.msgs.IReferenceSetChangedListener;
import com.raytheon.viz.gfe.core.msgs.IReferenceSetIDChangedListener;
import com.raytheon.viz.gfe.core.msgs.IReferenceSetInvChangedListener;
import com.raytheon.viz.gfe.query.QueryScript;
/**
* Public interface for ReferenceSetManager
@ -43,6 +45,7 @@ import com.raytheon.viz.gfe.core.msgs.IReferenceSetInvChangedListener;
* 02/26/2013 #1708 randerso Remove evaluateRefSet from public interface
* Aug 13, 2015 4749 njensen Extends DisposableManager
* Nov 18, 2015 5129 dgilling Remove UI-related arguments from deleteRefSet.
* Dec 16, 2015 4816 dgilling Add getPythonThreadPool.
*
* </pre>
*
@ -341,4 +344,14 @@ public interface IReferenceSetManager extends DisposableManager {
* @return true is query will recurse
*/
public boolean willRecurse(String name, String query);
/**
* Returns a reference to the {@link PythonJobCoordinator} so other classes
* can evaluate query-based edit areas using this
* {@code IReferenceSetManager}'s thread pool.
*
* @return {@code PythonJobCoordinator} for evaluating query-based edit
* areas.
*/
public PythonJobCoordinator<QueryScript> getPythonThreadPool();
}

View file

@ -63,8 +63,8 @@ import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.SaveableOutputStream;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.IPythonExecutor;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.uf.common.python.concurrent.IPythonJobListener;
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -115,6 +115,7 @@ import com.vividsolutions.jts.geom.Envelope;
* Aug 27, 2015 4947 njensen Fixed removeReferenceSetIDChangedListener()
* Nov 18, 2015 5129 dgilling Use new IFPClient for get/save/delete
* of reference data.
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -123,9 +124,14 @@ import com.vividsolutions.jts.geom.Envelope;
*/
public class ReferenceSetManager implements IReferenceSetManager,
IMessageClient, ISpatialEditorTimeChangedListener {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ReferenceSetManager.class);
private static final String QUERY_THREAD_POOL_NAME = "gfequeryscript";
private static final int NUM_QUERY_THREADS = 1;
public static final String EDIT_AREAS_DIR = FileUtil.join("gfe",
"editAreas");
@ -541,9 +547,10 @@ public class ReferenceSetManager implements IReferenceSetManager,
@SuppressWarnings("unchecked")
public ReferenceSetManager(DataManager dataManager) {
// ready the PythonJobCoordinator
AbstractPythonScriptFactory<QueryScript> factory = new QueryScriptFactory(
PythonInterpreterFactory<QueryScript> factory = new QueryScriptFactory(
dataManager);
coordinator = PythonJobCoordinator.newInstance(factory);
coordinator = new PythonJobCoordinator<>(NUM_QUERY_THREADS,
QUERY_THREAD_POOL_NAME, factory);
// MessageClient("ReferenceSetMgr", msgHandler);
this.dataManager = dataManager;
@ -1646,7 +1653,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
IPythonExecutor<QueryScript, ReferenceData> executor = new QueryScriptExecutor(
"evaluate", argMap);
try {
coordinator.submitAsyncJob(executor, listener);
coordinator.submitJobWithCallback(executor, listener);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR,
"Unable to submit job to ExecutorService", e);
@ -1669,7 +1676,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
IPythonExecutor<QueryScript, ReferenceData> executor = new QueryScriptExecutor(
"evaluate", argMap);
try {
ea = coordinator.submitSyncJob(executor);
ea = coordinator.submitJob(executor).get();
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Failed to evaluate query: "
+ query, e);
@ -1687,7 +1694,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
argMap);
int result = 0;
try {
result = coordinator.submitSyncJob(executor);
result = coordinator.submitJob(executor).get();
} catch (Exception e) {
statusHandler.handle(Priority.ERROR,
"Unable to submit job to ExecutorService", e);
@ -1787,4 +1794,9 @@ public class ReferenceSetManager implements IReferenceSetManager,
};
evaluateActiveRefSet(listener);
}
@Override
public PythonJobCoordinator<QueryScript> getPythonThreadPool() {
return coordinator;
}
}

View file

@ -55,17 +55,14 @@ import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.CoordinateType;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.IPythonExecutor;
import com.raytheon.uf.common.python.concurrent.IPythonJobListener;
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
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.VizApp;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
import com.raytheon.viz.gfe.core.IParmManager;
import com.raytheon.viz.gfe.core.IReferenceSetManager;
import com.raytheon.viz.gfe.core.IReferenceSetManager.RefSetMode;
@ -81,7 +78,6 @@ import com.raytheon.viz.gfe.core.wxvalue.WeatherWxValue;
import com.raytheon.viz.gfe.core.wxvalue.WxValue;
import com.raytheon.viz.gfe.query.QueryScript;
import com.raytheon.viz.gfe.query.QueryScriptExecutor;
import com.raytheon.viz.gfe.query.QueryScriptFactory;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
import com.raytheon.viz.ui.widgets.ToggleSelectList;
@ -106,7 +102,8 @@ import com.vividsolutions.jts.geom.MultiPolygon;
* Feb 14, 2013 mnash Move QueryScript to use new Python concurrency implementation
* Jan 13, 2015 3955 randerso Improve handling of Topo parm for Standard Terrain editing
* Jun 24, 2015 14401 yteng Check whether activeDisplay is disposed before update
* Aug 27, 2015 4749 njensen Reused reference to PythonJobCoordinator instance
* Aug 27, 2015 4749 njensen Reused reference to PythonJobCoordinator instance
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -853,12 +850,8 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
}
private void submit() {
Map<String, Object> argMap = new HashMap<String, Object>(1, 1f);
final String s = this.queryField.getText().trim();
AbstractPythonScriptFactory<QueryScript> factory = new QueryScriptFactory(
DataManagerUIFactory.getCurrentInstance());
PythonJobCoordinator<QueryScript> coordinator = PythonJobCoordinator
.getInstance(factory.getName());
Map<String, Object> argMap = new HashMap<String, Object>();
argMap.put("expression", s);
IPythonExecutor<QueryScript, ReferenceData> executor = new QueryScriptExecutor(
"evaluate", argMap);
@ -881,22 +874,21 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
addToHistory(s);
if (activeDisplay != null
|| !activeDisplay.isDisposed())
|| !activeDisplay.isDisposed()) {
activeDisplay.setText(s);
}
if (queryField != null && !queryField.isDisposed())
if (queryField != null && !queryField.isDisposed()) {
queryField.setText("");
}
}
};
});
}
};
try {
coordinator.submitAsyncJob(executor, listener);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to submit job to ExecutorService", e);
}
refSetMgr.getPythonThreadPool().submitJobWithCallback(executor,
listener);
}
/*

View file

@ -26,7 +26,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonIncludePathUtil;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.viz.gfe.core.DataManager;
@ -41,21 +41,22 @@ import com.raytheon.viz.gfe.core.DataManager;
* Feb 25, 2010 4108 ryu Add user/site directories to include path
* May 20, 2015 4509 njensen Added time and dataaccess to include path
* Jul 27, 2015 #4263 dgilling Refactor and make abstract.
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
* `1
*
* @author njensen
* @version 1.0
*/
public abstract class ProcedureFactory<C extends ProcedureController> extends
AbstractPythonScriptFactory<C> {
public abstract class ProcedureFactory<C extends ProcedureController>
implements PythonInterpreterFactory<C> {
protected final DataManager dataMgr;
public ProcedureFactory(String name, int numThreads,
final DataManager dataMgr) {
super(name, numThreads);
public ProcedureFactory(final DataManager dataMgr) {
this.dataMgr = dataMgr;
}

View file

@ -53,6 +53,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 24, 2015 #4263 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -66,6 +67,10 @@ public final class ProcedureMetadataManager implements
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
private static final String THREAD_POOL_NAME = "procedure-metadata";
private static final int NUM_POOL_THREADS = 1;
private final PythonJobCoordinator<ProcedureMetadataController> jobCoordinator;
private final Map<String, ProcedureMetadata> metadata;
@ -79,7 +84,8 @@ public final class ProcedureMetadataManager implements
public ProcedureMetadataManager(final DataManager dataMgr) {
ProcedureMetadataScriptFactory scriptFactory = new ProcedureMetadataScriptFactory(
dataMgr);
this.jobCoordinator = PythonJobCoordinator.newInstance(scriptFactory);
this.jobCoordinator = new PythonJobCoordinator<>(NUM_POOL_THREADS,
THREAD_POOL_NAME, scriptFactory);
this.metadata = new HashMap<>();
this.accessLock = new Object();
@ -109,7 +115,7 @@ public final class ProcedureMetadataManager implements
}
};
try {
jobCoordinator.submitAsyncJob(executor, listener);
jobCoordinator.submitJobWithCallback(executor, listener);
} catch (Exception e1) {
statusHandler.error("Error initializing procedure metadata.", e1);
}
@ -199,7 +205,7 @@ public final class ProcedureMetadataManager implements
}
};
try {
jobCoordinator.submitAsyncJob(executor, listener);
jobCoordinator.submitJobWithCallback(executor, listener);
} catch (Exception e1) {
statusHandler.error("Error updating procedure metadata.", e1);
}

View file

@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 24, 2015 #4263 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -43,21 +44,10 @@ import com.raytheon.viz.gfe.core.DataManager;
public final class ProcedureMetadataScriptFactory extends
ProcedureFactory<ProcedureMetadataController> {
private static final String SCRIPT_EXECUTOR_NAME = "procedure-metadata";
private static final int EXECUTOR_NUM_THREADS = 1;
public ProcedureMetadataScriptFactory(final DataManager dataMgr) {
super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr);
super(dataMgr);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory#
* createPythonScript()
*/
@Override
public ProcedureMetadataController createPythonScript() throws JepException {
return new ProcedureMetadataController(buildScriptPath(),

View file

@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2015 #4263 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -43,17 +44,8 @@ import com.raytheon.viz.gfe.core.DataManager;
public final class ProcedureRunnerScriptFactory extends
ProcedureFactory<ProcedureRunnerController> {
/*
* These constants that are passed to the super constructor only matter if
* procedure execution gets hooked into our python concurrent execution
* framework. Since it isn't we use dummy values for now...
*/
private static final String SCRIPT_EXECUTOR_NAME = "procedure-runner";
private static final int EXECUTOR_NUM_THREADS = 0;
public ProcedureRunnerScriptFactory(final DataManager dataMgr) {
super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr);
super(dataMgr);
}
/*

View file

@ -23,7 +23,7 @@ import java.io.IOException;
import jep.JepException;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -38,7 +38,8 @@ import com.raytheon.viz.gfe.core.DataManager;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 7, 2013 mnash Initial creation
* Feb 07, 2013 mnash Initial creation
* Dec 14, 2015 #4816 dgilling Rewrite based on PythonInterpreterFactory.
*
* </pre>
*
@ -46,8 +47,8 @@ import com.raytheon.viz.gfe.core.DataManager;
* @version 1.0
*/
public class QueryScriptFactory extends
AbstractPythonScriptFactory<QueryScript> {
public class QueryScriptFactory implements
PythonInterpreterFactory<QueryScript> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(QueryScriptFactory.class);
@ -57,25 +58,9 @@ public class QueryScriptFactory extends
*
*/
public QueryScriptFactory(DataManager dataMgr) {
this("gfequeryscript", 1);
this.manager = dataMgr;
}
/**
* @param name
* @param maxThreads
*/
public QueryScriptFactory(String name, int maxThreads) {
super(name, maxThreads);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory#
* createPythonScript()
*/
@Override
public QueryScript createPythonScript() {
try {

View file

@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.IPythonExecutor;
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
import com.raytheon.uf.common.status.IPerformanceStatusHandler;
@ -56,7 +55,6 @@ import com.raytheon.viz.gfe.core.parm.Parm;
import com.raytheon.viz.gfe.core.parm.ParmState;
import com.raytheon.viz.gfe.query.QueryScript;
import com.raytheon.viz.gfe.query.QueryScriptExecutor;
import com.raytheon.viz.gfe.query.QueryScriptFactory;
import com.raytheon.viz.gfe.smarttool.SmartToolException.ErrorType;
import com.raytheon.viz.gfe.smarttool.script.SmartToolRunnerController;
@ -77,6 +75,7 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolRunnerController;
* Aug 27, 2015 4749 njensen Call shutdown() on PythonJobCoordinator
* Sep 16, 2015 4871 randerso Return modified varDict from Tool
* 10/08/2015 18125 bhunder Modified CANCEL_MSG_START to work with Jep updates
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -127,22 +126,21 @@ public class Tool {
* @throws SmartToolException
*/
public Tool(IParmManager aParmMgr, Parm anInputParm, String aToolName,
PythonJobCoordinator<QueryScript> coordinator,
SmartToolRunnerController aTool) throws SmartToolException {
parmMgr = aParmMgr;
inputParm = anInputParm;
toolName = aToolName;
tool = aTool;
this.parmMgr = aParmMgr;
this.inputParm = anInputParm;
this.toolName = aToolName;
this.tool = aTool;
this.coordinator = coordinator;
AbstractPythonScriptFactory<QueryScript> factory = new QueryScriptFactory(
DataManagerUIFactory.getCurrentInstance());
coordinator = PythonJobCoordinator.newInstance(factory);
try {
if (!tool.isInstantiated(toolName)) {
tool.instantiatePythonScript(toolName);
if (!this.tool.isInstantiated(toolName)) {
this.tool.instantiatePythonScript(toolName);
}
} catch (JepException e) {
throw new SmartToolException("Error instantiating python tool "
+ toolName + ": " + e.getMessage());
+ this.toolName + ": " + e.getMessage());
}
}
@ -511,8 +509,8 @@ public class Tool {
IPythonExecutor<QueryScript, ReferenceData> executor = new QueryScriptExecutor(
"evaluate", argMap);
try {
Tool.this.trueEditArea = coordinator
.submitSyncJob(executor);
Tool.this.trueEditArea = coordinator.submitJob(
executor).get();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error re-evaluating edit area "

View file

@ -26,7 +26,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonIncludePathUtil;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.viz.gfe.core.DataManager;
@ -41,6 +41,7 @@ import com.raytheon.viz.gfe.core.DataManager;
* Jul 9, 2009 2454 ryu Put user and site's python scripts on path for import
* May 20, 2015 4509 njensen Added time and dataaccess to include path
* Jul 23, 2015 4263 dgilling Refactored to support changes to SmartToolController.
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -48,14 +49,12 @@ import com.raytheon.viz.gfe.core.DataManager;
* @version 1.0
*/
public abstract class SmartToolFactory<C extends SmartToolController> extends
AbstractPythonScriptFactory<C> {
public abstract class SmartToolFactory<C extends SmartToolController>
implements PythonInterpreterFactory<C> {
protected final DataManager dataMgr;
public SmartToolFactory(String name, int numThreads,
final DataManager dataMgr) {
super(name, numThreads);
public SmartToolFactory(final DataManager dataMgr) {
this.dataMgr = dataMgr;
}

View file

@ -358,7 +358,8 @@ public class SmartToolJobPool {
dataMgr.getParmOp().clearUndoParmList();
}
Tool tool = new Tool(dataMgr.getParmManager(), request
.getPreview().getParm(), ea.getItemName(), controller);
.getPreview().getParm(), ea.getItemName(), dataMgr
.getRefManager().getPythonThreadPool(), controller);
tool.execute(ea.getItemName(), request.getPreview().getParm(),
ea.getRefSet(), ea.getTimeRange(),
request.getVarDict(), ea.getMissingDataMode(), monitor);

View file

@ -58,6 +58,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 20, 2015 #4263 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -70,6 +71,10 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
private static final String THREAD_POOL_NAME = "smart-tool-metadata";
private static final int NUM_POOL_THREADS = 1;
private final PythonJobCoordinator<SmartToolMetadataController> jobCoordinator;
private final Map<String, SmartToolMetadata> toolMetadata;
@ -85,7 +90,8 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver {
public SmartToolMetadataManager(final DataManager dataMgr) {
SmartToolMetadataScriptFactory scriptFactory = new SmartToolMetadataScriptFactory(
dataMgr);
this.jobCoordinator = PythonJobCoordinator.newInstance(scriptFactory);
this.jobCoordinator = new PythonJobCoordinator<>(NUM_POOL_THREADS,
THREAD_POOL_NAME, scriptFactory);
this.toolMetadata = new HashMap<>();
this.accessLock = new Object();
@ -117,7 +123,7 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver {
}
};
try {
jobCoordinator.submitAsyncJob(executor, listener);
jobCoordinator.submitJobWithCallback(executor, listener);
} catch (Exception e1) {
statusHandler.error("Error initializing smart tool metadata.", e1);
}
@ -247,13 +253,6 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver {
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated
* (com.raytheon.uf.common.localization.FileUpdatedMessage)
*/
@Override
public void fileUpdated(FileUpdatedMessage message) {
SmartToolMetadataExecutor executor = new SmartToolMetadataExecutor(
@ -272,7 +271,7 @@ public class SmartToolMetadataManager implements ILocalizationFileObserver {
}
};
try {
jobCoordinator.submitAsyncJob(executor, listener);
jobCoordinator.submitJobWithCallback(executor, listener);
} catch (Exception e1) {
statusHandler.error("Error updating smart tool metadata.", e1);
}

View file

@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 22, 2015 #4263 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -43,21 +44,10 @@ import com.raytheon.viz.gfe.core.DataManager;
public final class SmartToolMetadataScriptFactory extends
SmartToolFactory<SmartToolMetadataController> {
private static final String SCRIPT_EXECUTOR_NAME = "smart-tool-metadata";
private static final int EXECUTOR_NUM_THREADS = 1;
public SmartToolMetadataScriptFactory(final DataManager dataMgr) {
super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr);
super(dataMgr);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory#
* createPythonScript()
*/
@Override
public SmartToolMetadataController createPythonScript() throws JepException {
return new SmartToolMetadataController(getScriptPath(),

View file

@ -33,6 +33,7 @@ import com.raytheon.viz.gfe.core.DataManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2015 #4263 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -43,26 +44,10 @@ import com.raytheon.viz.gfe.core.DataManager;
public final class SmartToolRunnerScriptFactory extends
SmartToolFactory<SmartToolRunnerController> {
/*
* These constants that are passed to the super constructor only matter if
* procedure execution gets hooked into our python concurrent execution
* framework. Since it isn't we use dummy values for now...
*/
private static final String SCRIPT_EXECUTOR_NAME = "smart-tool-runner";
private static final int EXECUTOR_NUM_THREADS = 0;
public SmartToolRunnerScriptFactory(final DataManager dataMgr) {
super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS, dataMgr);
super(dataMgr);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory#
* createPythonScript()
*/
@Override
public SmartToolRunnerController createPythonScript() throws JepException {
return new SmartToolRunnerController(getScriptPath(), getIncludePath(),

View file

@ -28,8 +28,8 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.PythonIncludePathUtil;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.viz.gfe.python.GfeCavePyIncludeUtil;
@ -45,6 +45,7 @@ import com.raytheon.viz.gfe.python.GfeCavePyIncludeUtil;
* Tests path for GFE formatter auto tests
* Jul 28, 2015 4263 dgilling Refactor based on AbstractPythonScriptFactory.
* Aug 21, 2015 4509 dgilling Added time and dataaccess to include path.
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -52,16 +53,8 @@ import com.raytheon.viz.gfe.python.GfeCavePyIncludeUtil;
* @version 1.0
*/
public class FormatterScriptFactory extends
AbstractPythonScriptFactory<FormatterScript> {
private static final String SCRIPT_EXECUTOR_NAME = "text-product-metadata";
private static final int EXECUTOR_NUM_THREADS = 1;
public FormatterScriptFactory() {
super(SCRIPT_EXECUTOR_NAME, EXECUTOR_NUM_THREADS);
}
public class FormatterScriptFactory implements
PythonInterpreterFactory<FormatterScript> {
private static String buildScriptPath() {
IPathManager pathMgr = PathManagerFactory.getPathManager();
@ -88,13 +81,6 @@ public class FormatterScriptFactory extends
return include;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory#
* createPythonScript()
*/
@Override
public FormatterScript createPythonScript() throws JepException {
return new FormatterScript(buildScriptPath(), buildIncludePath(),

View file

@ -61,6 +61,7 @@ import com.raytheon.viz.gfe.core.IAsyncStartupObjectListener;
* in a non-GUI environment like GFE formatter auto-tests
* Jul 30, 2015 4263 dgilling Major refactor so this object can be initialized off
* UI thread.
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -73,6 +74,10 @@ public class TextProductManager implements ILocalizationFileObserver {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
private static final String METADATA_THREAD_POOL_NAME = "text-product-metadata";
private static final int NUM_METADATA_THREADS = 1;
private String issuedBy;
private final PythonJobCoordinator<FormatterScript> jobCoordinator;
@ -95,8 +100,8 @@ public class TextProductManager implements ILocalizationFileObserver {
public TextProductManager() {
this.issuedBy = "";
FormatterScriptFactory factory = new FormatterScriptFactory();
this.jobCoordinator = PythonJobCoordinator.newInstance(factory);
this.jobCoordinator = new PythonJobCoordinator<>(NUM_METADATA_THREADS,
METADATA_THREAD_POOL_NAME, new FormatterScriptFactory());
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext baseContext = pm.getContext(
@ -129,7 +134,7 @@ public class TextProductManager implements ILocalizationFileObserver {
}
};
try {
jobCoordinator.submitAsyncJob(executor, listener);
jobCoordinator.submitJobWithCallback(executor, listener);
} catch (Exception e) {
statusHandler.error("Error building text product inventory.", e);
}
@ -270,9 +275,9 @@ public class TextProductManager implements ILocalizationFileObserver {
String officeTimeZone) {
Collection<String> timeZones = Collections.emptyList();
try {
timeZones = jobCoordinator
.submitSyncJob(new TextProductTimeZonesExecutor(zones,
officeTimeZone));
timeZones = jobCoordinator.submitJob(
new TextProductTimeZonesExecutor(zones, officeTimeZone))
.get();
} catch (Exception e) {
statusHandler.error("Exception getting time zones.", e);
}
@ -338,7 +343,7 @@ public class TextProductManager implements ILocalizationFileObserver {
}
};
try {
jobCoordinator.submitAsyncJob(executor, listener);
jobCoordinator.submitJobWithCallback(executor, listener);
} catch (Exception e) {
statusHandler.error("Error updating text product inventory.", e);
}

View file

@ -86,6 +86,7 @@ import com.raytheon.viz.pointdata.rsc.PlotResource;
* Aug 07, 2014 3478 bclement removed PointDataDescription.Type.Double
* Dec 16, 2014 16193 kshrestha Updated range limits
* Oct 27, 2015 4798 bsteffen Extend SVGImageFactory
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -93,6 +94,7 @@ import com.raytheon.viz.pointdata.rsc.PlotResource;
* @version 1.0
*/
public class PlotModelFactory extends SVGImageFactory {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PlotModelFactory.class);
@ -120,6 +122,8 @@ public class PlotModelFactory extends SVGImageFactory {
private final SimpleDateFormat SAMPLE_DATE = new SimpleDateFormat("HHmm");
private static final int NUM_POOL_THREADS = 1;
private int width = 1;
private LineStyle lineStyle = LineStyle.DEFAULT;
@ -141,7 +145,7 @@ public class PlotModelFactory extends SVGImageFactory {
private final IMapDescriptor mapDescriptor;
private RGB color;
private final List<PlotModelElement> plotFields;
private final List<PlotModelElement> sampleFields;
@ -294,7 +298,8 @@ public class PlotModelFactory extends SVGImageFactory {
if (scriptText.length() > 0) {
PlotPythonScriptFactory pythonFactory = new PlotPythonScriptFactory(
plotModelFile, scriptText, plotDelegateName);
python = PythonJobCoordinator.newInstance(pythonFactory);
python = new PythonJobCoordinator<>(NUM_POOL_THREADS,
plotModelFile, pythonFactory);
}
/*
@ -536,7 +541,7 @@ public class PlotModelFactory extends SVGImageFactory {
CheckPlotValidityExecutor task = new CheckPlotValidityExecutor(
stationData);
try {
result = python.submitSyncJob(task);
result = python.submitJob(task).get();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error checking if plot is valid for plot model "
@ -638,7 +643,7 @@ public class PlotModelFactory extends SVGImageFactory {
String result = null;
SampleTextExecutor task = new SampleTextExecutor(stationData);
try {
result = python.submitSyncJob(task);
result = python.submitJob(task).get();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error getting sample text for plot model "
@ -1077,8 +1082,9 @@ public class PlotModelFactory extends SVGImageFactory {
if (element.lookup != null && sValue != null) {
String lu = null;
lu = element.lookup.lookup(sValue);
if (!lu.equals(""))
if (!lu.equals("")) {
sValue = lu;
}
}
if (sValue != null) {
element.plotNode.setNodeValue(sValue.substring(element.trim));

View file

@ -27,7 +27,7 @@ import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.viz.pointdata.PlotModelFactory;
/**
@ -44,6 +44,7 @@ import com.raytheon.viz.pointdata.PlotModelFactory;
* ------------- -------- ----------- --------------------------
* Mar 14, 2014 2868 njensen Initial creation
* Jun 06, 2014 2061 bsteffen Remove old PlotResource
* Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -51,13 +52,15 @@ import com.raytheon.viz.pointdata.PlotModelFactory;
* @version 1.0
*/
public class PlotPythonScriptFactory extends
AbstractPythonScriptFactory<PlotPythonScript> {
public class PlotPythonScriptFactory implements
PythonInterpreterFactory<PlotPythonScript> {
private static String includePath;
private static String baseFilePath;
protected String plotSvgName;
protected String scriptText;
protected String plotDelegateName;
@ -76,7 +79,7 @@ public class PlotPythonScriptFactory extends
*/
public PlotPythonScriptFactory(String plotSvgName, String scriptText,
String plotDelegateName) {
super(plotSvgName, 1);
this.plotSvgName = plotSvgName;
this.scriptText = scriptText;
this.plotDelegateName = plotDelegateName;
}
@ -112,6 +115,6 @@ public class PlotPythonScriptFactory extends
}
return new PlotPythonScript(baseFilePath, includePath, scriptText,
plotDelegateName, this.getName());
plotDelegateName, plotSvgName);
}
}

View file

@ -370,41 +370,29 @@
<bean id="ifpnetCDFFactory" class="com.raytheon.edex.plugin.gfe.isc.IscScriptFactory">
<constructor-arg value="ifpnetCDF"/>
<constructor-arg value="2"/>
</bean>
<bean name="ifpnetCDFPythonThreadPool" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator.newInstance"/>
<property name="arguments">
<list>
<ref bean="ifpnetCDFFactory"/>
</list>
</property>
<bean id="ifpnetCDFPythonThreadPool" class="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator">
<constructor-arg value="2" />
<constructor-arg value="ifpnetCDF" />
<constructor-arg ref="ifpnetCDFFactory"/>
</bean>
<bean id="iscMosaicFactory" class="com.raytheon.edex.plugin.gfe.isc.IscScriptFactory">
<constructor-arg value="iscMosaic"/>
<constructor-arg value="2"/>
</bean>
<bean name="iscMosaicPythonThreadPool" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator.newInstance"/>
<property name="arguments">
<list>
<ref bean="iscMosaicFactory"/>
</list>
</property>
<bean id="iscMosaicPythonThreadPool" class="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator">
<constructor-arg value="2" />
<constructor-arg value="iscMosaic" />
<constructor-arg ref="iscMosaicFactory" />
</bean>
<bean id="iscDataRecFactory" class="com.raytheon.edex.plugin.gfe.isc.IscScriptFactory">
<constructor-arg value="iscDataRec"/>
<constructor-arg value="2"/>
</bean>
<bean name="iscDataRecPythonThreadPool" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator.newInstance"/>
<property name="arguments">
<list>
<ref bean="iscDataRecFactory"/>
</list>
</property>
<bean id="iscDataRecPythonThreadPool" class="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator">
<constructor-arg value="2" />
<constructor-arg value="iscDataRec" />
<constructor-arg ref="iscDataRecFactory" />
</bean>
<!-- End Additional ISC Beans -->

View file

@ -148,7 +148,7 @@ public class IscReceiveSrv {
IscScriptExecutor executor = new IscScriptExecutor(METHOD_NAME,
siteArgs.getKey(), args);
try {
threadPool.submitAsyncJob(executor, jobListener);
threadPool.submitJobWithCallback(executor, jobListener);
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,

View file

@ -21,10 +21,9 @@ package com.raytheon.edex.plugin.gfe.isc;
import jep.JepException;
import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory;
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Instantiates a {@link IscScript} on a separate thread.
@ -36,6 +35,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 11, 2013 dgilling Initial creation
* Dec 14, 2015 #4816 dgilling Support refactored PythonJobCoordinator API.
*
* </pre>
*
@ -43,35 +43,35 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* @version 1.0
*/
public class IscScriptFactory extends AbstractPythonScriptFactory<IscScript> {
public class IscScriptFactory implements PythonInterpreterFactory<IscScript> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(IscScriptFactory.class);
private static final String SCRIPT_EXTENSION = ".py";
private final String name;
/**
* Construct a new script factory for the python module with the specified
* name.
*
* @param name
* @param maxThreads
* The name of the python module (minus the .py extension) that
* this factory will build {@code IscScript} instances for.
*/
public IscScriptFactory(String name, int maxThreads) {
super(name, maxThreads);
public IscScriptFactory(String name) {
this.name = name;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory#
* createPythonScript()
*/
@Override
public IscScript createPythonScript() {
try {
return new IscScript(getName() + SCRIPT_EXTENSION);
return new IscScript(name + SCRIPT_EXTENSION);
} catch (JepException e) {
statusHandler.handle(Priority.ERROR,
"Unable to create GFE ISC script [" + getName() + "]", e);
statusHandler
.error(String.format(
"Unable to create GFE ISC script [%s]", name), e);
}
return null;
}

View file

@ -21,6 +21,7 @@ package com.raytheon.edex.plugin.gfe.server.handler;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import com.raytheon.edex.plugin.gfe.isc.IscScript;
import com.raytheon.edex.plugin.gfe.isc.IscScriptExecutor;
@ -107,8 +108,9 @@ public class ExecuteIfpNetCDFGridRequestHandler implements
args.put("siteIdOverride", request.getSiteIdOverride());
IscScriptExecutor executor = new IscScriptExecutor(METHOD_NAME,
request.getSiteID(), args);
String retVal = threadPool.submitSyncJob(executor);
Future<String> task = threadPool.submitJob(executor);
String retVal = task.get();
if (retVal != null) {
sr.addMessage(retVal);
return sr;

View file

@ -2,6 +2,7 @@ package com.raytheon.edex.plugin.gfe.server.handler;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import com.raytheon.edex.plugin.gfe.isc.IscScript;
import com.raytheon.edex.plugin.gfe.isc.IscScriptExecutor;
@ -76,8 +77,9 @@ public class ExecuteIscMosaicRequestHandler implements
IscScriptExecutor executor = new IscScriptExecutor(METHOD_NAME,
request.getSiteID(), args);
String retVal = threadPool.submitSyncJob(executor);
Future<String> task = threadPool.submitJob(executor);
String retVal = task.get();
if (retVal != null) {
sr.addMessage(retVal);
return sr;