Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/10 19:58:01 (14 years ago)
Author:
ascheibe
Message:

#1233

  • more tests for the hive slave
  • implemented a better way to write tests for the slave
  • get rid of MessageTypes for core and executor
  • various improvements in core and executor (better communication, bugfixes,...)
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources

    • Property svn:ignore
      •  

        old new  
         1*.suo
        12HeuristicLab.Hive-3.4.suo
        23TestResults
        3 HeuristicLab.Hive 3.4.suo
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/HeartbeatManager.cs

    r5105 r5137  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Diagnostics;
    2425using System.Threading;
    2526using HeuristicLab.Common;
    26 using HeuristicLab.Clients.Hive.Salve;
     27using HeuristicLab.Services.Hive.Common;
    2728using HeuristicLab.Services.Hive.Common.DataTransfer;
    28 using HeuristicLab.Services.Hive.Common;
    29 using System.Collections.Generic;
    3029
    3130namespace HeuristicLab.Clients.Hive.Salve {
     
    4948    private WcfService wcfService;
    5049
    51     private bool abortThreadPending;
     50    private bool threadStopped;
    5251
    5352    ReaderWriterLockSlim heartBeatThreadIsSleepingLock = new ReaderWriterLockSlim();
    54    
     53
    5554    /// <summary>
    5655    /// Starts the Heartbeat signal.
     
    5857    public void StartHeartbeat() {
    5958      this.waitHandle = new AutoResetEvent(true);
    60       wcfService = WcfService.Instance;     
    61       abortThreadPending = false;
     59      wcfService = WcfService.Instance;
     60      threadStopped = false;
    6261      heartBeatThread = new Thread(RunHeartBeatThread);
    6362      heartBeatThread.Start();
     
    6867    /// </summary>
    6968    public void StopHeartBeat() {
    70       abortThreadPending = true;
     69      threadStopped = true;
    7170      waitHandle.Set();
    7271      heartBeatThread.Join();
    7372    }
    74    
     73
    7574    /// <summary>
    7675    /// use this method to singalize there is work to do (to avoid the waiting period if its clear that actions are required)
    7776    /// </summary>
    7877    public void AwakeHeartBeatThread() {
    79       waitHandle.Set();
     78      if (!threadStopped)
     79        waitHandle.Set();
    8080    }
    8181
    8282    private void RunHeartBeatThread() {
    83       while (!abortThreadPending) {
     83      while (!threadStopped) {
    8484        try {
    8585          lock (locker) {
     
    8787              wcfService.Connect(ConfigManager.Instance.GetClientInfo()); // Login happens automatically upon successfull connection
    8888            }
    89             if(wcfService.ConnState == NetworkEnum.WcfConnState.Connected) {
     89            if (wcfService.ConnState == NetworkEnum.WcfConnState.Connected) {
    9090              HeuristicLab.Services.Hive.Common.DataTransfer.Slave info = ConfigManager.Instance.GetClientInfo();
    9191
    92               Heartbeat heartBeatData = new Heartbeat
    93               {
     92              Heartbeat heartBeatData = new Heartbeat {
    9493                SlaveId = info.Id,
    9594                FreeCores = info.Cores.HasValue ? info.Cores.Value - ConfigManager.Instance.GetUsedCores() : 0,
    9695                FreeMemory = GetFreeMemory(),
    97                 JobProgress = ConfigManager.Instance.GetExecutionTimeOfAllJobs()               
     96                JobProgress = ConfigManager.Instance.GetExecutionTimeOfAllJobs()
    9897              };
    99                              
     98
    10099              Logger.Debug("Sending Heartbeat: " + heartBeatData);
    101               List<MessageContainer> msgs =  wcfService.SendHeartbeat(heartBeatData);
    102              
     100              List<MessageContainer> msgs = wcfService.SendHeartbeat(heartBeatData);
     101
    103102              if (msgs == null) {
    104103                Logger.Debug("Error getting response from Heartbeat");
     
    108107              Logger.Debug("Heartbeat Response received: ");
    109108              msgs.ForEach(mc => Logger.Debug(mc.Message.ToString()));
    110               msgs.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));     
     109              msgs.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));
    111110            }
    112           } // lock
     111          }
    113112        }
    114113        catch (Exception e) {
     
    117116        }
    118117        waitHandle.WaitOne(this.Interval);
    119       } // while
     118      }
    120119      waitHandle.Close();
    121       abortThreadPending = false;
    122120      Logger.Debug("Heartbeat thread stopped");
    123121    }
    124          
     122
    125123
    126124    #region Eventhandler
Note: See TracChangeset for help on using the changeset viewer.