X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FDefaultAgent.java;h=7d6ff315e0df40ebc99ded44d13ddc481414b594;hb=5187ffaff5610275cf3dbc5fb913f59126576da8;hp=909fa17603382be0c74c21bdd4f757b0d3ae95ae;hpb=57aa5d64fb38af2d98076eeaaa11573b3147cc26;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgent.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgent.java index 909fa1760..7d6ff315e 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgent.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgent.java @@ -19,6 +19,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; @@ -28,13 +29,11 @@ import org.apache.commons.logging.LogFactory; import org.argeo.slc.execution.ExecutionModuleDescriptor; import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.execution.ExecutionProcess; -import org.argeo.slc.execution.ExecutionProcessNotifier; -import org.argeo.slc.execution.ExecutionStep; import org.argeo.slc.execution.SlcAgent; import org.argeo.slc.execution.SlcAgentDescriptor; /** Implements the base methods of an SLC agent. */ -public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier { +public class DefaultAgent implements SlcAgent { private final static Log log = LogFactory.getLog(DefaultAgent.class); private SlcAgentDescriptor agentDescriptor; @@ -59,8 +58,8 @@ public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier { } processesThreadGroup = new ThreadGroup("SLC Processes of Agent #" + agentDescriptor.getUuid()); - modulesManager.registerProcessNotifier(this, - new HashMap()); + // modulesManager.registerProcessNotifier(this, + // new HashMap()); // final String module = System // .getProperty(ExecutionModulesManager.UNIQUE_LAUNCH_MODULE_PROPERTY); @@ -79,8 +78,8 @@ public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier { /** Clean up (needs to be called by overriding method) */ public void destroy() { - modulesManager.unregisterProcessNotifier(this, - new HashMap()); +// modulesManager.unregisterProcessNotifier(this, +// new HashMap()); } /** @@ -106,7 +105,14 @@ public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier { modulesManager, process); processThread.start(); runningProcesses.put(process.getUuid(), processThread); - // FIXME find a way to remove them from this register + + // clean up old processes + Iterator it = runningProcesses.values().iterator(); + while (it.hasNext()) { + ProcessThread pThread = it.next(); + if (!pThread.isAlive()) + it.remove(); + } } public void kill(ExecutionProcess process) { @@ -141,17 +147,18 @@ public class DefaultAgent implements SlcAgent, ExecutionProcessNotifier { /* * PROCESS NOTIFIER */ - public void updateStatus(ExecutionProcess process, String oldStatus, - String newStatus) { - if (newStatus.equals(ExecutionProcess.COMPLETED) - || newStatus.equals(ExecutionProcess.ERROR) - || newStatus.equals(ExecutionProcess.KILLED)) { - runningProcesses.remove(process.getUuid()); - } - } - - public void addSteps(ExecutionProcess process, List steps) { - } + // public void updateStatus(ExecutionProcess process, String oldStatus, + // String newStatus) { + // if (newStatus.equals(ExecutionProcess.COMPLETED) + // || newStatus.equals(ExecutionProcess.ERROR) + // || newStatus.equals(ExecutionProcess.KILLED)) { + // runningProcesses.remove(process.getUuid()); + // } + // } + // + // public void addSteps(ExecutionProcess process, List steps) + // { + // } /* * BEAN