Changeset 2068 for trunk/sources
- Timestamp:
- 06/19/09 13:38:20 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Communication/3.2/WcfService.cs
r2063 r2068 278 278 /// Send back finished and Stored Job Results 279 279 /// </summary> 280 /*#region SendJobResults281 public event System.EventHandler<StoreFinishedJobResultCompletedEventArgs> ProcessStoredJobResultCompleted;282 public void ProcessStoredJobResultAsync(Guid clientId, long jobId, byte[] result, double percentage, Exception exception, bool finished) {283 if (ConnState == NetworkEnum.WcfConnState.Loggedin)284 //TODO: some sort of algo for the stored jobs285 proxy.ProcessJobResultAsync(clientId, jobId, result, percentage, exception, finished);286 }287 #endregion */288 289 280 private Stream GetStreamedJobResult(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 290 281 JobResult jobResult = -
trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs
r2063 r2068 173 173 break; 174 174 175 175 176 //When the timeslice is up 176 177 case MessageContainer.MessageType.UptimeLimitDisconnect: 177 178 Logging.Instance.Info(this.ToString(), "Uptime Limit reached, storing jobs and sending them back"); … … 211 212 #region Async Threads for the EE 212 213 214 /// <summary> 215 /// serializes the finished job and submits it to the server. If, at the time, a network connection is unavailable, the Job gets stored on the disk. 216 /// once the connection gets reestablished, the job gets submitted 217 /// </summary> 218 /// <param name="jobId"></param> 213 219 private void GetFinishedJob(object jobId) { 214 220 Guid jId = (Guid)jobId; … … 255 261 //Uptime Limit reached, now is a good time to destroy this jobs. 256 262 if (!UptimeManager.Instance.isOnline()) { 257 lock (engines) { 258 appDomains[jId].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 259 AppDomain.Unload(appDomains[jId]); 260 appDomains.Remove(jId); 261 engines.Remove(jId); 262 jobs.Remove(jId); 263 } 264 GC.Collect(); 265 263 KillAppDomain(jId); 266 264 //Still anything running? 267 265 if (engines.Count == 0) … … 277 275 //Eventhandlers for the communication with the wcf Layer 278 276 #region wcfService Events 279 277 /// <summary> 278 /// Login has returned 279 /// </summary> 280 /// <param name="sender"></param> 281 /// <param name="e"></param> 280 282 void wcfService_LoginCompleted(object sender, LoginCompletedEventArgs e) { 281 283 if (e.Result.Success) { … … 286 288 } 287 289 290 /// <summary> 291 /// A new Job from the wcfService has been received and will be started within a AppDomain. 292 /// </summary> 293 /// <param name="sender"></param> 294 /// <param name="e"></param> 288 295 void wcfService_SendJobCompleted(object sender, SendJobCompletedEventArgs e) { 289 296 if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) { 290 297 bool sandboxed = false; 291 //todo: For testing!!!292 //beat.StopHeartBeat();293 //Todo: make a set & override the equals method294 298 List<byte[]> files = new List<byte[]>(); 295 299 foreach (CachedHivePluginInfo plugininfo in PluginCache.Instance.GetPlugins(e.Result.Job.PluginsNeeded)) … … 318 322 } 319 323 324 /// <summary> 325 /// A finished job has been stored on the server 326 /// </summary> 327 /// <param name="sender"></param> 328 /// <param name="e"></param> 320 329 void wcfService_StoreFinishedJobResultCompleted(object sender, StoreFinishedJobResultCompletedEventArgs e) { 321 lock(engines) { 322 try { 323 appDomains[e.Result.JobId].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 324 AppDomain.Unload(appDomains[e.Result.JobId]); 325 appDomains.Remove(e.Result.JobId); 326 engines.Remove(e.Result.JobId); 327 jobs.Remove(e.Result.JobId); 328 } 329 catch (Exception ex) { 330 Logging.Instance.Error(this.ToString(), "Exception when unloading the appdomain: ", ex); 331 } 332 } 333 if (e.Result.Success) { 334 335 //if the engine is running again -> we sent an snapshot. Otherwise the job was finished 336 //this method has a risk concerning race conditions. 337 //better expand the sendjobresultcompltedeventargs with a boolean "snapshot?" flag 338 330 KillAppDomain(e.Result.JobId); 331 if (e.Result.Success) { 339 332 ClientStatusInfo.JobsProcessed++; 340 333 Debug.WriteLine("ProcessedJobs to:" + ClientStatusInfo.JobsProcessed); … … 344 337 } 345 338 339 /// <summary> 340 /// A snapshot has been stored on the server 341 /// </summary> 342 /// <param name="sender"></param> 343 /// <param name="e"></param> 346 344 void wcfService_ProcessSnapshotCompleted(object sender, ProcessSnapshotCompletedEventArgs e) { 347 345 Logging.Instance.Info(this.ToString(), "Snapshot " + e.Result.JobId + " has been transmitted according to plan."); 348 346 } 349 347 350 //Todo: First stop all threads, then terminate 348 /// <summary> 349 /// The server has been changed. All Appdomains and Jobs must be aborted! 350 /// </summary> 351 /// <param name="sender"></param> 352 /// <param name="e"></param> 351 353 void wcfService_ServerChanged(object sender, EventArgs e) { 352 354 Logging.Instance.Info(this.ToString(), "ServerChanged has been called"); 353 355 lock (engines) { 354 foreach (KeyValuePair<Guid, AppDomain> entries in appDomains) { 355 appDomains[entries.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 356 AppDomain.Unload(appDomains[entries.Key]); 356 foreach (KeyValuePair<Guid, Executor> entries in engines) { 357 engines[entries.Key].Abort(); 358 //appDomains[entries.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 359 //AppDomain.Unload(appDomains[entries.Key]); 357 360 } 358 appDomains = new Dictionary<Guid, AppDomain>(); 359 engines = new Dictionary<Guid, Executor>(); 360 } 361 } 362 361 //appDomains = new Dictionary<Guid, AppDomain>(); 362 //engines = new Dictionary<Guid, Executor>(); 363 //jobs = new Dictionary<Guid, Job>(); 364 } 365 } 366 367 /// <summary> 368 /// Connnection to the server has been estabilshed => Login and Send the persistet Jobs from the harddisk. 369 /// </summary> 370 /// <param name="sender"></param> 371 /// <param name="e"></param> 363 372 void wcfService_Connected(object sender, EventArgs e) { 364 wcfService.LoginSync(ConfigManager.Instance.GetClientInfo()); 373 wcfService.LoginSync(ConfigManager.Instance.GetClientInfo()); 365 374 JobStorageManager.CheckAndSubmitJobsFromDisc(); 375 currentlyFetching = false; 366 376 } 367 377 … … 392 402 return jobs; 393 403 } 404 405 /// <summary> 406 /// Kill a appdomain with a specific id. 407 /// </summary> 408 /// <param name="id">the GUID of the job</param> 409 private void KillAppDomain(Guid id) { 410 lock (engines) { 411 try { 412 appDomains[id].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 413 AppDomain.Unload(appDomains[id]); 414 appDomains.Remove(id); 415 engines.Remove(id); 416 jobs.Remove(id); 417 } 418 catch (Exception ex) { 419 Logging.Instance.Error(this.ToString(), "Exception when unloading the appdomain: ", ex); 420 } 421 } 422 GC.Collect(); 423 } 394 424 } 395 425 }
Note: See TracChangeset
for help on using the changeset viewer.