+ /** Thread of the SLC Process, starting the sub executions. */
+ private class ProcessThread extends Thread {
+ private final SlcExecution slcProcess;
+ private final ThreadGroup processThreadGroup;
+ private final List<RealizedFlow> flowsToProcess = new ArrayList<RealizedFlow>();
+
+ public ProcessThread(ThreadGroup processesThreadGroup,
+ SlcExecution slcExecution) {
+ super(processesThreadGroup, "SLC Process #"
+ + slcExecution.getUuid());
+ this.slcProcess = slcExecution;
+ processThreadGroup = new ThreadGroup("SLC Process #"
+ + slcExecution.getUuid() + " thread group");
+ }
+
+ public void run() {
+ log.info("\n##\n## Process SLC Execution " + slcProcess + "\n##\n");
+
+ // FIXME: hack to let the SlcExecution be registered on server
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e1) {
+ // silent
+ }
+
+ slcProcess.setStatus(SlcExecution.STATUS_RUNNING);
+ dispatchUpdateStatus(slcProcess, SlcExecution.STATUS_SCHEDULED,
+ SlcExecution.STATUS_RUNNING);
+
+ flowsToProcess.addAll(slcProcess.getRealizedFlows());
+
+ while (flowsToProcess.size() > 0) {
+ RealizedFlow flow = flowsToProcess.remove(0);
+ ExecutionModule module = getExecutionModule(flow
+ .getModuleName(), flow.getModuleVersion());
+ if (module != null) {
+ ExecutionThread thread = new ExecutionThread(this, flow
+ .getFlowDescriptor(), module);
+ thread.start();
+ } else {
+ throw new SlcException("ExecutionModule "
+ + flow.getModuleName() + ", version "
+ + flow.getModuleVersion() + " not found.");
+ }
+
+ synchronized (this) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ // silent
+ }
+ }
+ }
+
+ slcProcess.setStatus(SlcExecution.STATUS_FINISHED);
+ dispatchUpdateStatus(slcProcess, SlcExecution.STATUS_RUNNING,
+ SlcExecution.STATUS_FINISHED);
+ }
+
+ public synchronized void flowCompleted() {
+ notifyAll();
+ }
+
+ public SlcExecution getSlcProcess() {
+ return slcProcess;
+ }
+
+ public ThreadGroup getProcessThreadGroup() {
+ return processThreadGroup;
+ }
+ }
+
+ /** Thread of a single execution */