IP allocation - add LCP2 algorithm.
authorMartin Schwenke <martin@meltin.net>
Thu, 28 Jul 2011 05:16:46 +0000 (15:16 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 28 Jul 2011 22:54:16 +0000 (08:54 +1000)
commitfe84e07e94675ade4db56b2e55fa049476171633
tree19ecc5c590410f8233ef960917705afecc8928fa
parent4677a17aef0f42af94fd8a5ba800d5df9bcd36e9
IP allocation - add LCP2 algorithm.

The current non-deterministic IP allocation algorithm balances IPs
across the whole cluster.  It does not consider different
interfaces/VLANs/subnets, so these different groups of IPs aren't
generally well balanced.

This adds the LCP2 algorithm for IP allocation and allows it to be
enabled by setting the "LCP2PublicIPs" tunable to 1.

The LCP2 algorithm calculates the imbalance of a node by totalling the
squares of the distances between each IP on the node.  The IP distance
is defined as the length longest common prefix (LCP) of bits that is
found when comparing 2 IPs.  The imbalance of a cluster is the maximum
imbalance for any node.  At each step the algorithm selects an
allocation to the IP/node combination that results in the choosing the
allocation that best reduces the imbalance of the cluster.

The implementation splits out the IP allocation part of
ctdb_takeover_run() into new function ctdb_takeover_run_core(), and
then extracts out the basic IP assignment code into new functions
basic_allocate_unassigned() and basic_failback().  3 new functions
lcp2_init(), lcp2_allocate_unassigned() and lcp2_failback() implement
the LCP2 algorithm, and are hooked into ctdb_takeover_run_core().

Signed-off-by: Martin Schwenke <martin@meltin.net>
include/ctdb_private.h
server/ctdb_takeover.c
server/ctdb_tunables.c