- Timestamp:
- 03/24/11 16:15:23 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r5793 r5826 24 24 using System.Diagnostics; 25 25 using System.IO; 26 using System.Runtime.CompilerServices;27 26 using System.ServiceModel; 28 27 using System.Threading; … … 33 32 34 33 35 36 34 namespace HeuristicLab.Clients.Hive.SlaveCore { 37 35 /// <summary> 38 /// The core component of the Hive Client 36 /// The core component of the Hive Slave. 37 /// Handles commands sent from the Hive Server. 39 38 /// </summary> 40 39 public class Core : MarshalByRefObject { 41 42 //TODO: this class should be a singleton; there is only one instance, the reference is meanwhile save in TheCore43 public static Core TheCore;44 45 40 public EventLog ServiceEventLog { get; set; } 46 41 … … 68 63 } 69 64 70 public Core() { 71 TheCore = this; 72 } 65 public Core() { } 73 66 74 67 /// <summary> … … 80 73 81 74 try { 75 ConfigManager manager = ConfigManager.Instance; 76 manager.Core = this; 77 82 78 //start the client communication service (pipe between slave and slave gui) 83 79 slaveComm = new ServiceHost(typeof(SlaveCommunicationService)); … … 87 83 clientCom.LogMessage("Hive Slave started"); 88 84 89 ConfigManager manager = ConfigManager.Instance;90 manager.Core = this;91 92 85 wcfService = WcfService.Instance; 93 86 RegisterServiceEvents(); 94 87 95 StartHeartbeats(); // Start heartbeats thread 88 StartHeartbeats(); // Start heartbeats thread 96 89 DispatchMessageQueue(); // dispatch messages until abortRequested 97 90 } … … 125 118 MessageContainer container = queue.GetMessage(); 126 119 DetermineAction(container); 120 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 127 121 } 128 122 } … … 149 143 /// Reads and analyzes the Messages from the MessageQueue and starts corresponding actions 150 144 /// </summary> 151 /// <param name="container">The Container, containing the message</param>145 /// <param name="container">The container, containing the message</param> 152 146 private void DetermineAction(MessageContainer container) { 153 147 clientCom.LogMessage("Message: " + container.Message.ToString() + " for job: " + container.JobId); … … 169 163 } 170 164 JobData jobData = wcfService.GetJobData(job.Id); 171 if (job == null) throw new JobDataNotFoundException(jobId); 165 if (jobData == null) throw new JobDataNotFoundException(jobId); 166 SlaveStatusInfo.JobsFetched++; 172 167 job = wcfService.UpdateJobState(job.Id, JobState.Calculating, null); 173 168 StartJobInAppDomain(job, jobData); … … 228 223 clientCom.LogMessage("Sending the paused job with id: " + job.Id); 229 224 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused); 230 SlaveStatusInfo.JobsProcessed++; //TODO: count or not count, thats the question231 225 } 232 226 catch (Exception e) { … … 254 248 clientCom.LogMessage("Sending the stoppped job with id: " + job.Id); 255 249 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Finished); 256 SlaveStatusInfo.JobsProcessed++; //TODO: count or not count, thats the question257 250 } 258 251 catch (Exception e) { … … 365 358 /// stop slave, except for client gui communication, 366 359 /// primarily used by gui if core is running as windows service 367 /// </summary> 368 //TODO: do we need an AbortSleep? 360 /// </summary> 369 361 private void Sleep() { 370 362 clientCom.LogMessage("Sleep received"); … … 380 372 /// atm only used when executor is waiting for child jobs 381 373 /// </summary> 382 /// <param name="data"></param>383 [MethodImpl(MethodImplOptions.Synchronized)]384 374 public void PauseWaitJob(JobData data) { 385 375 if (!Jobs.ContainsKey(data.JobId)) { … … 397 387 /// once the connection gets reestablished, the job gets submitted 398 388 /// </summary> 399 /// <param name="jobId"></param>400 [MethodImpl(MethodImplOptions.Synchronized)]401 389 public void SendFinishedJob(Guid jobId) { 402 390 try { … … 413 401 cJob.ExecutionTime = engines[jobId].ExecutionTime; 414 402 403 if (engines[jobId].Aborted) { 404 SlaveStatusInfo.JobsAborted++; 405 } else { 406 SlaveStatusInfo.JobsProcessed++; 407 } 408 409 if (engines[jobId].CurrentException != string.Empty) { 410 wcfService.UpdateJobState(jobId, JobState.Failed, engines[jobId].CurrentException); 411 } 412 415 413 JobData sJob = engines[jobId].GetFinishedJob(); 416 // cJob.Exception = engines[jId].CurrentException; // can there be an exception if the job is sent normally. the exception should be entered in the statelog with the corresponding state (Failed)417 cJob.ExecutionTime = engines[jobId].ExecutionTime;418 419 414 try { 420 415 clientCom.LogMessage("Sending the finished job with id: " + jobId); 421 416 wcfService.UpdateJobData(cJob, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Finished); 422 SlaveStatusInfo.JobsProcessed++;423 417 } 424 418 catch (Exception e) { … … 426 420 } 427 421 finally { 428 KillAppDomain(jobId); // kill app-domain in every case422 KillAppDomain(jobId); 429 423 heartbeatManager.AwakeHeartBeatThread(); 430 424 } … … 437 431 /// <summary> 438 432 /// A new Job from the wcfService has been received and will be started within a AppDomain. 439 /// </summary> 440 /// <param name="sender"></param> 441 /// <param name="e"></param> 433 /// </summary> 442 434 private void StartJobInAppDomain(Job myJob, JobData jobData) { 443 435 clientCom.LogMessage("Received new job with id " + myJob.Id); 436 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 444 437 if (engines.ContainsKey(myJob.Id)) 445 438 throw new Exception("Job with key " + myJob.Id + " already exists"); … … 472 465 engines.Add(myJob.Id, engine); 473 466 engine.Start(jobData.Data); 474 SlaveStatusInfo.JobsFetched++;475 clientCom.LogMessage("Increment FetchedJobs to:" + SlaveStatusInfo.JobsFetched);476 467 } 477 468 } … … 501 492 /// This is necessary if the core thread has to execute certain actions, e.g. 502 493 /// killing of an app domain. 503 /// </summary> 504 /// <typeparam name="T"></typeparam> 505 /// <param name="action"></param> 506 /// <param name="parameter"></param> 494 /// </summary> 507 495 /// <returns>true if the calling method can continue execution, else false</returns> 508 496 public void EnqueueExecutorMessage<T>(Action<T> action, T parameter) { … … 516 504 /// Kill a appdomain with a specific id. 517 505 /// </summary> 518 /// <param name="id">the GUID of the job</param> 519 //[MethodImpl(MethodImplOptions.Synchronized)] 506 /// <param name="id">the GUID of the job</param> 520 507 public void KillAppDomain(Guid id) { 521 508 if (Thread.CurrentThread.ManagedThreadId != this.coreThreadId) { … … 562 549 } 563 550 GC.Collect(); 551 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 564 552 } 565 553 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs
r5795 r5826 38 38 private Semaphore pauseStopSem = new Semaphore(0, 1); 39 39 40 public bool Aborted { get; set; } 41 40 42 private Exception currentException; 41 43 public String CurrentException { … … 68 70 try { 69 71 CreationTime = DateTime.Now; 72 Aborted = false; 70 73 Job = PersistenceUtil.Deserialize<IJob>(serializedJob); 71 74 … … 182 185 currentException = ex.Value; 183 186 Core.EnqueueExecutorMessage(Core.SendFinishedJob, JobId); 187 Aborted = true; 184 188 } 185 189 … … 187 191 if (wasJobAborted) { 188 192 pauseStopSem.Release(); 193 Aborted = true; 189 194 } else { 190 //it's a clean and finished job, so send it 195 //it's a clean and finished job, so send it 191 196 Core.EnqueueExecutorMessage(Core.SendFinishedJob, JobId); 192 197 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/HeartbeatManager.cs
r5721 r5826 78 78 while (!threadStopped) { 79 79 sleepForever = false; 80 SlaveClientCom.Instance.ClientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 81 80 82 try { 81 83 lock (locker) { 82 84 if (wcfService.ConnState != NetworkEnum.WcfConnState.Connected) { 83 wcfService.Connect(ConfigManager.Instance.GetClientInfo()); // Login happens automatically upon successfull connection 85 // login happens automatically upon successfull connection 86 wcfService.Connect(ConfigManager.Instance.GetClientInfo()); 87 SlaveStatusInfo.LoginTime = DateTime.Now; 84 88 } 85 89 if (wcfService.ConnState == NetworkEnum.WcfConnState.Connected) { … … 111 115 } 112 116 catch (Exception e) { 113 SlaveClientCom.Instance.ClientCom.LogMessage("Heartbeat Thread failed badly: " + e.Message);117 SlaveClientCom.Instance.ClientCom.LogMessage("Heartbeat thread failed: " + e.ToString()); 114 118 OnExceptionOccured(e); 115 119 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/ServiceContracts/ISlaveCommunication.cs
r5599 r5826 49 49 void AbortAll(); 50 50 51 [OperationContract]52 void ShutdownSlave();53 54 51 //callbacks 55 52 [OperationContract] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveCommunicationService.cs
r5599 r5826 33 33 try { 34 34 ISlaveCommunicationCallbacks callback = OperationContext.Current.GetCallbackChannel<ISlaveCommunicationCallbacks>(); 35 if (!subscribers.Contains(callback)) 35 if (!subscribers.Contains(callback)) { 36 36 subscribers.Add(callback); 37 } 37 38 return true; 38 39 } … … 99 100 } 100 101 101 public void ShutdownSlave() {102 Core.TheCore.Shutdown();103 }104 105 102 public void AbortAll() { 106 103 MessageContainer mc = new MessageContainer(MessageContainer.MessageType.AbortAll);
Note: See TracChangeset
for help on using the changeset viewer.