Class HostWeights

java.lang.Object
org.jenkinsci.plugins.vsphere.tools.HostWeights

public final class HostWeights extends Object
How much each of four measures of a host's free resources counts towards its score when automatically choosing the "most available" host (see VSphereHostSelection.rank(java.util.List<org.jenkinsci.plugins.vsphere.tools.VSphereHostSelection.HostCandidate>, org.jenkinsci.plugins.vsphere.tools.HostWeights)):
  • free CPU in MHz (absolute: a big host with the same load percentage has more to give),
  • free CPU as a share of the host's CPU capacity (relative: how idle the host is),
  • free memory in MB (absolute),
  • free memory as a share of the host's memory (relative).
The weights are relative to each other and only need to be non-negative. With all of them zero (the default) the original ranking applies: the host whose busier resource - CPU or memory - is the least used, by percentage.
  • Field Details

    • DEFAULT

      public static final HostWeights DEFAULT
      All zero: the original ranking.
  • Constructor Details

    • HostWeights

      public HostWeights(double freeCpuMhz, double freeCpuPercent, double freeMemoryMB, double freeMemoryPercent)
  • Method Details

    • parseOverride

      @CheckForNull public static HostWeights parseOverride(@CheckForNull String freeCpuMhz, @CheckForNull String freeCpuPercent, @CheckForNull String freeMemoryMB, @CheckForNull String freeMemoryPercent) throws VSphereException
      Builds the weights a single call (build step or template) sets for itself from the text of its four settings, already variable-expanded. If none is set (all null or blank) there is no override and null is returned, meaning: use the cloud's weights. If any is set, these four values replace the cloud's weights entirely, those left blank counting as zero. Setting them all to 0 is therefore a way to get the original ranking despite weights on the cloud.
      Throws:
      VSphereException - if a value is set but is not a non-negative whole number
    • getFreeCpuMhz

      public double getFreeCpuMhz()
    • getFreeCpuPercent

      public double getFreeCpuPercent()
    • getFreeMemoryMB

      public double getFreeMemoryMB()
    • getFreeMemoryPercent

      public double getFreeMemoryPercent()
    • total

      public double total()
    • isDefault

      public boolean isDefault()
      True if no weight is set, meaning the original ranking applies.
    • toString

      public String toString()
      Overrides:
      toString in class Object