use of voldemort.server.rebalance.async.StealerBasedRebalanceAsyncOperation in project voldemort by voldemort.
the class Rebalancer method rebalanceNode.
/**
* This function is responsible for starting the actual async rebalance
* operation. This is run if this node is the stealer node
*
* <br>
*
* We also assume that the check that this server is in rebalancing state
* has been done at a higher level
*
* @param stealInfo Partition info to steal
* @return Returns a id identifying the async operation
*/
public int rebalanceNode(final RebalanceTaskInfo stealInfo) {
final RebalanceTaskInfo info = metadataStore.getRebalancerState().find(stealInfo.getDonorId());
// Do we have the plan in the state?
if (info == null) {
throw new VoldemortException("Could not find plan " + stealInfo + " in the server state on " + metadataStore.getNodeId());
} else if (!info.equals(stealInfo)) {
// If we do have the plan, is it the same
throw new VoldemortException("The plan in server state " + info + " is not the same as the process passed " + stealInfo);
} else if (!acquireRebalancingPermit(stealInfo.getDonorId())) {
// Both are same, now try to acquire a lock for the donor node
throw new AlreadyRebalancingException("Node " + metadataStore.getNodeId() + " is already rebalancing from donor " + info.getDonorId() + " with info " + info);
}
// Acquired lock successfully, start rebalancing...
int requestId = asyncService.getUniqueRequestId();
// Why do we pass 'info' instead of 'stealInfo'? So that we can change
// the state as the stores finish rebalance
asyncService.submitOperation(requestId, new StealerBasedRebalanceAsyncOperation(this, voldemortConfig, metadataStore, requestId, info));
return requestId;
}
Aggregations