Changeset 1830
- Timestamp:
- 05/15/09 14:25:36 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs
r1812 r1830 114 114 //Server requests to abort a job 115 115 case MessageContainer.MessageType.AbortJob: 116 engines[container.JobId].Abort(); 116 if(engines.ContainsKey(container.JobId)) 117 engines[container.JobId].Abort(); 118 else 119 Logging.Instance.Error(this.ToString(), "AbortJob: Engine doesn't exist"); 117 120 break; 118 121 //Job has been successfully aborted … … 120 123 //todo: thread this 121 124 Debug.WriteLine("Job aborted, he's dead"); 122 lock (engines) { 123 AppDomain.Unload(appDomains[container.JobId]); 124 appDomains.Remove(container.JobId); 125 engines.Remove(container.JobId); 126 jobs.Remove(container.JobId); 125 lock (engines) { 126 Guid jobId = new Guid(container.JobId.ToString()); 127 if(engines.ContainsKey(jobId)) { 128 appDomains[jobId].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 129 AppDomain.Unload(appDomains[jobId]); 130 appDomains.Remove(jobId); 131 engines.Remove(jobId); 132 jobs.Remove(jobId); 133 GC.Collect(); 134 } else 135 Logging.Instance.Error(this.ToString(), "JobAbort: Engine doesn't exist"); 127 136 } 128 137 break; 129 138 //Request a Snapshot from the Execution Engine 130 139 case MessageContainer.MessageType.RequestSnapshot: 131 engines[container.JobId].RequestSnapshot(); 140 if (engines.ContainsKey(container.JobId)) 141 engines[container.JobId].RequestSnapshot(); 142 else 143 Logging.Instance.Error(this.ToString(), "RequestSnapshot: Engine doesn't exist"); 132 144 break; 133 145 //Snapshot is ready and can be sent back to the Server … … 149 161 case MessageContainer.MessageType.Shutdown: 150 162 lock (engines) { 151 foreach (KeyValuePair<Guid, AppDomain> kvp in appDomains) 163 foreach (KeyValuePair<Guid, AppDomain> kvp in appDomains) { 164 appDomains[kvp.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 152 165 AppDomain.Unload(kvp.Value); 166 } 153 167 } 154 168 abortRequested = true; … … 165 179 Guid jId = (Guid)jobId; 166 180 try { 181 if (!engines.ContainsKey(jId)) { 182 Logging.Instance.Error(this.ToString(), "GetFinishedJob: Engine doesn't exist"); 183 return; 184 } 185 167 186 byte[] sJob = engines[jId].GetFinishedJob(); 168 187 … … 174 193 null, 175 194 true); 176 } else { 195 } else { 177 196 JobStorageManager.PersistObjectToDisc(wcfService.ServerIP, wcfService.ServerPort, jId, sJob); 178 197 lock (engines) { 198 appDomains[jId].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 179 199 AppDomain.Unload(appDomains[jId]); 180 200 appDomains.Remove(jId); … … 248 268 lock(engines) { 249 269 try { 270 appDomains[e.Result.JobId].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 250 271 AppDomain.Unload(appDomains[e.Result.JobId]); 251 272 appDomains.Remove(e.Result.JobId); … … 278 299 Logging.Instance.Info(this.ToString(), "ServerChanged has been called"); 279 300 lock (engines) { 280 foreach (KeyValuePair<Guid, AppDomain> entries in appDomains) 301 foreach (KeyValuePair<Guid, AppDomain> entries in appDomains) { 302 appDomains[entries.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 281 303 AppDomain.Unload(appDomains[entries.Key]); 304 } 282 305 appDomains = new Dictionary<Guid, AppDomain>(); 283 306 engines = new Dictionary<Guid, Executor>();
Note: See TracChangeset
for help on using the changeset viewer.