use of org.knime.core.node.workflow.NodeExecutionJobManagerFactory in project knime-core by knime.
the class NodeExecutionJobManagerPool method collectJobManagerFactories.
private static void collectJobManagerFactories() {
managerFactories = new LinkedHashMap<String, NodeExecutionJobManagerFactory>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
if (point == null) {
// let's throw in the default manager - otherwise things fail badly
managerFactories.put(getDefaultJobManagerFactory().getID(), getDefaultJobManagerFactory());
LOGGER.error("Invalid extension point: " + EXT_POINT_ID);
throw new IllegalStateException("ACTIVATION ERROR: " + " --> Invalid extension point: " + EXT_POINT_ID);
}
for (IConfigurationElement elem : point.getConfigurationElements()) {
String jobMgr = elem.getAttribute(EXT_POINT_ATTR_JOBMGR);
String decl = elem.getDeclaringExtension().getUniqueIdentifier();
if (jobMgr == null || jobMgr.isEmpty()) {
LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + EXT_POINT_ATTR_JOBMGR + "'");
LOGGER.error("Extension " + decl + " ignored.");
continue;
}
// try instantiating the job manager.
NodeExecutionJobManagerFactory instance = null;
try {
// TODO: THE THREADED MANAGER NEEDS TO BE RE-WRITTEN!
if (jobMgr.equals(getDefaultJobManagerFactory().getID())) {
instance = getDefaultJobManagerFactory();
} else {
instance = (NodeExecutionJobManagerFactory) elem.createExecutableExtension(EXT_POINT_ATTR_JOBMGR);
}
} catch (UnsatisfiedLinkError ule) {
// in case an implementation tries to load an external lib
// when the factory class gets loaded
LOGGER.error("Unable to load a library required for '" + jobMgr + "'");
LOGGER.error("Either specify it in the -Djava.library.path " + "option at the program's command line, or");
LOGGER.error("include it in the LD_LIBRARY_PATH variable.");
LOGGER.error("Extension " + jobMgr + " ('" + decl + "') ignored.", ule);
} catch (CoreException ex) {
Throwable cause = ex.getStatus().getException();
if (cause != null) {
LOGGER.error("Problems during initialization of job manager (with id '" + jobMgr + "'): " + cause.getMessage(), ex);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
} else {
LOGGER.error("Problems during initialization of job manager (with id '" + jobMgr + "')", ex);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
} catch (Throwable t) {
LOGGER.error("Problems during initialization of job manager (with id '" + jobMgr + "')", t);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
if (instance != null) {
/*
* make sure the ThreadedJobManagerFactory is always the first
* in the list
*/
if ((instance instanceof ThreadPool) && managerFactories.size() > 0) {
Map<String, NodeExecutionJobManagerFactory> old = managerFactories;
managerFactories = new LinkedHashMap<String, NodeExecutionJobManagerFactory>();
managerFactories.put(instance.getID(), instance);
for (Map.Entry<String, NodeExecutionJobManagerFactory> e : old.entrySet()) {
managerFactories.put(e.getKey(), e.getValue());
}
} else {
managerFactories.put(instance.getID(), instance);
}
}
}
}
use of org.knime.core.node.workflow.NodeExecutionJobManagerFactory in project knime-core by knime.
the class NodeExecutionJobManagerPool method merge.
/**
* Get the common settings for a set of job managers.
* Used from {@link WorkflowManager#getCommonSettings(org.knime.core.node.workflow.NodeID...)}.
* @param jobManagers ...
* @return ...
* @since 2.7
*/
public static NodeContainerSettings merge(final NodeExecutionJobManager[] jobManagers) {
String factoryID = null;
NodeSettings mgrSettings = null;
boolean isFirst = true;
for (NodeExecutionJobManager jobManager : jobManagers) {
String curFactoryID;
NodeSettings curMgrSettings;
if (jobManager == null) {
curFactoryID = null;
curMgrSettings = null;
} else {
curFactoryID = jobManager.getID();
NodeSettings temp = new NodeSettings(CFG_JOB_MANAGER_SETTINGS);
jobManager.save(temp);
curMgrSettings = temp;
}
if (isFirst) {
isFirst = false;
factoryID = curFactoryID;
mgrSettings = curMgrSettings;
} else if (ConvenienceMethods.areEqual(factoryID, curFactoryID)) {
if (!ConvenienceMethods.areEqual(mgrSettings, curMgrSettings)) {
mgrSettings = null;
}
} else {
// different job managers
// unassigned
curFactoryID = null;
}
}
if (factoryID == null) {
return null;
}
NodeExecutionJobManagerFactory jobManagerFactory = getJobManagerFactory(factoryID);
assert jobManagerFactory != null : "Factory ID " + factoryID + " unknown although job manager present";
NodeExecutionJobManager instance = jobManagerFactory.getInstance();
if (mgrSettings != null) {
try {
instance.load(mgrSettings);
} catch (InvalidSettingsException e) {
LOGGER.error("Settings could not be applied to job manager although " + "they retrieved from another identical instance.", e);
}
}
NodeContainerSettings result = new NodeContainerSettings();
result.setJobManager(instance);
return result;
}
use of org.knime.core.node.workflow.NodeExecutionJobManagerFactory in project knime-core by knime.
the class NodeExecutionJobManagerPool method load.
/**
* Restores a job manager given the parameters contained in the argument
* settings.
*
* @param sncSettings To load from.
* @return A customized job manager or the default one if no settings were
* stored.
* @throws InvalidSettingsException If that fails.
*/
public static NodeExecutionJobManager load(final NodeSettingsRO sncSettings) throws InvalidSettingsException {
String jobManagerID = sncSettings.getString(CFG_JOB_MANAGER_FACTORY_ID);
NodeExecutionJobManagerFactory reference = getJobManagerFactory(jobManagerID);
if (reference == null) {
throw new InvalidSettingsException("Unknown job manager factory id \"" + jobManagerID + "\" (job manager factory possibly not installed?)");
}
NodeSettingsRO sub = sncSettings.getNodeSettings(CFG_JOB_MANAGER_SETTINGS);
NodeExecutionJobManager jobManager = reference.getInstance();
jobManager.load(sub);
return jobManager;
}
Aggregations