- Timestamp:
- 03/16/11 18:05:56 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r5718 r5721 26 26 using System.ServiceModel; 27 27 using System.Threading; 28 using System.Threading.Tasks; 28 29 using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts; 29 30 using HeuristicLab.Common; … … 133 134 private void DetermineAction(MessageContainer container) { 134 135 ClientCom.LogMessage("Message: " + container.Message.ToString() + " for job: " + container.JobId); 135 //TODO: find a better solution 136 136 137 if (container is ExecutorMessageContainer<Guid>) { 137 138 ExecutorMessageContainer<Guid> c = (ExecutorMessageContainer<Guid>)container; … … 140 141 switch (container.Message) { 141 142 case MessageContainer.MessageType.CalculateJob: 142 Job job = wcfService.GetJob(container.JobId); 143 JobData jobData = wcfService.GetJobData(job.Id); 144 job = wcfService.UpdateJobState(job.Id, JobState.Calculating, null); 145 StartJobInAppDomain(job, jobData); 143 Task.Factory.StartNew(() => { 144 Job job = wcfService.GetJob(container.JobId); 145 lock (engines) { 146 if (!jobs.ContainsKey(job.Id)) { 147 jobs.Add(job.Id, job); 148 } 149 } 150 JobData jobData = wcfService.GetJobData(job.Id); 151 job = wcfService.UpdateJobState(job.Id, JobState.Calculating, null); 152 StartJobInAppDomain(job, jobData); 153 }); 146 154 break; 147 155 case MessageContainer.MessageType.ShutdownSlave: … … 420 428 appDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 421 429 lock (engines) { 422 if (!jobs.ContainsKey(myJob.Id)) { 423 jobs.Add(myJob.Id, myJob); 424 appDomains.Add(myJob.Id, appDomain); 425 ClientCom.LogMessage("Creating AppDomain"); 426 Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 427 ClientCom.LogMessage("Created AppDomain"); 428 engine.JobId = myJob.Id; 429 engine.Core = this; 430 ClientCom.LogMessage("Starting Engine for job " + myJob.Id); 431 engines.Add(myJob.Id, engine); 432 engine.Start(jobData.Data); 433 SlaveStatusInfo.JobsFetched++; 434 ClientCom.LogMessage("Increment FetchedJobs to:" + SlaveStatusInfo.JobsFetched); 435 } 430 appDomains.Add(myJob.Id, appDomain); 431 ClientCom.LogMessage("Creating AppDomain"); 432 Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 433 ClientCom.LogMessage("Created AppDomain"); 434 engine.JobId = myJob.Id; 435 engine.Core = this; 436 ClientCom.LogMessage("Starting Engine for job " + myJob.Id); 437 engines.Add(myJob.Id, engine); 438 engine.Start(jobData.Data); 439 SlaveStatusInfo.JobsFetched++; 440 ClientCom.LogMessage("Increment FetchedJobs to:" + SlaveStatusInfo.JobsFetched); 436 441 } 437 heartbeatManager.AwakeHeartBeatThread();438 442 } 439 443 catch (Exception exception) { … … 443 447 } 444 448 } 449 heartbeatManager.AwakeHeartBeatThread(); 445 450 } 446 451 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/HeartbeatManager.cs
r5599 r5721 34 34 private Thread heartBeatThread; 35 35 private AutoResetEvent waitHandle; 36 private WcfService wcfService; 37 private bool threadStopped; 38 ReaderWriterLockSlim heartBeatThreadIsSleepingLock = new ReaderWriterLockSlim(); 36 39 37 40 public HeartbeatManager() { … … 42 45 Interval = interval; 43 46 } 44 45 private WcfService wcfService;46 47 private bool threadStopped;48 49 ReaderWriterLockSlim heartBeatThreadIsSleepingLock = new ReaderWriterLockSlim();50 47 51 48 /// <summary> … … 78 75 79 76 private void RunHeartBeatThread() { 77 bool sleepForever; 80 78 while (!threadStopped) { 79 sleepForever = false; 81 80 try { 82 81 lock (locker) { … … 88 87 89 88 Heartbeat heartBeatData = new Heartbeat { 90 SlaveId = info.Id, /*Settings.Default.Guid*/89 SlaveId = info.Id, 91 90 FreeCores = info.Cores.HasValue ? info.Cores.Value - ConfigManager.Instance.GetUsedCores() : 0, 92 91 FreeMemory = ConfigManager.GetFreeMemory(), … … 102 101 OnExceptionOccured(new Exception("Error getting response from Heartbeat")); 103 102 } else { 104 SlaveClientCom.Instance.ClientCom.LogMessage("Heartbeat Response received : ");103 SlaveClientCom.Instance.ClientCom.LogMessage("Heartbeat Response received (" + msgs.Count + "): "); 105 104 msgs.ForEach(mc => SlaveClientCom.Instance.ClientCom.LogMessage(mc.Message.ToString())); 106 105 msgs.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc)); 106 //after fetching a job, we sleep until the core wakes us up!! 107 msgs.ForEach(s => { if (s.Message == MessageContainer.MessageType.CalculateJob) sleepForever = true; }); 107 108 } 108 109 } … … 113 114 OnExceptionOccured(e); 114 115 } 115 waitHandle.WaitOne(this.Interval); 116 if (sleepForever) 117 waitHandle.WaitOne(); 118 else 119 waitHandle.WaitOne(this.Interval); 116 120 } 117 121 waitHandle.Close(); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/HeuristicLab.Clients.Hive.Slave-3.4.csproj
r5711 r5721 146 146 </ProjectReference> 147 147 </ItemGroup> 148 <ItemGroup> 149 <Content Include="ICSharpCode.SharpZipLib License.txt"> 150 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 151 </Content> 152 </ItemGroup> 148 153 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 149 154 <PropertyGroup> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs
r5599 r5721 113 113 CopyFile(baseDir, targetDir, "HeuristicLab.Hive-3.4.dll"); 114 114 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Common-3.3.dll"); 115 116 //TODO: remove, just needed for unit tests117 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Hive.Slave.Tests-3.4.dll");118 115 } 119 116 }
Note: See TracChangeset
for help on using the changeset viewer.