protected void populateTasksByStealer ( List < StealerBasedRebalanceTask > sbTaskList ) { // Setup mapping of stealers to work for this run. for ( StealerBasedRebalanceTask task : sbTaskList ) { if ( task . getStealInfos ( ) . size ( ) != 1 ) { throw new VoldemortException ( "StealerBasedRebalanceTasks should have a list of RebalancePartitionsInfo of length 1." ) ; } RebalanceTaskInfo stealInfo = task . getStealInfos ( ) . get ( 0 ) ; int stealerId = stealInfo . getStealerId ( ) ; if ( ! this . tasksByStealer . containsKey ( stealerId ) ) { this . tasksByStealer . put ( stealerId , new ArrayList < StealerBasedRebalanceTask > ( ) ) ; } this . tasksByStealer . get ( stealerId ) . add ( task ) ; } if ( tasksByStealer . isEmpty ( ) ) { return ; } // Shuffle order of each stealer's work list. This randomization // helps to get rid of any "patterns" in how rebalancing tasks were // added to the task list passed in. for ( List < StealerBasedRebalanceTask > taskList : tasksByStealer . values ( ) ) { Collections . shuffle ( taskList ) ; } }
Go over the task list and create a map of stealerId - > Tasks