voldemort.client.rebalance
Class RebalanceScheduler

java.lang.Object
  extended by voldemort.client.rebalance.RebalanceScheduler

public class RebalanceScheduler
extends java.lang.Object

Scheduler for rebalancing tasks. There is at most one rebalancing task per stealer-donor pair. This scheduler ensures the following invariant is obeyed: A node works on no more than one rebalancing task at a time. Note that a node working on a rebalancing task may be either a stealer or a donor. This invariant should somewhat isolate the foreground workload against the work a server must do for rebalancing. Because of this isolation, it is safe to attempt "infinite" parallelism since no more than floor(number of nodes / 2) rebalancing tasks can possibly be scheduled to execute while obeying the invariant. The order of tasks are randomized within this class. The intent is to "spread" rebalancing work smoothly out over the cluster and avoid "long tails" of straggler rebalancing tasks. Only experience will tell us if we need to do anything smarter.


Constructor Summary
RebalanceScheduler(java.util.concurrent.ExecutorService service, int maxParallelRebalancing)
           
 
Method Summary
 void addNodesToWorkerList(java.util.List<java.lang.Integer> nodeIds)
          Add nodes to the workers list
 void doneTask(int stealerId, int donorId)
          Method must be invoked upon completion of a rebalancing task.
protected  void initializeLatch(int size)
          Initialize the count down latch.
protected  void populateTasksByStealer(java.util.List<StealerBasedRebalanceTask> sbTaskList)
          Go over the task list and create a map of stealerId -> Tasks
 void removeNodesFromWorkerList(java.util.List<java.lang.Integer> nodeIds)
          Removes nodes from the workers list
 void run(java.util.List<StealerBasedRebalanceTask> sbTaskList)
          Set up scheduling structures and then start scheduling tasks to execute.
protected  StealerBasedRebalanceTask scheduleNextTask(boolean executeService)
          Schedule at most one task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RebalanceScheduler

public RebalanceScheduler(java.util.concurrent.ExecutorService service,
                          int maxParallelRebalancing)
Method Detail

initializeLatch

protected void initializeLatch(int size)
Initialize the count down latch.

Parameters:
size - of the task list

populateTasksByStealer

protected void populateTasksByStealer(java.util.List<StealerBasedRebalanceTask> sbTaskList)
Go over the task list and create a map of stealerId -> Tasks

Parameters:
sbTaskList - List of all stealer-based rebalancing tasks to be scheduled.

run

public void run(java.util.List<StealerBasedRebalanceTask> sbTaskList)
Set up scheduling structures and then start scheduling tasks to execute. Blocks until all tasks have been scheduled. (For all tasks to be scheduled, most tasks must have completed.)

Parameters:
sbTaskList - List of all stealer-based rebalancing tasks to be scheduled.

scheduleNextTask

protected StealerBasedRebalanceTask scheduleNextTask(boolean executeService)
Schedule at most one task. The scheduled task *must* invoke 'doneTask()' upon completion/termination.

Parameters:
executeService - flag to control execution of the service, some tests pass in value 'false'
Returns:
The task scheduled or null if not possible to schedule a task at this time.

addNodesToWorkerList

public void addNodesToWorkerList(java.util.List<java.lang.Integer> nodeIds)
Add nodes to the workers list

Parameters:
nodeIds - list of node ids.

removeNodesFromWorkerList

public void removeNodesFromWorkerList(java.util.List<java.lang.Integer> nodeIds)
Removes nodes from the workers list

Parameters:
nodeIds - list of node ids.

doneTask

public void doneTask(int stealerId,
                     int donorId)
Method must be invoked upon completion of a rebalancing task. It is the task's responsibility to do so.

Parameters:
stealerId -
donorId -


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu