final void rebalance ( ) { // Let's start distribute the vbuckets across the servers configurationRwLock . writeLock ( ) . lock ( ) ; try { Info . incrementConfigRevision ( ) ; List < MemcachedServer > nodes = activeServers ( ) ; for ( int ii = 0 ; ii < numVBuckets ; ++ ii ) { Collections . shuffle ( nodes ) ; vbInfo [ ii ] . setOwner ( nodes . get ( 0 ) ) ; if ( nodes . size ( ) < 2 ) { continue ; } List < MemcachedServer > replicas = nodes . subList ( 1 , nodes . size ( ) ) ; if ( replicas . size ( ) > numReplicas ) { replicas = replicas . subList ( 0 , numReplicas ) ; } vbInfo [ ii ] . setReplicas ( replicas ) ; } } finally { Info . incrementConfigRevision ( ) ; configurationRwLock . writeLock ( ) . unlock ( ) ; } }
Issues a rebalance within the bucket . vBuckets which are mapped to failed - over nodes are relocated with their first replica being promoted to active .