static private void updateShares ( Cluster clusters [ ] ) { assert ( clusters . length == 2 ) ; if ( clusters [ 0 ] . runnableMaps == 0 && clusters [ 0 ] . runnableMaps == 0 && clusters [ 1 ] . runnableReduces == 0 && clusters [ 1 ] . runnableReduces == 0 ) { // Do nothing if both clusters are empty return ; } // Update target task shares using runnable tasks and weight if ( ! ( clusters [ 0 ] . runnableMaps == 0 && clusters [ 1 ] . runnableMaps == 0 ) ) { clusters [ 0 ] . targetMapShare = clusters [ 0 ] . runnableMaps * clusters [ 0 ] . weight / ( clusters [ 0 ] . runnableMaps * clusters [ 0 ] . weight + clusters [ 1 ] . runnableMaps * clusters [ 1 ] . weight ) ; clusters [ 1 ] . targetMapShare = 1 - clusters [ 0 ] . targetMapShare ; } if ( ! ( clusters [ 0 ] . runnableReduces == 0 && clusters [ 1 ] . runnableReduces == 0 ) ) { clusters [ 0 ] . targetReduceShare = clusters [ 0 ] . runnableReduces * clusters [ 0 ] . weight / ( clusters [ 0 ] . runnableReduces * clusters [ 0 ] . weight + clusters [ 1 ] . runnableReduces * clusters [ 1 ] . weight ) ; clusters [ 1 ] . targetReduceShare = 1 - clusters [ 0 ] . targetReduceShare ; } for ( int i = 0 ; i < 2 ; ++ i ) { LOG . info ( String . format ( "Update Shares. " + "cluster%s:%s runnableMaps:%s runnableReduces:%s " + "weight:%s targetMapShare:%s targetReduceShare:%s" , i , clusters [ i ] . address , clusters [ i ] . weight , clusters [ i ] . runnableMaps , clusters [ i ] . runnableReduces , clusters [ i ] . targetMapShare , clusters [ i ] . targetReduceShare ) ) ; } }
Update the task share of the clusters