private Pair < Double , String > summarizeBalance ( final Map < Integer , Integer > nodeIdToPartitionCount , String title ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "\n" + title + "\n" ) ; Map < Integer , ZoneBalanceStats > zoneToBalanceStats = new HashMap < Integer , ZoneBalanceStats > ( ) ; for ( Integer zoneId : cluster . getZoneIds ( ) ) { zoneToBalanceStats . put ( zoneId , new ZoneBalanceStats ( ) ) ; } for ( Node node : cluster . getNodes ( ) ) { int curCount = nodeIdToPartitionCount . get ( node . getId ( ) ) ; builder . append ( "\tNode ID: " + node . getId ( ) + " : " + curCount + " (" + node . getHost ( ) + ")\n" ) ; zoneToBalanceStats . get ( node . getZoneId ( ) ) . addPartitions ( curCount ) ; } // double utilityToBeMinimized = Double.MIN_VALUE; double utilityToBeMinimized = 0 ; for ( Integer zoneId : cluster . getZoneIds ( ) ) { builder . append ( "Zone " + zoneId + "\n" ) ; builder . append ( zoneToBalanceStats . get ( zoneId ) . dumpStats ( ) ) ; utilityToBeMinimized += zoneToBalanceStats . get ( zoneId ) . getUtility ( ) ; /*- * Another utility function to consider if(zoneToBalanceStats.get(zoneId).getMaxMinRatio() > utilityToBeMinimized) { utilityToBeMinimized = zoneToBalanceStats.get(zoneId).getUtility(); } */ } return Pair . create ( utilityToBeMinimized , builder . toString ( ) ) ; }
Summarizes balance for the given nodeId to PartitionCount .