protected int getDonorId ( StoreRoutingPlan currentSRP , StoreRoutingPlan finalSRP , int stealerZoneId , int stealerNodeId , int stealerPartitionId ) { int stealerZoneNAry = finalSRP . getZoneNaryForNodesPartition ( stealerZoneId , stealerNodeId , stealerPartitionId ) ; int donorZoneId ; if ( currentSRP . zoneNAryExists ( stealerZoneId , stealerZoneNAry , stealerPartitionId ) ) { // Steal from local n-ary (since one exists). donorZoneId = stealerZoneId ; } else { // Steal from zone that hosts primary partition Id. int currentMasterNodeId = currentSRP . getNodeIdForPartitionId ( stealerPartitionId ) ; donorZoneId = currentCluster . getNodeById ( currentMasterNodeId ) . getZoneId ( ) ; } return currentSRP . getNodeIdForZoneNary ( donorZoneId , stealerZoneNAry , stealerPartitionId ) ; }
Decide which donor node to steal from . This is a policy implementation . I . e . in the future additional policies could be considered . At that time this method should be overridden in a sub - class or a policy object ought to implement this algorithm .