Free cookie consent management tool by TermsFeed Policy Generator

Changeset 34


Ignore:
Timestamp:
03/01/08 15:19:15 (17 years ago)
Author:
gkronber
Message:

return the whole engine as the result instead of only the scope

(ticket ref #2)

Location:
trunk/sources
Files:
3 edited

Legend:

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

    r33 r34  
    9090      if(runningEngines.Count != 0) {
    9191        Guid engineGuid = runningEngines[0];
    92         byte[] scopeXml = server.TryEndExecuteEngine(engineGuid,100);
    93         if(scopeXml != null) {
    94           GZipStream stream = new GZipStream(new MemoryStream(scopeXml), CompressionMode.Decompress);
    95           IScope newScope = (IScope)PersistenceManager.Load(stream);
     92        byte[] resultXml = server.TryEndExecuteEngine(engineGuid,100);
     93        if(resultXml != null) {
     94          GZipStream stream = new GZipStream(new MemoryStream(resultXml), CompressionMode.Decompress);
     95          ProcessingEngine resultEngine = (ProcessingEngine)PersistenceManager.Load(stream);
    9696          IScope oldScope = engineOperations[engineGuid].Scope;
    9797          oldScope.Clear();
    98           foreach(IVariable variable in newScope.Variables) {
     98          foreach(IVariable variable in resultEngine.InitialOperation.Scope.Variables) {
    9999            oldScope.AddVariable(variable);
    100100          }
    101           foreach(IScope subScope in newScope.SubScopes) {
     101          foreach(IScope subScope in resultEngine.InitialOperation.Scope.SubScopes) {
    102102            oldScope.AddSubScope(subScope);
    103103          }
  • trunk/sources/HeuristicLab.Grid/ClientForm.cs

    r32 r34  
    102102        if (InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Executing engine"; }); } else statusTextBox.Text = "Executing engine";
    103103        currentEngine.Finished += delegate(object src, EventArgs args) {
    104           byte[] resultScopeXml = SaveScope(currentEngine.InitialOperation.Scope);
    105           engineStore.StoreResult(currentGuid, resultScopeXml);
     104          byte[] resultXml = SaveEngine(currentEngine);
     105          engineStore.StoreResult(currentGuid, resultXml);
    106106          currentGuid = Guid.Empty;
    107107          currentEngine = null;
     
    127127      return (ProcessingEngine)PersistenceManager.Load(stream);
    128128    }
    129     private byte[] SaveScope(IScope scope) {
     129    private byte[] SaveEngine(IEngine engine) {
    130130      MemoryStream memStream = new MemoryStream();
    131131      GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true);
    132       PersistenceManager.Save(scope, stream);
     132      PersistenceManager.Save(engine, stream);
    133133      stream.Close();
    134134      return memStream.ToArray();
  • trunk/sources/HeuristicLab.Grid/EngineStore.cs

    r33 r34  
    2929  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
    3030  public class EngineStore : IEngineStore {
    31     private Queue<Guid> engineQueue;
     31    private List<Guid> engineList;
    3232    private Dictionary<Guid, byte[]> waitingEngines;
    3333    private Dictionary<Guid, byte[]> runningEngines;
     
    5656
    5757    public EngineStore() {
    58       engineQueue = new Queue<Guid>();
     58      engineList = new List<Guid>();
    5959      waitingEngines = new Dictionary<Guid, byte[]>();
    6060      runningEngines = new Dictionary<Guid, byte[]>();
     
    7575    public bool TryTakeEngine(string clientUrl, out Guid guid, out byte[] engine) {
    7676      lock(bigLock) {
    77         if(engineQueue.Count == 0) {
     77        if(engineList.Count == 0) {
    7878          guid = Guid.Empty;
    7979          engine = null;
    8080          return false;
    8181        } else {
    82           guid = engineQueue.Dequeue();
     82          guid = engineList[0];
     83          engineList.RemoveAt(0);
    8384          engine = waitingEngines[guid];
    8485          waitingEngines.Remove(guid);
     
    103104    internal void AddEngine(Guid guid, byte[] engine) {
    104105      lock(bigLock) {
    105         engineQueue.Enqueue(guid);
     106        engineList.Add(guid);
    106107        waitingEngines.Add(guid, engine);
    107108        waitHandles.Add(guid, new ManualResetEvent(false));
    108       }
    109     }
    110 
    111     internal byte[] RemoveResult(Guid guid) {
    112       lock(bigLock) {
    113         byte[] result = results[guid];
    114         results.Remove(guid);
    115         return result;
    116109      }
    117110    }
     
    144137        if(runningClients.ContainsKey(guid)) {
    145138          clientUrl = runningClients[guid];
    146         }
    147 
    148         if(clientUrl != "") {
    149139          IClient client = clientChannelFactory.CreateChannel(new EndpointAddress(clientUrl));
    150140          client.Abort(guid);
     141        } else if(waitingEngines.ContainsKey(guid)) {
     142          byte[] engine = waitingEngines[guid];
     143          waitingEngines.Remove(guid);
     144          engineList.Remove(guid);
     145          results.Add(guid, engine);
    151146        }
    152147      }
Note: See TracChangeset for help on using the changeset viewer.