Changeset 34
- Timestamp:
- 03/01/08 15:19:15 (17 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DistributedEngine/DistributedEngine.cs
r33 r34 90 90 if(runningEngines.Count != 0) { 91 91 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); 96 96 IScope oldScope = engineOperations[engineGuid].Scope; 97 97 oldScope.Clear(); 98 foreach(IVariable variable in newScope.Variables) {98 foreach(IVariable variable in resultEngine.InitialOperation.Scope.Variables) { 99 99 oldScope.AddVariable(variable); 100 100 } 101 foreach(IScope subScope in newScope.SubScopes) {101 foreach(IScope subScope in resultEngine.InitialOperation.Scope.SubScopes) { 102 102 oldScope.AddSubScope(subScope); 103 103 } -
trunk/sources/HeuristicLab.Grid/ClientForm.cs
r32 r34 102 102 if (InvokeRequired) { Invoke((MethodInvoker)delegate() { statusTextBox.Text = "Executing engine"; }); } else statusTextBox.Text = "Executing engine"; 103 103 currentEngine.Finished += delegate(object src, EventArgs args) { 104 byte[] result ScopeXml = SaveScope(currentEngine.InitialOperation.Scope);105 engineStore.StoreResult(currentGuid, result ScopeXml);104 byte[] resultXml = SaveEngine(currentEngine); 105 engineStore.StoreResult(currentGuid, resultXml); 106 106 currentGuid = Guid.Empty; 107 107 currentEngine = null; … … 127 127 return (ProcessingEngine)PersistenceManager.Load(stream); 128 128 } 129 private byte[] Save Scope(IScope scope) {129 private byte[] SaveEngine(IEngine engine) { 130 130 MemoryStream memStream = new MemoryStream(); 131 131 GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true); 132 PersistenceManager.Save( scope, stream);132 PersistenceManager.Save(engine, stream); 133 133 stream.Close(); 134 134 return memStream.ToArray(); -
trunk/sources/HeuristicLab.Grid/EngineStore.cs
r33 r34 29 29 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)] 30 30 public class EngineStore : IEngineStore { 31 private Queue<Guid> engineQueue;31 private List<Guid> engineList; 32 32 private Dictionary<Guid, byte[]> waitingEngines; 33 33 private Dictionary<Guid, byte[]> runningEngines; … … 56 56 57 57 public EngineStore() { 58 engine Queue = new Queue<Guid>();58 engineList = new List<Guid>(); 59 59 waitingEngines = new Dictionary<Guid, byte[]>(); 60 60 runningEngines = new Dictionary<Guid, byte[]>(); … … 75 75 public bool TryTakeEngine(string clientUrl, out Guid guid, out byte[] engine) { 76 76 lock(bigLock) { 77 if(engine Queue.Count == 0) {77 if(engineList.Count == 0) { 78 78 guid = Guid.Empty; 79 79 engine = null; 80 80 return false; 81 81 } else { 82 guid = engineQueue.Dequeue(); 82 guid = engineList[0]; 83 engineList.RemoveAt(0); 83 84 engine = waitingEngines[guid]; 84 85 waitingEngines.Remove(guid); … … 103 104 internal void AddEngine(Guid guid, byte[] engine) { 104 105 lock(bigLock) { 105 engine Queue.Enqueue(guid);106 engineList.Add(guid); 106 107 waitingEngines.Add(guid, engine); 107 108 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;116 109 } 117 110 } … … 144 137 if(runningClients.ContainsKey(guid)) { 145 138 clientUrl = runningClients[guid]; 146 }147 148 if(clientUrl != "") {149 139 IClient client = clientChannelFactory.CreateChannel(new EndpointAddress(clientUrl)); 150 140 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); 151 146 } 152 147 }
Note: See TracChangeset
for help on using the changeset viewer.