- log.info("##\n## Process SLC Execution " + slcExecution+"\n##");
-
- for(RealizedFlow flow : slcExecution.getRealizedFlows()) {
- ExecutionModule module = getExecutionModule(flow.getModuleName(),
- flow.getModuleVersion());
- if(module != null) {
- ExecutionContext executionContext = new ExecutionContext();
-
- // convert the values of flow.getFlowDescriptor()
- Map<String, Object> values = flow.getFlowDescriptor().getValues();
-
- Map<String, Object> convertedValues = new HashMap<String, Object>();
-
- for(String key : values.keySet()) {
- Object value = values.get(key);
- if(value instanceof PrimitiveValue) {
- PrimitiveValue primitiveValue = (PrimitiveValue) value;
-
- // TODO: check that the class of the the primitiveValue.value matches
- // the primitiveValue.type
- convertedValues.put(key, primitiveValue.getValue());
- }
- else if(value instanceof RefValue) {
- RefValue refValue = (RefValue) value;
- convertedValues.put(key, refValue.getLabel());
+ new ProcessThread(slcExecution).start();
+ }
+
+ protected void dispatchUpdateStatus(SlcExecution slcExecution,
+ String oldStatus, String newStatus) {
+ for (Iterator<SlcExecutionNotifier> it = slcExecutionNotifiers
+ .iterator(); it.hasNext();) {
+ it.next().updateStatus(slcExecution, oldStatus, newStatus);
+ }
+ }
+
+ public void setSlcExecutionNotifiers(
+ List<SlcExecutionNotifier> slcExecutionNotifiers) {
+ this.slcExecutionNotifiers = slcExecutionNotifiers;
+ }
+
+ private class ProcessThread extends Thread {
+ private final SlcExecution slcExecution;
+ private final List<RealizedFlow> flowsToProcess = new ArrayList<RealizedFlow>();
+
+ public ProcessThread(SlcExecution slcExecution) {
+ this.slcExecution = slcExecution;
+ }
+
+ public void run() {
+ log.info("\n##\n## Process SLC Execution " + slcExecution
+ + "\n##\n");
+
+ // FIXME: hack to let the SlcExecution be registered on server
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e1) {
+ // silent
+ }
+
+ slcExecution.setStatus(SlcExecution.STATUS_RUNNING);
+ dispatchUpdateStatus(slcExecution, SlcExecution.STATUS_SCHEDULED,
+ SlcExecution.STATUS_RUNNING);
+
+ flowsToProcess.addAll(slcExecution.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