- Timestamp:
- 05/03/11 17:08:54 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/ConfigManager.cs
r6004 r6110 85 85 st.JobsFetched = SlaveStatusInfo.JobsFetched; 86 86 87 Dictionary<Guid, Executor> engines = Core.Execut ionEngines;87 Dictionary<Guid, Executor> engines = Core.Executors; 88 88 st.Jobs = new List<JobStatus>(); 89 89 … … 99 99 public Dictionary<Guid, TimeSpan> GetExecutionTimeOfAllJobs() { 100 100 Dictionary<Guid, TimeSpan> prog = new Dictionary<Guid, TimeSpan>(); 101 Dictionary<Guid, Executor> engines = Core.Execut ionEngines;101 Dictionary<Guid, Executor> engines = Core.Executors; 102 102 lock (engines) { 103 103 foreach (KeyValuePair<Guid, Executor> kvp in engines) { … … 113 113 114 114 public int GetUsedCores() { 115 Dictionary<Guid, Executor> engines = Core.Execut ionEngines;115 Dictionary<Guid, Executor> engines = Core.Executors; 116 116 Dictionary<Guid, Job> jobs = Core.Jobs; 117 117 int usedCores = 0; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r6107 r6110 44 44 public static ILog Log { get; set; } 45 45 46 private Dictionary<Guid, Executor> e ngines = new Dictionary<Guid, Executor>();46 private Dictionary<Guid, Executor> executors = new Dictionary<Guid, Executor>(); 47 47 private Dictionary<Guid, AppDomain> appDomains = new Dictionary<Guid, AppDomain>(); 48 48 private Dictionary<Guid, Job> jobs = new Dictionary<Guid, Job>(); … … 55 55 private ServiceHost slaveComm; 56 56 57 public Dictionary<Guid, Executor> Execut ionEngines {58 get { return e ngines; }57 public Dictionary<Guid, Executor> Executors { 58 get { return executors; } 59 59 } 60 60 … … 162 162 Job job = wcfService.GetJob(jobId); 163 163 if (job == null) throw new JobNotFoundException(jobId); 164 lock (e ngines) {164 lock (executors) { 165 165 if (!jobs.ContainsKey(job.Id)) { 166 166 jobs.Add(job.Id, job); … … 177 177 // handle exception of task 178 178 clientCom.LogMessage(t.Exception.ToString()); 179 wcfService.UpdateJobState(container.JobId, JobState.Failed, t.Exception.ToString());180 SlaveStatusInfo.JobsAborted++;181 179 }, TaskContinuationOptions.OnlyOnFaulted); 182 180 break; … … 225 223 226 224 if (job != null) { 227 e ngines[job.Id].Pause();228 JobData sJob = e ngines[job.Id].GetPausedJob();229 job.ExecutionTime = e ngines[job.Id].ExecutionTime;225 executors[job.Id].Pause(); 226 JobData sJob = executors[job.Id].GetPausedJob(); 227 job.ExecutionTime = executors[job.Id].ExecutionTime; 230 228 231 229 try { 232 if (e ngines[job.Id].CurrentException != string.Empty) {233 wcfService.UpdateJobState(job.Id, JobState.Failed, e ngines[job.Id].CurrentException);230 if (executors[job.Id].CurrentException != string.Empty) { 231 wcfService.UpdateJobState(job.Id, JobState.Failed, executors[job.Id].CurrentException); 234 232 SlaveStatusInfo.JobsAborted++; 235 233 } else { … … 256 254 257 255 if (job != null) { 258 e ngines[job.Id].Stop();259 JobData sJob = e ngines[job.Id].GetFinishedJob();260 job.ExecutionTime = e ngines[job.Id].ExecutionTime;256 executors[job.Id].Stop(); 257 JobData sJob = executors[job.Id].GetFinishedJob(); 258 job.ExecutionTime = executors[job.Id].ExecutionTime; 261 259 262 260 263 261 try { 264 if (e ngines[job.Id].CurrentException != string.Empty) {265 wcfService.UpdateJobState(job.Id, JobState.Failed, e ngines[job.Id].CurrentException);262 if (executors[job.Id].CurrentException != string.Empty) { 263 wcfService.UpdateJobState(job.Id, JobState.Failed, executors[job.Id].CurrentException); 266 264 } 267 265 SlaveStatusInfo.JobsAborted++; … … 350 348 351 349 352 lock (e ngines) {353 clientCom.LogMessage("e ngines locked");350 lock (executors) { 351 clientCom.LogMessage("executors locked"); 354 352 foreach (KeyValuePair<Guid, AppDomain> kvp in appDomains) { 355 353 clientCom.LogMessage("Shutting down Appdomain for " + kvp.Key); … … 411 409 try { 412 410 clientCom.LogMessage("Getting the finished job with id: " + jobId); 413 if (!e ngines.ContainsKey(jobId)) {414 clientCom.LogMessage("E nginedoesn't exist");411 if (!executors.ContainsKey(jobId)) { 412 clientCom.LogMessage("Executor doesn't exist"); 415 413 return; 416 414 } … … 420 418 } 421 419 Job cJob = jobs[jobId]; 422 cJob.ExecutionTime = e ngines[jobId].ExecutionTime;423 424 if (e ngines[jobId].Aborted) {420 cJob.ExecutionTime = executors[jobId].ExecutionTime; 421 422 if (executors[jobId].Aborted) { 425 423 SlaveStatusInfo.JobsAborted++; 426 424 } else { … … 428 426 } 429 427 430 if (e ngines[jobId].CurrentException != string.Empty) {431 wcfService.UpdateJobState(jobId, JobState.Failed, e ngines[jobId].CurrentException);432 } 433 434 JobData sJob = e ngines[jobId].GetFinishedJob();428 if (executors[jobId].CurrentException != string.Empty) { 429 wcfService.UpdateJobState(jobId, JobState.Failed, executors[jobId].CurrentException); 430 } 431 432 JobData sJob = executors[jobId].GetFinishedJob(); 435 433 try { 436 434 clientCom.LogMessage("Sending the finished job with id: " + jobId); … … 450 448 } 451 449 452 private static object locker = new object();450 private static object startInAppDomainLocker = new object(); 453 451 454 452 /// <summary> … … 459 457 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 460 458 461 lock ( locker) {462 if (e ngines.ContainsKey(myJob.Id)) {459 lock (startInAppDomainLocker) { 460 if (executors.ContainsKey(myJob.Id)) { 463 461 clientCom.LogMessage("Job with key " + myJob.Id + " already exists. Job will be ignored."); 464 462 return; … … 476 474 catch (Exception exception) { 477 475 clientCom.LogMessage(string.Format("Copying plugins for job {0} failed: {1}", myJob.Id, exception)); 478 wcfService.UpdateJobState(myJob.Id, JobState.Failed, exception.ToString()); 479 SlaveStatusInfo.JobsAborted++; 480 481 lock (engines) { 476 lock (executors) { 482 477 if (jobs.ContainsKey(myJob.Id)) { 483 478 jobs.Remove(myJob.Id); … … 490 485 AppDomain appDomain = HeuristicLab.PluginInfrastructure.Sandboxing.SandboxManager.CreateAndInitSandbox(myJob.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName)); 491 486 appDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 492 Executor engine; 493 lock (engines) { 494 appDomains.Add(myJob.Id, appDomain); 495 clientCom.LogMessage("Creating AppDomain"); 496 engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 497 clientCom.LogMessage("Created AppDomain"); 498 engine.JobId = myJob.Id; 499 engine.Core = this; 500 clientCom.LogMessage("Starting Engine for job " + myJob.Id); 501 engines.Add(myJob.Id, engine); 487 Executor executor; 488 appDomains.Add(myJob.Id, appDomain); 489 clientCom.LogMessage("Creating AppDomain"); 490 executor = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 491 clientCom.LogMessage("Created AppDomain"); 492 executor.JobId = myJob.Id; 493 executor.Core = this; 494 clientCom.LogMessage("Starting Executor for job " + myJob.Id); 495 496 executor.Start(jobData.Data); 497 498 lock (executors) { 499 executors.Add(myJob.Id, executor); 502 500 } 503 engine.Start(jobData.Data);504 501 } 505 502 catch (Exception exception) { 506 503 clientCom.LogMessage("Creating the Appdomain and loading the job failed for job " + myJob.Id); 507 504 clientCom.LogMessage("Error thrown is: " + exception.ToString()); 508 509 if (engines.ContainsKey(myJob.Id) && engines[myJob.Id].CurrentException != string.Empty) {510 wcfService.UpdateJobState(myJob.Id, JobState.Failed, engines[myJob.Id].CurrentException);511 } else {512 wcfService.UpdateJobState(myJob.Id, JobState.Failed, exception.ToString());513 }514 SlaveStatusInfo.JobsAborted++;515 516 505 KillAppDomain(myJob.Id); 517 506 } … … 557 546 558 547 clientCom.LogMessage("Shutting down Appdomain for Job " + id); 559 lock (e ngines) {548 lock (executors) { 560 549 try { 561 if (e ngines.ContainsKey(id)) {562 e ngines[id].Dispose();563 e ngines.Remove(id);550 if (executors.ContainsKey(id)) { 551 executors[id].Dispose(); 552 executors.Remove(id); 564 553 } 565 554 … … 597 586 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 598 587 } 588 589 public override object InitializeLifetimeService() { 590 return null; // avoid destruction of proxy object after 5 minutes 591 } 599 592 } 600 593 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs
r6100 r6110 85 85 Job.Resume(childjobs.Select(j => PersistenceUtil.Deserialize<IJob>(j.Data))); 86 86 } else { 87 // Job.Prepare(); // do NOT prepare here, otherwise paused jobs get restarted88 87 Job.Start(); 88 89 89 } 90 90 } … … 200 200 Aborted = true; 201 201 } else { 202 //it's a clean and finished job, so send it 202 //it's a clean and finished job, so send it 203 203 Core.EnqueueExecutorMessage(Core.SendFinishedJob, JobId); 204 204 }
Note: See TracChangeset
for help on using the changeset viewer.