voldemort.server.rebalance
Class Rebalancer

java.lang.Object
  extended by voldemort.server.rebalance.Rebalancer
All Implemented Interfaces:
java.lang.Runnable

public class Rebalancer
extends java.lang.Object
implements java.lang.Runnable

Service responsible for rebalancing
Handles two scenarios a) When a new request comes in b) When a rebalancing was shut down and the box was restarted


Constructor Summary
Rebalancer(StoreRepository storeRepository, MetadataStore metadataStore, VoldemortConfig voldemortConfig, AsyncOperationService asyncService)
           
 
Method Summary
 boolean acquireRebalancingPermit(int nodeId)
          Acquire a permit for a particular node id so as to allow rebalancing
 AsyncOperationService getAsyncOperationService()
           
 int rebalanceNode(RebalancePartitionsInfo stealInfo)
          This function is responsible for starting the actual async rebalance operation
We also assume that the check that this server is in rebalancing state has been done at a higher level
 void rebalanceStateChange(Cluster cluster, java.util.List<RebalancePartitionsInfo> rebalancePartitionsInfo, boolean swapRO, boolean changeClusterMetadata, boolean changeRebalanceState, boolean rollback)
          Support four different stages
For normal operation:
 void releaseRebalancingPermit(int nodeId)
          Release the rebalancing permit for a particular node id
 void run()
          This is called only once at startup
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rebalancer

public Rebalancer(StoreRepository storeRepository,
                  MetadataStore metadataStore,
                  VoldemortConfig voldemortConfig,
                  AsyncOperationService asyncService)
Method Detail

getAsyncOperationService

public AsyncOperationService getAsyncOperationService()

start

public void start()

stop

public void stop()

run

public void run()
This is called only once at startup

Specified by:
run in interface java.lang.Runnable

acquireRebalancingPermit

public boolean acquireRebalancingPermit(int nodeId)
Acquire a permit for a particular node id so as to allow rebalancing

Parameters:
nodeId - The id of the node for which we are acquiring a permit
Returns:
Returns true if permit acquired, false if the permit is already held by someone

releaseRebalancingPermit

public void releaseRebalancingPermit(int nodeId)
Release the rebalancing permit for a particular node id

Parameters:
nodeId - The node id whose permit we want to release

rebalanceStateChange

public void rebalanceStateChange(Cluster cluster,
                                 java.util.List<RebalancePartitionsInfo> rebalancePartitionsInfo,
                                 boolean swapRO,
                                 boolean changeClusterMetadata,
                                 boolean changeRebalanceState,
                                 boolean rollback)
Support four different stages
For normal operation:
 | swapRO | changeClusterMetadata | changeRebalanceState | Order |
 | f | t | t | cluster -> rebalance | 
 | f | f | t | rebalance |
 | t | t | f | cluster -> swap |
 | t | t | t | cluster -> swap -> rebalance |
 
In general we need to do [ cluster change -> swap -> rebalance state change ]

Parameters:
cluster - Cluster metadata to change
rebalancePartitionsInfo - List of rebalance partitions info
swapRO - Boolean to indicate swapping of RO store
changeClusterMetadata - Boolean to indicate a change of cluster metadata
changeRebalanceState - Boolean to indicate a change in rebalance state
rollback - Boolean to indicate that we are rolling back or not

rebalanceNode

public int rebalanceNode(RebalancePartitionsInfo stealInfo)
This function is responsible for starting the actual async rebalance operation
We also assume that the check that this server is in rebalancing state has been done at a higher level

Parameters:
stealInfo - Partition info to steal
Returns:
Returns a id identifying the async operation


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao