Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/12/11 15:48:53 (13 years ago)
Author:
ascheibe
Message:

#1233 fixed a bug where the slave didn't report the cpu utilization correctly

Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/ConfigManager.cs

    r6897 r6910  
    4646    private Slave slave;
    4747    private PerformanceCounter cpuCounter;
     48    private PerformanceCounter memCounter;
    4849
    4950    /// <summary>
     
    5253    public ConfigManager(TaskManager jobManager) {
    5354      this.jobManager = jobManager;
    54       UpdateSlaveInfo();
    55     }
    56 
    57     private void UpdateSlaveInfo() {
    5855      cpuCounter = new PerformanceCounter();
    5956      cpuCounter.CategoryName = "Processor";
    6057      cpuCounter.CounterName = "% Processor Time";
    6158      cpuCounter.InstanceName = "_Total";
     59      memCounter = new PerformanceCounter("Memory", "Available Bytes", true);
    6260
    6361      Asleep = false;
     
    7068      slave.OperatingSystem = Environment.OSVersion.VersionString;
    7169      slave.CpuSpeed = GetCpuSpeed();
    72       slave.FreeMemory = GetFreeMemory();
    73       slave.HbInterval = (int)Settings.Default.HeartbeatInterval.TotalSeconds;
     70
     71      UpdateSlaveInfo();
     72    }
     73
     74    private void UpdateSlaveInfo() {
     75      if (slave != null) {
     76        slave.FreeMemory = GetFreeMemory();
     77        slave.HbInterval = (int)Settings.Default.HeartbeatInterval.TotalSeconds;
     78      }
    7479    }
    7580
     
    240245    /// returns free memory of machine in MB
    241246    /// </summary>   
    242     public static int GetFreeMemory() {
     247    public int GetFreeMemory() {
    243248      int mb = 0;
    244249
    245250      try {
    246         PerformanceCounter counter = new PerformanceCounter("Memory", "Available Bytes", true);
    247         mb = (int)(counter.NextValue() / 1024 / 1024);
     251        mb = (int)(memCounter.NextValue() / 1024 / 1024);
    248252      }
    249253      catch { }
     
    252256
    253257    public float GetCpuUtilization() {
    254       return cpuCounter.NextValue();
     258      float cpuVal = 0.0F;
     259
     260      try {
     261        return cpuCounter.NextValue();
     262      }
     263      catch { }
     264      return cpuVal;
    255265    }
    256266  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/HeartbeatManager.cs

    r6893 r6910  
    9797                SlaveId = info.Id,
    9898                FreeCores = info.Cores.HasValue ? info.Cores.Value - SlaveStatusInfo.UsedCores : 0,
    99                 FreeMemory = ConfigManager.GetFreeMemory(),
     99                FreeMemory = ConfigManager.Instance.GetFreeMemory(),
    100100                CpuUtilization = ConfigManager.Instance.GetCpuUtilization(),
    101101                JobProgress = ConfigManager.Instance.GetExecutionTimeOfAllJobs(),
Note: See TracChangeset for help on using the changeset viewer.