Free cookie consent management tool by TermsFeed Policy Generator

Changeset 413


Ignore:
Timestamp:
07/31/08 10:07:09 (16 years ago)
Author:
gkronber
Message:

fixed #218 (DistributedEngine silently ignores when grid-jobs are canceled (because of exceptions) on grid-clients) by adding a property that holds an error message to the ProcessingEngine

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DistributedEngine/DistributedEngine.cs

    r412 r413  
    127127              }
    128128            }
     129
     130            CompositeOperation canceledOperations = new CompositeOperation();
     131            canceledOperations.ExecuteInParallel = true;
    129132            // retrieve results and merge into scope-tree
    130133            foreach(AtomicOperation parOperation in compositeOperation.Operations) {
    131134              ProcessingEngine resultEngine = jobManager.EndExecuteOperation(parOperation);
    132135              if(resultEngine.Canceled) {
    133                 // When the engine was canceled because of a problem at the client we can try to execute the steps locally.
    134                 // If they also fail the (local) distributued-engine will be aborted and we will see an error-message.
    135                 // so just push the original parallel operation back on the stack to force local execution.
    136                 ExecutionStack.Push(parOperation);
     136                ThreadPool.QueueUserWorkItem(delegate(object state) { OnExceptionOccurred(new JobExecutionException(resultEngine.ErrorMessage)); });
     137                canceledOperations.AddOperation(parOperation);
    137138              } else {
    138139                // if everything went fine we can merge the results into our local scope-tree
    139140                MergeScope(parOperation.Scope, resultEngine.InitialOperation.Scope);
    140141              }
     142            }
     143
     144            if(canceledOperations.Operations.Count > 0) {
     145              myExecutionStack.Push(canceledOperations);
     146              Abort();
    141147            }
    142148          } catch(Exception e) {
  • trunk/sources/HeuristicLab.Grid/ProcessingEngine.cs

    r412 r413  
    3636    }
    3737
     38    private string errorMessage;
     39    public string ErrorMessage {
     40      get { return errorMessage; }
     41    }
     42
    3843    public ProcessingEngine()
    3944      : base() {
     
    5156      canceledAttr.Value = Canceled.ToString();
    5257      node.Attributes.Append(canceledAttr);
     58      if(errorMessage != null) {
     59        XmlAttribute errorMessageAttr = document.CreateAttribute("ErrorMessage");
     60        errorMessageAttr.Value = ErrorMessage;
     61        node.Attributes.Append(errorMessageAttr);
     62      }
    5363      node.AppendChild(PersistenceManager.Persist("InitialOperation", initialOperation, document, persistedObjects));
    5464      return node;
     
    5868      base.Populate(node, restoredObjects);
    5969      myCanceled = bool.Parse(node.Attributes["Canceled"].Value);
     70      if(node.Attributes["ErrorMessage"] != null) errorMessage = node.Attributes["ErrorMessage"].Value;
    6071      initialOperation = (AtomicOperation)PersistenceManager.Restore(node.SelectSingleNode("InitialOperation"), restoredObjects);
    6172    }
     
    6980          next = atomicOperation.Operator.Execute(atomicOperation.Scope);
    7081        } catch(Exception ex) {
    71           Trace.TraceWarning("Exception while executing an engine.\n" + ex.Message + "\n" + ex.StackTrace);
     82          errorMessage = CreateErrorMessage(ex);
     83          Trace.TraceWarning(errorMessage);
    7284          // push operation on stack again
    7385          myExecutionStack.Push(atomicOperation);
     
    8395      }
    8496    }
     97
     98    private string CreateErrorMessage(Exception ex) {
     99      StringBuilder sb = new StringBuilder();
     100      sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     101
     102      while(ex.InnerException != null) {
     103        ex = ex.InnerException;
     104        sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     105      }
     106      return sb.ToString();
     107    }
    85108  }
    86109}
Note: See TracChangeset for help on using the changeset viewer.