KLALB V3.4

This commit is contained in:
Administrator
2025-11-15 11:08:16 +08:00
parent 306bfd36f7
commit 8842566ee2
160 changed files with 18540 additions and 4512 deletions
+49 -14
View File
@@ -39,8 +39,43 @@ 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) {
public static String convertUintNanoDefalut(long v) {
if(v>=1000L*1000L*1000L*1000L*1000L) {
return format( v/(1000.0*1000.0*1000.0*1000.0*1000.0))+"M";
}else if(v>=1000L*1000L*1000L*1000L) {
return format (v/(1000.0*1000.0*1000.0*1000.0))+"K";
}else if(v>=1000L*1000L*1000L) {
return format( v/(1000.0*1000.0*1000.0));
}else if(v>=1000L*1000L) {
return format( v/(1000.0*1000.0))+"m";
}else if(v>=1000L) {
return format( v/(1000.0))+"u";
}else {
return Long.toString(v)+"n" ;
}
}
public static String convertUintDefalut(long v) {
if(v>=1000L*1000L*1000L*1000L*1000L) {
return format( v/(1000.0*1000.0*1000.0*1000.0*1000.0))+"P";
}else if(v>=1000L*1000L*1000L*1000L) {
return format (v/(1000.0*1000.0*1000.0*1000.0))+"T";
}else if(v>=1000L*1000L*1000L) {
return format( v/(1000.0*1000.0*1000.0))+"G";
}else if(v>=1000L*1000L) {
return format( v/(1000.0*1000.0))+"M";
}else if(v>=1000L) {
return format( v/(1000.0))+"K";
}else {
return Long.toString(v) ;
}
}
public static String convertIBUint(long v) {
return convertIUintDefalut(v)+"B";
/*if (v >= 1024L * 1024 * 1024 * 1024 * 1024) {
return String.format("%.2f", v / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)) + "PB";
} else if (v >= 1024L * 1024 * 1024 * 1024) {
return String.format("%.2f", v / (1024.0 * 1024.0 * 1024.0 * 1024.0)) + "TB";
@@ -52,9 +87,9 @@ public class KLALBUtils {
return String.format("%.2f", v / (1024.0)) + "KB";
} else {
return v + "B";
}
}*/
}
public static String bytesUnitSimp(long v) {
public static String convertIBUintSimp(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) {
@@ -71,17 +106,17 @@ public class KLALBUtils {
}
public static String defaultUnit(long v) {
public static String convertIUintDefalut(long v) {
if(v>=1024L*1024*1024*1024*1024) {
return format( v/(1024.0*1024.0*1024.0*1024.0*1024.0))+"P";
return format( v/(1024.0*1024.0*1024.0*1024.0*1024.0))+"Pi";
}else if(v>=1024L*1024*1024*1024) {
return format (v/(1024.0*1024.0*1024.0*1024.0))+"T";
return format (v/(1024.0*1024.0*1024.0*1024.0))+"Ti";
}else if(v>=1024L*1024*1024) {
return format( v/(1024.0*1024.0*1024.0))+"G";
return format( v/(1024.0*1024.0*1024.0))+"Gi";
}else if(v>=1024L*1024) {
return format( v/(1024.0*1024.0))+"M";
return format( v/(1024.0*1024.0))+"Mi";
}else if(v>=1024L) {
return format( v/(1024.0))+"K";
return format( v/(1024.0))+"Ki";
}else {
return Long.toString(v) ;
}
@@ -164,9 +199,9 @@ public class KLALBUtils {
if (targetAddress.supportNIO()) {
if (bindAddress != null) {
return new StreamChannelKLALBPacketLink(targetAddress
.connectSocketChannel(InetAddress.getByName(bindAddress.getHost()), bindAddress.getPort()));
.connectSocketChannel(InetAddress.getByName(bindAddress.getHost()), bindAddress.getPort()),buffered);
} else {
return new StreamChannelKLALBPacketLink(targetAddress.connectSocketChannel());
return new StreamChannelKLALBPacketLink(targetAddress.connectSocketChannel(),buffered);
}
} else {
if (bindAddress != null) {
@@ -192,10 +227,10 @@ public class KLALBUtils {
if (bindAddress != null) {
if(buffered) {
return new StreamChannelKLALBPacketLink(targetAddress
.connectSocketChannel(InetAddress.getByName(bindAddress.getHost()), bindAddress.getPort(),timeout));
.connectSocketChannel(InetAddress.getByName(bindAddress.getHost()), bindAddress.getPort(),timeout),buffered);
}else {
return new StreamChannelKLALBPacketLink(targetAddress
.connectSocketChannel(InetAddress.getByName(bindAddress.getHost()), bindAddress.getPort(),timeout));
.connectSocketChannel(InetAddress.getByName(bindAddress.getHost()), bindAddress.getPort(),timeout),buffered);
}
} else {
if(buffered) {