private static FactorComparator < Executor > getCpuUsageComparator ( final int weight ) { return FactorComparator . create ( CPUUSAGE_COMPARATOR_NAME , weight , new Comparator < Executor > ( ) { @ Override public int compare ( final Executor o1 , final Executor o2 ) { final ExecutorInfo stat1 = o1 . getExecutorInfo ( ) ; final ExecutorInfo stat2 = o2 . getExecutorInfo ( ) ; final int result = 0 ; if ( statisticsObjectCheck ( stat1 , stat2 , CPUUSAGE_COMPARATOR_NAME ) ) { return result ; } // CPU usage , the lesser the value is, the better. return ( ( Double ) stat2 . getCpuUsage ( ) ) . compareTo ( stat1 . getCpuUsage ( ) ) ; } } ) ; }
function defines the cpuUsage comparator .