Class ClusterConfiguration

java.lang.Object
com.aoindustries.aoserv.cluster.ClusterConfiguration
All Implemented Interfaces:
Serializable, Comparable<ClusterConfiguration>

public class ClusterConfiguration extends Object implements Comparable<ClusterConfiguration>, Serializable
A ClusterConfiguration contains one possible configuration of a cluster. The configuration consists of a mapping between virtual resources and the physical layer. This includes the following:
  • DomU onto primary Dom0
  • DomU onto secondary Dom0
  • DomUDisk onto a set of primary physical volumes
  • DomUDisk onto a set of secondary physical volumes

The heap space used should be as small as possible to allow the maximum number of possible configurations to be explored.

Everything in ClusterConfiguration is not thread-safe, if using from multiple threads, external synchronization is required.

DomU VMs may only be allocated to Dom0 machines in the same cluster.

Author:
AO Industries, Inc.
See Also:
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCluster

      public Cluster getCluster()
    • getDomUConfigurations

      public List<DomUConfiguration> getDomUConfigurations()
      Gets an unmodifiable list of all configured DomUs.
    • getDomUConfiguration

      public DomUConfiguration getDomUConfiguration(DomU domU)
      Gets the cluster configuration for the provided DomU. To conserve heap space at the expense of more time, this runs in O(n).
      Returns:
      the DomUConfiguration or null if not found
    • addDomUConfiguration

      public ClusterConfiguration addDomUConfiguration(DomU domU, Dom0 primaryDom0, Dom0 secondaryDom0)
      Adds a domU to the configuration.
    • addDomUDiskConfiguration

      public ClusterConfiguration addDomUDiskConfiguration(DomU domU, DomUDisk domUDisk, List<PhysicalVolumeConfiguration> primaryPhysicalVolumeConfigurations, List<PhysicalVolumeConfiguration> secondaryPhysicalVolumeConfigurations)
      Adds a domU disk to the configuration.
    • liveMigrate

      public ClusterConfiguration liveMigrate(DomU domU)
      Swaps the primary and secondary for the provided DomU and returns the new cluster configuration.
    • moveSecondary

      public Iterable<ClusterConfiguration> moveSecondary(DomU domU, Dom0 newSecondaryDom0)
      Moves the secondary to another machine if it is possible to map all of the extents for the DomUDisks onto free physical volumes in Dom0.

      Because there can be many mappings between DomUDisk and PhysicalVolumes, in factorial combinations, this method has a large impact on the branch factor for the cluster optimizer. However, it also affects which solutions may be found or transitioned through in the path to a solution.

      This implementation is meant to be as simple as possible. It focuses on reducing the search space while possibly missing some valid configurations. It works as follows:

      1. Make sure all DomUDisk have the same minspeed - error otherwise.
      2. Find all unallocated physical volumes, sort by speed, device, partition
      3. Work through each Dom0Disk as a starting point
        1. Allocate all the extents of the free physical volumes in order on each Dom0Disk in order until VM mapped
        2. If mapping complete add to results (avoid allocation to exactly equal resources in exactly equal ways)
        3. If mapping incomplete return results found

      In the future, a more advanced configuration could try to reduce the combinations while (hopefully) not losing any possible solution by:

      1. Always allocating DomUDisks of the same min speed, extents, and weight in order by device
      2. Always allocating to the physical volumes in order by speed, device, partition
      3. Always allocating from the first unused physical volumes on a single Dom0Disk
      4. Always consuming as many of the physical volumes in a single Dom0Disk as possible
      5. Not returning multiple results onto different Dom0Disk that have the same speed, size, and overall allocation
      Returns:
      the new configuration(s)
    • equals

      public boolean equals(Object obj)
      Performs a deep field-by-field comparison to see if two configurations are identical in every way.
      Overrides:
      equals in class Object
      See Also:
    • equals

      public boolean equals(ClusterConfiguration other)
      Performs a deep field-by-field comparison to see if two configurations are identical in every way.
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(ClusterConfiguration other)
      Sorted ascending. By:
      1. cluster
      Specified by:
      compareTo in interface Comparable<ClusterConfiguration>