|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvoldemort.tools.Repartitioner
public class Repartitioner
RepartitionUtils provides functions that balance the distribution of partitions across a cluster.
Field Summary | |
---|---|
static int |
DEFAULT_GREEDY_MAX_PARTITIONS_PER_NODE
Default (max) number of partition IDs per node to consider, if greedy swaps are enabled. |
static int |
DEFAULT_GREEDY_MAX_PARTITIONS_PER_ZONE
Default (max) number of partition IDs from all the other nodes in the cluster to consider, if greedy swaps are enabled. |
static int |
DEFAULT_GREEDY_SWAP_ATTEMPTS
Default number of greedy partition ID swaps to perform, if greedy swaps are enabled. |
static java.util.List<java.lang.Integer> |
DEFAULT_GREEDY_SWAP_ZONE_IDS
Default setting for which zone IDs to run greedy swap algorithm. |
static int |
DEFAULT_MAX_CONTIGUOUS_PARTITIONS
Default limit on length of contiguous partition ID run within a zone. |
static int |
DEFAULT_RANDOM_SWAP_ATTEMPTS
Default number of random partition ID swaps to attempt, if random swaps are enabled. |
static int |
DEFAULT_RANDOM_SWAP_SUCCESSES
Default number of successful random swaps (i.e., the random swap improves balance) after which reparitioning stops, if random swaps are enabled. |
static java.util.List<java.lang.Integer> |
DEFAULT_RANDOM_SWAP_ZONE_IDS
Default setting for which zone IDs to run random swap algorithm. |
static int |
DEFAULT_REPARTITION_ATTEMPTS
Recommended (default) number of times to attempt repartitioning. |
Constructor Summary | |
---|---|
Repartitioner()
|
Method Summary | |
---|---|
static Cluster |
balanceContiguousPartitionsPerZone(Cluster nextCandidateCluster,
int maxContiguousPartitionsPerZone)
Ensures that no more than maxContiguousPartitionsPerZone partitions are contiguous within a single zone. |
static Cluster |
balancePrimaryPartitions(Cluster nextCandidateCluster,
boolean balanceZones)
This method balances primary partitions among nodes within a zone, and optionally primary partitions among zones. |
static java.util.HashMap<java.lang.Integer,java.util.List<java.lang.Integer>> |
getBalancedNumberOfPrimaryPartitionsPerNode(Cluster nextCandidateCluster,
java.util.Map<java.lang.Integer,java.lang.Integer> targetPartitionsPerZone)
Determines how many primary partitions each node within each zone should have. |
static Pair<java.util.HashMap<Node,java.lang.Integer>,java.util.HashMap<Node,java.lang.Integer>> |
getDonorsAndStealersForBalance(Cluster nextCandidateCluster,
java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> numPartitionsPerNodePerZone)
Assign target number of partitions per node to specific node IDs. |
static Cluster |
greedyShufflePartitions(Cluster nextCandidateCluster,
int greedyAttempts,
int greedySwapMaxPartitionsPerNode,
int greedySwapMaxPartitionsPerZone,
java.util.List<java.lang.Integer> greedySwapZoneIds,
java.util.List<StoreDefinition> storeDefs)
Within a single zone, tries swapping some minimum number of random partitions per node with some minimum number of random partitions from other nodes within the zone. |
static Cluster |
randomShufflePartitions(Cluster nextCandidateCluster,
int randomSwapAttempts,
int randomSwapSuccesses,
java.util.List<java.lang.Integer> randomSwapZoneIds,
java.util.List<StoreDefinition> storeDefs)
Randomly shuffle partitions between nodes within every zone. |
static Cluster |
repartition(Cluster currentCluster,
java.util.List<StoreDefinition> currentStoreDefs,
Cluster interimCluster,
java.util.List<StoreDefinition> finalStoreDefs,
java.lang.String outputDir,
int attempts,
boolean disableNodeBalancing,
boolean disableZoneBalancing,
boolean enableRandomSwaps,
int randomSwapAttempts,
int randomSwapSuccesses,
java.util.List<java.lang.Integer> randomSwapZoneIds,
boolean enableGreedySwaps,
int greedySwapAttempts,
int greedySwapMaxPartitionsPerNode,
int greedySwapMaxPartitionsPerZone,
java.util.List<java.lang.Integer> greedySwapZoneIds,
int maxContiguousPartitionsPerZone)
Runs a number of distinct algorithms over the specified clusters/store defs to better balance partition IDs over nodes such that all nodes have similar iops and capacity usage. |
static Cluster |
repeatedlyBalanceContiguousPartitionsPerZone(Cluster nextCandidateCluster,
int maxContiguousPartitionsPerZone)
Loops over cluster and repeatedly tries to break up contiguous runs of partitions. |
static Cluster |
swapGreedyRandomPartitions(Cluster nextCandidateCluster,
java.util.List<java.lang.Integer> nodeIds,
int greedySwapMaxPartitionsPerNode,
int greedySwapMaxPartitionsPerZone,
java.util.List<StoreDefinition> storeDefs)
For each node in specified zones, tries swapping some minimum number of random partitions per node with some minimum number of random partitions from other specified nodes. |
static Cluster |
swapPartitions(Cluster nextCandidateCluster,
int nodeIdA,
int partitionIdA,
int nodeIdB,
int partitionIdB)
Swaps two specified partitions. |
static Cluster |
swapRandomPartitionsAmongNodes(Cluster nextCandidateCluster,
java.util.List<java.lang.Integer> nodeIds)
Shuffles partitions among all nodes specified. |
static Cluster |
swapRandomPartitionsWithinZone(Cluster nextCandidateCluster,
int zoneId)
Within a single zone, swaps one random partition on one random node with another random partition on different random node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_REPARTITION_ATTEMPTS
public static final int DEFAULT_RANDOM_SWAP_ATTEMPTS
public static final int DEFAULT_RANDOM_SWAP_SUCCESSES
public static final java.util.List<java.lang.Integer> DEFAULT_RANDOM_SWAP_ZONE_IDS
public static final int DEFAULT_GREEDY_SWAP_ATTEMPTS
public static final java.util.List<java.lang.Integer> DEFAULT_GREEDY_SWAP_ZONE_IDS
public static final int DEFAULT_GREEDY_MAX_PARTITIONS_PER_NODE
public static final int DEFAULT_GREEDY_MAX_PARTITIONS_PER_ZONE
public static final int DEFAULT_MAX_CONTIGUOUS_PARTITIONS
Constructor Detail |
---|
public Repartitioner()
Method Detail |
---|
public static Cluster repartition(Cluster currentCluster, java.util.List<StoreDefinition> currentStoreDefs, Cluster interimCluster, java.util.List<StoreDefinition> finalStoreDefs, java.lang.String outputDir, int attempts, boolean disableNodeBalancing, boolean disableZoneBalancing, boolean enableRandomSwaps, int randomSwapAttempts, int randomSwapSuccesses, java.util.List<java.lang.Integer> randomSwapZoneIds, boolean enableGreedySwaps, int greedySwapAttempts, int greedySwapMaxPartitionsPerNode, int greedySwapMaxPartitionsPerZone, java.util.List<java.lang.Integer> greedySwapZoneIds, int maxContiguousPartitionsPerZone)
currentCluster
- current clustercurrentStoreDefs
- current store defsinterimCluster
- interim cluster; needed for cluster or zone
expansion, otherwise pass in same as currentCluster.finalStoreDefs
- final store defs; needed for zone expansion,
otherwise pass in same as currentStores.outputDir
- Directory in which to dump cluster xml and analysis
files.attempts
- Number of distinct repartitionings to attempt, the best
of which is returned.disableNodeBalancing
- Disables the core algorithm that balances
primaries among nodes within each zone.disableZoneBalancing
- For the core algorithm that balances
primaries among nodes in each zone, disable balancing primaries
among zones.enableRandomSwaps
- Enables random swap optimization.randomSwapAttempts
- randomSwapSuccesses
- randomSwapZoneIds
- enableGreedySwaps
- Enables greedy swap optimization.greedySwapAttempts
- greedySwapMaxPartitionsPerNode
- greedySwapMaxPartitionsPerZone
- greedySwapZoneIds
- maxContiguousPartitionsPerZone
-
public static java.util.HashMap<java.lang.Integer,java.util.List<java.lang.Integer>> getBalancedNumberOfPrimaryPartitionsPerNode(Cluster nextCandidateCluster, java.util.Map<java.lang.Integer,java.lang.Integer> targetPartitionsPerZone)
nextCandidateCluster
- targetPartitionsPerZone
-
public static Pair<java.util.HashMap<Node,java.lang.Integer>,java.util.HashMap<Node,java.lang.Integer>> getDonorsAndStealersForBalance(Cluster nextCandidateCluster, java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> numPartitionsPerNodePerZone)
nextCandidateCluster
- numPartitionsPerNodePerZone
-
public static Cluster balancePrimaryPartitions(Cluster nextCandidateCluster, boolean balanceZones)
nextCandidateCluster
- balanceZones
- indicates whether or not number of primary partitions
per zone should be balanced.
public static Cluster repeatedlyBalanceContiguousPartitionsPerZone(Cluster nextCandidateCluster, int maxContiguousPartitionsPerZone)
nextCandidateCluster
- maxContiguousPartitionsPerZone
- See RebalanceCLI.
public static Cluster balanceContiguousPartitionsPerZone(Cluster nextCandidateCluster, int maxContiguousPartitionsPerZone)
nextCandidateCluster
- cluster metadatamaxContiguousPartitionsPerZone
- See RebalanceCLI.
public static Cluster swapPartitions(Cluster nextCandidateCluster, int nodeIdA, int partitionIdA, int nodeIdB, int partitionIdB)
public static Cluster swapRandomPartitionsWithinZone(Cluster nextCandidateCluster, int zoneId)
nextCandidateCluster
- zoneId
- Zone ID within which to shuffle partitions
public static Cluster swapRandomPartitionsAmongNodes(Cluster nextCandidateCluster, java.util.List<java.lang.Integer> nodeIds)
nextCandidateCluster
- nodeIds
-
public static Cluster randomShufflePartitions(Cluster nextCandidateCluster, int randomSwapAttempts, int randomSwapSuccesses, java.util.List<java.lang.Integer> randomSwapZoneIds, java.util.List<StoreDefinition> storeDefs)
nextCandidateCluster
- cluster object.randomSwapAttempts
- See RebalanceCLI.randomSwapSuccesses
- See RebalanceCLI.randomSwapZoneIds
- The set of zoneIds to consider. Each zone is done
independently.storeDefs
- List of store definitions
public static Cluster swapGreedyRandomPartitions(Cluster nextCandidateCluster, java.util.List<java.lang.Integer> nodeIds, int greedySwapMaxPartitionsPerNode, int greedySwapMaxPartitionsPerZone, java.util.List<StoreDefinition> storeDefs)
nextCandidateCluster
- nodeIds
- Node IDs within which to shuffle partitionsgreedySwapMaxPartitionsPerNode
- See RebalanceCLI.greedySwapMaxPartitionsPerZone
- See RebalanceCLI.storeDefs
-
public static Cluster greedyShufflePartitions(Cluster nextCandidateCluster, int greedyAttempts, int greedySwapMaxPartitionsPerNode, int greedySwapMaxPartitionsPerZone, java.util.List<java.lang.Integer> greedySwapZoneIds, java.util.List<StoreDefinition> storeDefs)
nextCandidateCluster
- cluster object.greedyAttempts
- See RebalanceCLI.greedySwapMaxPartitionsPerNode
- See RebalanceCLI.greedySwapMaxPartitionsPerZone
- See RebalanceCLI.greedySwapZoneIds
- The set of zoneIds to consider. Each zone is done
independently.storeDefs
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |