public class ClusterOptimizer extends Object

Optimizes the cluster using a best-first heuristic search.

The current optimization only tries to eliminate all problems. A future version of this should factory in the hardware and monthly costs to maximize the amount of revenue we can make per cost.

The search is performed by exploring two possible moves:

  1. Swap DomU between primary and secondary Dom0 (live-migrate if same architecture or shutdown/create if different)
  2. Move the secondary storage to a different Dom0

The following transitions are possible, but can also occur less directly as a result of the previous two transitions. These are not yet implemented.

  1. pvmove primary storage to different physical volumes
  2. pvmove secondary storage to different physical volumes

To reduce the number of non-live-migrate swaps, this search could try to move between same architectures in preference to different architectures.

TODO: To manage heap consumption, allow two optional parameters: maxPathLen something to make it a "Beam Search" (
AO Industries, Inc.
  • Constructor Details

    • ClusterOptimizer

      public ClusterOptimizer(ClusterConfiguration clusterConfiguration, HeuristicFunction heuristicFunction, boolean allowPathThroughCritical, boolean randomizeChildren)
      Creates a new cluster optimizer for the given configuration and heuristic.
  • Method Details

    • getOptimizedClusterConfiguration

      public ListElement getOptimizedClusterConfiguration()
      Optimizes the cluster and returns the path to the first optimal configuration found or null if no optimal configuration was found.
    • getOptimizedClusterConfiguration

      public ListElement getOptimizedClusterConfiguration(OptimizedClusterConfigurationHandler handler)
      Optimizes the cluster and returns the best path (possibly limited by an OptimizedResultHandler) or null if no optimal configuration was found.

      Best-first search implementation.

      TODO: Since we are limited by heap space more than CPU speed, perhaps we should look for optimal solutions before adding onto the open list? This means we could at least look one more move ahead.

      Could allow heuristic to return Double.POSITIVE_INFINITY to indicate no solution from that state: (see

      TODO: Add in transition cost because the best path depends not on the number of steps, but the total time of the steps. TODO: This could be a real-world estimate on how many seconds the operation would take.

      TODO: If something MUST take a path through a CRITICAL state, try to use path with shortest time in CRITICAL TODO: based on time estimates above.

      handler - if null, returns the first path found, not necessarily the shortest
    • getClusterConfiguration

      public ClusterConfiguration getClusterConfiguration()
      Gets the starting clusterConfiguration.
    • getHeuristicFunction

      public HeuristicFunction getHeuristicFunction()
      Gets the heuristic function used during the search.
    • allowsPathThroughCritical

      public boolean allowsPathThroughCritical()
      When true, a transition from non-critical to critical will be allowed. Otherwise, any path with this transition will be ignored and not expanded.
    • getRandomizeChildren

      public boolean getRandomizeChildren()
      When true, the search will randomize the list of children as it expands each node. The impact of this is not yet tested, but it is expected to provide different alternatives when several different paths yield exactly the same heuristic value because only the first of a provided path length is kept as the sortest path.