KLALB大更新

新负载均衡算法
This commit is contained in:
Administrator
2023-07-02 13:20:11 +08:00
parent f743b23e53
commit 585b7c5fe6
59 changed files with 1681 additions and 553 deletions
@@ -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;
}
}