forked from KNEMC/KLALB
KLALB大更新
新负载均衡算法
This commit is contained in:
@@ -29,4 +29,29 @@ public class KLALBUtils {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(uuidToIP(new UUID(-1,-1)));
|
||||
}
|
||||
public static String bytesUnit(long v) {
|
||||
if(v>=1024L*1024*1024*1024*1024) {
|
||||
return format( v/(1024.0*1024.0*1024.0*1024.0*1024.0))+"P";
|
||||
}else if(v>=1024L*1024*1024*1024) {
|
||||
return format (v/(1024.0*1024.0*1024.0*1024.0))+"T";
|
||||
}else if(v>=1024L*1024*1024) {
|
||||
return format( v/(1024.0*1024.0*1024.0))+"G";
|
||||
}else if(v>=1024L*1024) {
|
||||
return format( v/(1024.0*1024.0))+"M";
|
||||
}else if(v>=1024L) {
|
||||
return format( v/(1024.0))+"K";
|
||||
}else {
|
||||
return v+"B";
|
||||
}
|
||||
}
|
||||
private static String format( double d) {
|
||||
String fmt=String.format( "%.2f",d);
|
||||
if(fmt.length()>4) {
|
||||
fmt=fmt.substring(0, 4);
|
||||
}
|
||||
if(fmt.endsWith(".")) {
|
||||
fmt=fmt.substring(0, fmt.length()-1);
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user