nl_tokens: Evaluate the allocation share of a bucket among all the buckets for which allocations are defined . If there are no allocations setup return 1 . 0 implying 100% . If no allocation is setup for the given <code > bucket< / code > return a small value . Otherwise calculate the share percentage of each resource cpu memory network and disk from the total and return the maximum of these shares .
pl_tokens: double evalAllocationShare ( String bucket ) { if ( allocsMap . isEmpty ( ) ) { return 1.0 ; // special case if there are no allocations setup } final ResAllocs resAllocs = allocsMap . get ( bucket ) ; if ( resAllocs == null ) return totalCpu < ( 1.0 / eps ) ? eps : 1.0 / totalCpu ; // arbitrarily base it on cpus double val = totalCpu < 1.0 ? eps : resAllocs . getCores ( ) / totalCpu ; val = Math . <mask> ( val , totalMem < 1.0 ? eps : resAllocs . getMemory ( ) / totalMem ) ; val = Math . max ( val , totalNetwork < 1.0 ? eps : resAllocs . getNetworkMbps ( ) / totalNetwork ) ; return Math . max ( val , totalDisk < 1.0 ? eps : resAllocs . getDisk ( ) / totalDisk ) ; }