Remove SLC process notifiers
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 27 Feb 2013 12:46:52 +0000 (12:46 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 27 Feb 2013 12:46:52 +0000 (12:46 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6091 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

12 files changed:
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessEditor.java
runtime/org.argeo.slc.core/pom.xml
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/AbstractExecutionModulesManager.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultAgent.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultProcess.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ExecutionThread.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThread.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThreadGroup.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModulesManager.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionProcessNotifier.java [deleted file]
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/SlcAgent.java
runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/equinox/ExecutionCommandProvider.java

index a8d7b1fb37f9251a04062e7bed34ade0391546fa..75df4d320407c8c01f1448652def44be3ab2dfca 100644 (file)
@@ -16,7 +16,6 @@
 package org.argeo.slc.client.ui.editors;
 
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -33,8 +32,6 @@ import org.argeo.slc.client.ui.ClientUiPlugin;
 import org.argeo.slc.client.ui.controllers.ProcessController;
 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.jcr.SlcJcrUtils;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
@@ -47,8 +44,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.editor.FormEditor;
 
 /** Editor for an execution process. */
-public class ProcessEditor extends FormEditor implements
-               ExecutionProcessNotifier, SlcTypes, SlcNames {
+public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames {
        public final static String ID = ClientUiPlugin.ID + ".processEditor";
 
        private Session session;
@@ -153,7 +149,7 @@ public class ProcessEditor extends FormEditor implements
                        Map<String, String> properties = new HashMap<String, String>();
                        properties.put(ExecutionModulesManager.SLC_PROCESS_ID,
                                        process.getUuid());
-                       modulesManager.registerProcessNotifier(this, properties);
+                       // modulesManager.registerProcessNotifier(this, properties);
                } catch (Exception e) {
                        ErrorFeedback.show("Execution of " + processNode + " failed", e);
                }
@@ -249,12 +245,13 @@ public class ProcessEditor extends FormEditor implements
                return false;
        }
 
-       public void updateStatus(ExecutionProcess process, String oldStatus,
-                       String newStatus) {
-       }
-
-       public void addSteps(ExecutionProcess process, List<ExecutionStep> steps) {
-       }
+       // public void updateStatus(ExecutionProcess process, String oldStatus,
+       // String newStatus) {
+       // }
+       //
+       // public void addSteps(ExecutionProcess process, List<ExecutionStep> steps)
+       // {
+       // }
 
        /** Expects one session per editor. */
        public void setSession(Session session) {
index 1c26c4f32e0eee492aee5fa5815b1c5fc3392f1e..63017d913257f160cd367b9cf68bc661d5b7b327 100644 (file)
                        <groupId>org.argeo.tp</groupId>
                        <artifactId>org.apache.commons.exec</artifactId>
                </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>org.apache.commons.cli</artifactId>
+               </dependency>
 
                <dependency>
                        <groupId>org.argeo.tp</groupId>
index cf44981cdb51c7b74f68c801e577e117378559ef..1a07313f002273ff234f39c888760e9e1d685b6b 100644 (file)
  */
 package org.argeo.slc.core.execution;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -28,9 +23,6 @@ import org.argeo.slc.execution.ExecutionContext;
 import org.argeo.slc.execution.ExecutionFlow;
 import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
 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.RealizedFlow;
 
 /** Provides the base feature of an execution module manager. */
@@ -39,8 +31,8 @@ public abstract class AbstractExecutionModulesManager implements
        private final static Log log = LogFactory
                        .getLog(AbstractExecutionModulesManager.class);
 
-       private List<FilteredNotifier> filteredNotifiers = Collections
-                       .synchronizedList(new ArrayList<FilteredNotifier>());
+//     private List<FilteredNotifier> filteredNotifiers = Collections
+//                     .synchronizedList(new ArrayList<FilteredNotifier>());
 
        protected abstract ExecutionFlow findExecutionFlow(String moduleName,
                        String moduleVersion, String flowName);
@@ -78,88 +70,88 @@ public abstract class AbstractExecutionModulesManager implements
                //
        }
 
-       public void dispatchUpdateStatus(ExecutionProcess process,
-                       String oldStatus, String newStatus) {
-               // filtered notifiers
-               for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
-                               .hasNext();) {
-                       FilteredNotifier filteredNotifier = it.next();
-                       if (filteredNotifier.receiveFrom(process))
-                               filteredNotifier.getNotifier().updateStatus(process, oldStatus,
-                                               newStatus);
-               }
-
-       }
-
-       public void dispatchAddSteps(ExecutionProcess process,
-                       List<ExecutionStep> steps) {
-               process.addSteps(steps);
-               for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
-                               .hasNext();) {
-                       FilteredNotifier filteredNotifier = it.next();
-                       if (filteredNotifier.receiveFrom(process))
-                               filteredNotifier.getNotifier().addSteps(process, steps);
-               }
-       }
-
-       public void registerProcessNotifier(ExecutionProcessNotifier notifier,
-                       Map<String, String> properties) {
-               filteredNotifiers.add(new FilteredNotifier(notifier, properties));
-       }
-
-       public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
-                       Map<String, String> properties) {
-               filteredNotifiers.remove(notifier);
-       }
-
-       protected class FilteredNotifier {
-               private final ExecutionProcessNotifier notifier;
-               private final String processId;
-
-               public FilteredNotifier(ExecutionProcessNotifier notifier,
-                               Map<String, String> properties) {
-                       super();
-                       this.notifier = notifier;
-                       if (properties == null)
-                               properties = new HashMap<String, String>();
-                       if (properties.containsKey(SLC_PROCESS_ID))
-                               processId = properties.get(SLC_PROCESS_ID);
-                       else
-                               processId = null;
-               }
-
-               /**
-                * Whether event from this process should be received by this listener.
-                */
-               public Boolean receiveFrom(ExecutionProcess process) {
-                       if (processId != null)
-                               if (process.getUuid().equals(processId))
-                                       return true;
-                               else
-                                       return false;
-                       return true;
-               }
-
-               @Override
-               public int hashCode() {
-                       return notifier.hashCode();
-               }
-
-               @Override
-               public boolean equals(Object obj) {
-                       if (obj instanceof FilteredNotifier) {
-                               FilteredNotifier fn = (FilteredNotifier) obj;
-                               return notifier.equals(fn.notifier);
-                       } else if (obj instanceof ExecutionProcessNotifier) {
-                               ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
-                               return notifier.equals(epn);
-                       } else
-                               return false;
-               }
-
-               public ExecutionProcessNotifier getNotifier() {
-                       return notifier;
-               }
-
-       }
+//     public void dispatchUpdateStatus(ExecutionProcess process,
+//                     String oldStatus, String newStatus) {
+//             // filtered notifiers
+//             for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+//                             .hasNext();) {
+//                     FilteredNotifier filteredNotifier = it.next();
+//                     if (filteredNotifier.receiveFrom(process))
+//                             filteredNotifier.getNotifier().updateStatus(process, oldStatus,
+//                                             newStatus);
+//             }
+//
+//     }
+
+//     public void dispatchAddSteps(ExecutionProcess process,
+//                     List<ExecutionStep> steps) {
+//             process.addSteps(steps);
+//             for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+//                             .hasNext();) {
+//                     FilteredNotifier filteredNotifier = it.next();
+//                     if (filteredNotifier.receiveFrom(process))
+//                             filteredNotifier.getNotifier().addSteps(process, steps);
+//             }
+//     }
+
+//     public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+//                     Map<String, String> properties) {
+//             filteredNotifiers.add(new FilteredNotifier(notifier, properties));
+//     }
+//
+//     public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
+//                     Map<String, String> properties) {
+//             filteredNotifiers.remove(notifier);
+//     }
+
+//     protected class FilteredNotifier {
+//             private final ExecutionProcessNotifier notifier;
+//             private final String processId;
+//
+//             public FilteredNotifier(ExecutionProcessNotifier notifier,
+//                             Map<String, String> properties) {
+//                     super();
+//                     this.notifier = notifier;
+//                     if (properties == null)
+//                             properties = new HashMap<String, String>();
+//                     if (properties.containsKey(SLC_PROCESS_ID))
+//                             processId = properties.get(SLC_PROCESS_ID);
+//                     else
+//                             processId = null;
+//             }
+//
+//             /**
+//              * Whether event from this process should be received by this listener.
+//              */
+//             public Boolean receiveFrom(ExecutionProcess process) {
+//                     if (processId != null)
+//                             if (process.getUuid().equals(processId))
+//                                     return true;
+//                             else
+//                                     return false;
+//                     return true;
+//             }
+//
+//             @Override
+//             public int hashCode() {
+//                     return notifier.hashCode();
+//             }
+//
+//             @Override
+//             public boolean equals(Object obj) {
+//                     if (obj instanceof FilteredNotifier) {
+//                             FilteredNotifier fn = (FilteredNotifier) obj;
+//                             return notifier.equals(fn.notifier);
+//                     } else if (obj instanceof ExecutionProcessNotifier) {
+//                             ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
+//                             return notifier.equals(epn);
+//                     } else
+//                             return false;
+//             }
+//
+//             public ExecutionProcessNotifier getNotifier() {
+//                     return notifier;
+//             }
+//
+//     }
 }
