Changeset 6910


Ignore:
Timestamp:
10/12/11 15:48:53 (9 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
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient/3.3/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.3.csproj

    r6896 r6910  
    4040  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    4141    <PlatformTarget>AnyCPU</PlatformTarget>
    42     <OutputPath>..\..\..\..\..\trunk\sources\bin\</OutputPath>
     42    <OutputPath>bin\Debug\</OutputPath>
    4343  </PropertyGroup>
    4444  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
     
    6565      <Project>{989FE92B-484E-41EE-87E2-6A24AF0381D8}</Project>
    6666      <Name>HeuristicLab.Clients.Hive.Slave-3.3</Name>
    67       <Private>False</Private>
     67      <Private>True</Private>
    6868    </ProjectReference>
    6969    <ProjectReference Include="..\..\HeuristicLab.Clients.Hive\3.3\HeuristicLab.Clients.Hive-3.3.csproj">
    7070      <Project>{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}</Project>
    7171      <Name>HeuristicLab.Clients.Hive-3.3</Name>
    72       <Private>False</Private>
     72      <Private>True</Private>
    7373    </ProjectReference>
    7474    <ProjectReference Include="..\..\HeuristicLab.Hive\3.3\HeuristicLab.Hive-3.3.csproj">
    7575      <Project>{F98A1740-9AC9-4D36-A582-6A2D0D06978D}</Project>
    7676      <Name>HeuristicLab.Hive-3.3</Name>
    77       <Private>False</Private>
     77      <Private>True</Private>
    7878    </ProjectReference>
    7979  </ItemGroup>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r6893 r6910  
    241241        if (task == null) throw new TaskNotFoundException(taskId);
    242242        if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException();
    243         if (ConfigManager.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
     243        if (ConfigManager.Instance.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
    244244        SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded;
    245245        TaskData taskData = wcfService.GetTaskData(taskId);
  • 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.