index 909fa17603382be0c74c21bdd4f757b0d3ae95ae..7d6ff315e0df40ebc99ded44d13ddc481414b594 100644 (file)
@@ -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<String, String>());
+               // modulesManager.registerProcessNotifier(this,
+               // new HashMap<String, String>());
 
                // 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<String, String>());
+//             modulesManager.unregisterProcessNotifier(this,
+//                             new HashMap<String, String>());
        }
 
        /**
@@ -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<ProcessThread> 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<ExecutionStep> 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<ExecutionStep> steps)
+       // {
+       // }
 
        /*
         * BEAN
index 06ff4d2f7048404a376a6c3ec543d7bb86ba7198..30211800fa67b5d164631e906e18949afad0980b 100644 (file)
@@ -8,11 +8,13 @@ import org.argeo.slc.execution.ExecutionProcess;
 import org.argeo.slc.execution.ExecutionStep;
 import org.argeo.slc.execution.RealizedFlow;
 
+/** Canonical implementation of an {@link ExecutionProcess} as a bean. */
 public class DefaultProcess implements ExecutionProcess {
        private String uuid = UUID.randomUUID().toString();
-       private String status;
+       private String status = ExecutionProcess.NEW;
 
        private List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
+       private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
 
        public String getUuid() {
                return uuid;
@@ -31,7 +33,7 @@ public class DefaultProcess implements ExecutionProcess {
        }
 
        public List<RealizedFlow> getRealizedFlows() {
-               return null;
+               return realizedFlows;
        }
 
        public List<ExecutionStep> getSteps() {
@@ -46,4 +48,8 @@ public class DefaultProcess implements ExecutionProcess {
                this.uuid = uuid;
        }
 
+       public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
+               this.realizedFlows = realizedFlows;
+       }
+
 }
index ec69c68d7f1ab103c87132c74ea147be692759e4..71e2100e29e078e15c7e421d4e0f211ef2c9e33c 100644 (file)
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModulesManager;
 import org.argeo.slc.execution.ExecutionStep;
 import org.argeo.slc.execution.RealizedFlow;
 import org.springframework.security.Authentication;
@@ -33,17 +34,20 @@ public class ExecutionThread extends Thread {
 
        private final static Log log = LogFactory.getLog(ExecutionThread.class);
 
+       private ExecutionModulesManager executionModulesManager;
        private final RealizedFlow realizedFlow;
-       private final ProcessThread processThread;
+       // private final ProcessThread processThread;
 
        private List<Runnable> destructionCallbacks = new ArrayList<Runnable>();
 
-       public ExecutionThread(ProcessThread processThread,
+       public ExecutionThread(ProcessThreadGroup processThreadGroup,
+                       ExecutionModulesManager executionModulesManager,
                        RealizedFlow realizedFlow) {
-               super(processThread.getProcessThreadGroup(), "Flow "
+               super(processThreadGroup, "Flow "
                                + realizedFlow.getFlowDescriptor().getName());
                this.realizedFlow = realizedFlow;
-               this.processThread = processThread;
+               this.executionModulesManager = executionModulesManager;
+               // this.processThread = processThread;
        }
 
        public void run() {
@@ -59,37 +63,40 @@ public class ExecutionThread extends Thread {
                                .getFlowDescriptor();
                String flowName = executionFlowDescriptor.getName();
 
-               dispatchAddStep(new ExecutionStep(realizedFlow.getModuleName(),
-                               ExecutionStep.PHASE_START, "Flow " + flowName));
+               getProcessThreadGroup().dispatchAddStep(
+                               new ExecutionStep(realizedFlow.getModuleName(),
+                                               ExecutionStep.PHASE_START, "Flow " + flowName));
 
                try {
                        String autoUpgrade = System
                                        .getProperty(SYSPROP_EXECUTION_AUTO_UPGRADE);
                        if (autoUpgrade != null && autoUpgrade.equals("true"))
-                               processThread.getExecutionModulesManager().upgrade(
-                                               realizedFlow.getModuleNameVersion());
+                               executionModulesManager.upgrade(realizedFlow
+                                               .getModuleNameVersion());
 
                        // START FLOW
-                       processThread.getExecutionModulesManager().execute(realizedFlow);
+                       executionModulesManager.execute(realizedFlow);
                        // END FLOW
                } catch (Exception e) {
                        // TODO: re-throw exception ?
                        String msg = "Execution of flow " + flowName + " failed.";
                        log.error(msg, e);
-                       dispatchAddStep(new ExecutionStep(realizedFlow.getModuleName(),
-                                       ExecutionStep.ERROR, msg + " " + e.getMessage()));
-                       processThread.notifyError();
+                       getProcessThreadGroup().dispatchAddStep(
+                                       new ExecutionStep(realizedFlow.getModuleName(),
+                                                       ExecutionStep.ERROR, msg + " " + e.getMessage()));
+                       // processThread.notifyError();
                } finally {
-                       processThread.flowCompleted();
-                       dispatchAddStep(new ExecutionStep(realizedFlow.getModuleName(),
-                                       ExecutionStep.PHASE_END, "Flow " + flowName));
+                       // processThread.flowCompleted();
+                       getProcessThreadGroup().dispatchAddStep(
+                                       new ExecutionStep(realizedFlow.getModuleName(),
+                                                       ExecutionStep.PHASE_END, "Flow " + flowName));
                        processDestructionCallbacks();
                }
        }
 
-       private void dispatchAddStep(ExecutionStep step) {
-               processThread.getProcessThreadGroup().dispatchAddStep(step);
-       }
+       // private void dispatchAddStep(ExecutionStep step) {
+       // getProcessThreadGroup().dispatchAddStep(step);
+       // }
 
        private synchronized void processDestructionCallbacks() {
                for (int i = destructionCallbacks.size() - 1; i >= 0; i--) {
@@ -111,11 +118,12 @@ public class ExecutionThread extends Thread {
        }
 
        protected ProcessThreadGroup getProcessThreadGroup() {
-               return processThread.getProcessThreadGroup();
+               return (ProcessThreadGroup) getThreadGroup();
+               // return processThread.getProcessThreadGroup();
        }
 
-       public RealizedFlow getRealizedFlow() {
-               return realizedFlow;
-       }
+       // public RealizedFlow getRealizedFlow() {
+       // return realizedFlow;
+       // }
 
 }
index 8e7584b2bff8bb7fbf4b790cffa7eec0d59fe79c..5552d664e9a5f01bd180fc9a248e270ec6e2d29c 100644 (file)
@@ -31,6 +31,10 @@ import org.argeo.slc.execution.RealizedFlow;
 import org.springframework.security.Authentication;
 import org.springframework.security.context.SecurityContextHolder;
 
+/**
+ * Main thread coordinating an {@link ExecutionProcess}, launching parallel or
+ * sequential {@link ExecutionThread}s.
+ */
 public class ProcessThread extends Thread {
        private final static Log log = LogFactory.getLog(ProcessThread.class);
 
@@ -41,7 +45,7 @@ public class ProcessThread extends Thread {
        private Set<ExecutionThread> executionThreads = Collections
                        .synchronizedSet(new HashSet<ExecutionThread>());
 
-       private Boolean hadAnError = false;
+       // private Boolean hadAnError = false;
        private Boolean killed = false;
 
        public ProcessThread(ThreadGroup processesThreadGroup,
@@ -50,8 +54,7 @@ public class ProcessThread extends Thread {
                super(processesThreadGroup, "SLC Process #" + process.getUuid());
                this.executionModulesManager = executionModulesManager;
                this.process = process;
-               processThreadGroup = new ProcessThreadGroup(executionModulesManager,
-                               this);
+               processThreadGroup = new ProcessThreadGroup(process);
        }
 
        public final void run() {
@@ -71,10 +74,10 @@ public class ProcessThread extends Thread {
                // Start logging
                new LoggingThread().start();
 
-               String oldStatus = process.getStatus();
+               // String oldStatus = process.getStatus();
                process.setStatus(ExecutionProcess.RUNNING);
-               executionModulesManager.dispatchUpdateStatus(process, oldStatus,
-                               ExecutionProcess.RUNNING);
+               // executionModulesManager.dispatchUpdateStatus(process, oldStatus,
+               // ExecutionProcess.RUNNING);
 
                try {
                        process();
@@ -101,16 +104,16 @@ public class ProcessThread extends Thread {
 
        /** Make sure this is called BEFORE all the threads are interrupted. */
        private void computeFinalStatus() {
-               String oldStatus = process.getStatus();
+               // String oldStatus = process.getStatus();
                // TODO: error management at flow level?
                if (killed)
                        process.setStatus(ExecutionProcess.KILLED);
-               else if (hadAnError)
+               else if (processThreadGroup.hadAnError())
                        process.setStatus(ExecutionProcess.ERROR);
                else
                        process.setStatus(ExecutionProcess.COMPLETED);
-               executionModulesManager.dispatchUpdateStatus(process, oldStatus,
-                               process.getStatus());
+               // executionModulesManager.dispatchUpdateStatus(process, oldStatus,
+               // process.getStatus());
                log.info("\n## SLC Process #" + process.getUuid() + " "
                                + process.getStatus() + "\n");
        }
@@ -148,7 +151,8 @@ public class ProcessThread extends Thread {
                if (killed)
                        return;
 
-               ExecutionThread thread = new ExecutionThread(this, realizedFlow);
+               ExecutionThread thread = new ExecutionThread(processThreadGroup,
+                               executionModulesManager, realizedFlow);
                executionThreads.add(thread);
                thread.start();
 
@@ -158,13 +162,13 @@ public class ProcessThread extends Thread {
                return;
        }
 
-       public void notifyError() {
-               hadAnError = true;
-       }
-
-       public synchronized void flowCompleted() {
-               // notifyAll();
-       }
+//     public void notifyError() {
+//             hadAnError = true;
+//     }
+//
+//     public synchronized void flowCompleted() {
+//             // notifyAll();
+//     }
 
        public ExecutionProcess getProcess() {
                return process;
index 969c9b93fba5737c75ea723c601402f991b7d7d9..2f264bed46ea59c441a4031e895cc1d70e3e5d3a 100644 (file)
  */
 package org.argeo.slc.core.execution;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 
-import org.argeo.slc.execution.ExecutionModulesManager;
 import org.argeo.slc.execution.ExecutionProcess;
 import org.argeo.slc.execution.ExecutionStep;
 import org.springframework.security.Authentication;
@@ -28,20 +25,20 @@ import org.springframework.security.context.SecurityContextHolder;
 
 /** The thread group attached to a given {@link SlcExecution}. */
 public class ProcessThreadGroup extends ThreadGroup {
-       private final ExecutionModulesManager executionModulesManager;
-       private final ProcessThread processThread;
+       // private final ExecutionModulesManager executionModulesManager;
+       // private final ProcessThread processThread;
        private final Authentication authentication;
        private final static Integer STEPS_BUFFER_CAPACITY = 5000;
 
        private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
                        STEPS_BUFFER_CAPACITY);
 
-       public ProcessThreadGroup(ExecutionModulesManager executionModulesManager,
-                       ProcessThread processThread) {
-               super("SLC Process #" + processThread.getProcess().getUuid()
-                               + " thread group");
-               this.executionModulesManager = executionModulesManager;
-               this.processThread = processThread;
+       private Boolean hadAnError = false;
+
+       public ProcessThreadGroup(ExecutionProcess executionProcess) {
+               super("SLC Process #" + executionProcess.getUuid() + " thread group");
+               // this.executionModulesManager = executionModulesManager;
+               // this.processThread = processThread;
                this.authentication = SecurityContextHolder.getContext()
                                .getAuthentication();
        }
@@ -51,22 +48,27 @@ public class ProcessThreadGroup extends ThreadGroup {
        }
 
        public void dispatchAddStep(ExecutionStep step) {
-               ExecutionProcess slcProcess = processThread.getProcess();
-               List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
-               steps.add(step);
+               // ExecutionProcess slcProcess = processThread.getProcess();
+               // List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
+               // steps.add(step);
                // TODO clarify why we don't dispatch steps, must be a reason
                // dispatchAddSteps(steps);
-               slcProcess.addSteps(steps);
+               // slcProcess.addSteps(steps);
+               if (step.getType().equals(ExecutionStep.ERROR))
+                       hadAnError = true;
                this.steps.add(step);
        }
 
-       public void dispatchAddSteps(List<ExecutionStep> steps) {
-               ExecutionProcess slcProcess = processThread.getProcess();
-               executionModulesManager.dispatchAddSteps(slcProcess, steps);
-       }
+       // public void dispatchAddSteps(List<ExecutionStep> steps) {
+       // ExecutionProcess slcProcess = processThread.getProcess();
+       // executionModulesManager.dispatchAddSteps(slcProcess, steps);
+       // }
 
        public BlockingQueue<ExecutionStep> getSteps() {
                return steps;
        }
 
+       public Boolean hadAnError() {
+               return hadAnError;
+       }
 }
index b04eca3006b86e56152c17a08f045e02534a882a..06681747a8e2e3be3d4cfb39f0939236a7ffad72 100644 (file)
@@ -16,7 +16,6 @@
 package org.argeo.slc.execution;
 
 import java.util.List;
-import java.util.Map;
 
 import org.argeo.slc.deploy.ModulesManager;
 
@@ -44,22 +43,22 @@ public interface ExecutionModulesManager extends ModulesManager {
        /** Synchronously finds and executes an {@link ExecutionFlow}. */
        public void execute(RealizedFlow realizedFlow);
 
-       /** Notify of a status update status of the {@link ExecutionProcess} */
-       public void dispatchUpdateStatus(ExecutionProcess process,
-                       String oldStatus, String newStatus);
-
-       /** Notify that a step was added in an {@link ExecutionProcess} */
-       public void dispatchAddSteps(ExecutionProcess process,
-                       List<ExecutionStep> steps);
-
-       /**
-        * Register a notifier which will be notified based on the provided
-        * properties.
-        */
-       public void registerProcessNotifier(ExecutionProcessNotifier notifier,
-                       Map<String, String> properties);
-
-       /** Unregisters a notifier */
-       public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
-                       Map<String, String> properties);
+       // /** Notify of a status update status of the {@link ExecutionProcess} */
+//      public void dispatchUpdateStatus(ExecutionProcess process,
+//      String oldStatus, String newStatus);
+       //
+       // /** Notify that a step was added in an {@link ExecutionProcess} */
+       // public void dispatchAddSteps(ExecutionProcess process,
+       // List<ExecutionStep> steps);
+       //
+       // /**
+       // * Register a notifier which will be notified based on the provided
+       // * properties.
+       // */
+       // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties);
+       //
+       // /** Unregisters a notifier */
+       // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties);
 }
diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionProcessNotifier.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionProcessNotifier.java
deleted file mode 100644 (file)
index 28b2fed..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.slc.execution;
-
-import java.util.List;
-
-/**
- * Implementations of this interface can be notified of events related to
- * process execution.
- */
-public interface ExecutionProcessNotifier {
-       /**
-        * Notify a status change, see {@link ExecutionProcess} for the list of
-        * vaailable statuses.
-        */
-       public void updateStatus(ExecutionProcess process, String oldStatus,
-                       String newStatus);
-
-       /** Notifiy of new execution steps. */
-       public void addSteps(ExecutionProcess process, List<ExecutionStep> steps);
-
-}
index 9b8acb728a8bd08753662032f935ad799f9b1dcb..38fcb24a2d7cf3cfea182e273ea4addb04098493 100644 (file)
@@ -17,8 +17,12 @@ package org.argeo.slc.execution;
 
 import java.util.List;
 
-
-/** A local agent, able to run SLC Execution locally. */
+/**
+ * A local agent can run SLC processes. It is responsible for creating their
+ * threads and integrating them with various UIs. It typically wraps
+ * {@link ExecutionModulesManager} which is used to run flows synchronously at a
+ * lower level.
+ */
 public interface SlcAgent {
        /** Agent unique identifier */
        public String getAgentUuid();
@@ -29,9 +33,14 @@ public interface SlcAgent {
        /** Kills this process */
        public void kill(ExecutionProcess process);
 
+       /**
+        * Describe all the flows provided by this execution module. Typically
+        * called in order to build a realized flow.
+        */
        public ExecutionModuleDescriptor getExecutionModuleDescriptor(
                        String moduleName, String version);
 
+       /** List all execution modules which can be processed by this agent. */
        public List<ExecutionModuleDescriptor> listExecutionModuleDescriptors();
 
        /** @return true if still alive. */
index ae99ab0c453c2a1d9eec3e80716696481a0bb6d4..25de1868d92dc7b27ea1dc60642f9c1cd477814e 100644 (file)
@@ -58,6 +58,7 @@ public class ExecutionCommandProvider implements CommandProvider {
                        }
                }
                String executionName = ci.nextArgument();
+               
 
                launch(slcCommand, firstArg, executionName);
                return "COMMAND COMPLETED";