forked from KNEMC/KLALB
KLALB V3.6.0 写了一半
This commit is contained in:
@@ -19,22 +19,21 @@ import org.kne.cloud.network.SocketChannelListener;
|
||||
import org.kne.cloud.network.SocketListener;
|
||||
import org.kne.cloud.network.ipv6.IPv6NetworkLink;
|
||||
import org.kne.cloud.network.ipv6.RouteItem;
|
||||
import org.kne.cloud.network.klalb.ui.KLALBStateGUI2;
|
||||
import org.kne.cloud.network.klalb.ui.KLALBStateGUI3;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
import org.kne.cloud.network.perf.Kperf;
|
||||
import org.kne.cloud.network.perf.MemcpyBenchmark;
|
||||
import org.kne.cloud.network.perf.NodeBenchmark;
|
||||
import org.kne.debug.Debuger;
|
||||
import org.kne.debug.TimeDebugger;
|
||||
import org.kne.membandboost.MembandBenchmark;
|
||||
|
||||
public class KLALBMain {
|
||||
public static KLALBStateGUI3 ksg;
|
||||
public static void main(String[] args) throws IOException {
|
||||
try {
|
||||
UIEnv.inituie();
|
||||
}catch(Exception e) {
|
||||
|
||||
}catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(CONST.klalb+" V"+CONST.klalbver);
|
||||
Scanner scn=new Scanner(System.in);
|
||||
@@ -46,7 +45,9 @@ public class KLALBMain {
|
||||
dtb.putTime("Create");
|
||||
kpcje.loadConfigJson(configJson);
|
||||
dtb.putTime("Load");
|
||||
System.out.println("SRv6地址:"+kpcje.getKlalbController().getSelf().getAddress().getHostAddress());
|
||||
System.out.println("=".repeat(65));
|
||||
System.out.println(" - IPv6 Address / End SID: "+kpcje.getKlalbController().getSelf().getAddress());
|
||||
System.out.println("=".repeat(65));
|
||||
try {
|
||||
if(!kpcje.getControllerConfig().isNogui())
|
||||
openGUI(kpcje);
|
||||
@@ -70,22 +71,28 @@ public class KLALBMain {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
System.out.println("Done!");
|
||||
while(true) {
|
||||
System.out.print("KLALB>");
|
||||
try {
|
||||
String s=scn.nextLine();
|
||||
String[]sc=s.trim().split(" ");
|
||||
String tri=s.trim();
|
||||
if(tri.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String[]sc=tri.split(" ");
|
||||
switch(sc[0]) {
|
||||
case "?":
|
||||
case "help":
|
||||
System.out.println("help:查看命令使用说明");
|
||||
System.out.println("monitor:显示监视器图形界面");
|
||||
System.out.println("lines-state:查看线路状态");
|
||||
System.out.println("lines-add <地址:端口>:添加线路");
|
||||
System.out.println("lines-remove <地址:端口>:删除线路");
|
||||
System.out.println("lines-reconnect:所有离线线路立即尝试重连");
|
||||
System.out.println("route:显示路由表");
|
||||
System.out.println("kperf <地址:端口>:网络性能测试");
|
||||
System.out.println("stop:退出程序");
|
||||
System.out.println(" help / ?: see help");
|
||||
System.out.println(" monitor: show monitor GUI");
|
||||
System.out.println(" links-state: query link states");
|
||||
System.out.println(" links-add <addr:port>: add link");
|
||||
System.out.println(" links-remove <addr:port>: remove link");
|
||||
System.out.println(" links-reconnect: reconnect all link");
|
||||
System.out.println(" route: display internal route table");
|
||||
System.out.println(" kperf <addr:port>: Porformance benchmark");
|
||||
System.out.println(" exit: Exit");
|
||||
break;
|
||||
|
||||
case "monitor":
|
||||
@@ -95,8 +102,8 @@ public class KLALBMain {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case "lines-state":
|
||||
System.out.println("线路状态:");
|
||||
case "links-state":
|
||||
System.out.println("links state:");
|
||||
System.out.println("状态\t上传流量\t下载流量\t上传速度\t下载速度\t上传延迟\t下载延迟\t上传抖动\t下载抖动");
|
||||
synchronized (kpcje.getKlalbController().getLines()) {
|
||||
for (Iterator<IPv6NetworkLink> iterator = kpcje.getKlalbController().getLines().iterator(); iterator.hasNext();) {
|
||||
@@ -108,7 +115,7 @@ public class KLALBMain {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "lines-add":
|
||||
case "links-add":
|
||||
if(sc.length>=2) {
|
||||
MultipurposeSocketAddress mpsa=new MultipurposeSocketAddress(sc[1]);
|
||||
List<KLALBRemoteLine>addl=kpcje.getKlalbController().addRemoteLines(mpsa);
|
||||
@@ -125,39 +132,39 @@ public class KLALBMain {
|
||||
System.out.println("请输入要添加地址:端口!");
|
||||
}
|
||||
break;
|
||||
case "lines-remove":
|
||||
case "links-remove":
|
||||
if(sc.length>=2) {
|
||||
MultipurposeSocketAddress mpsa=new MultipurposeSocketAddress(sc[1]);
|
||||
List<KLALBRemoteLine>rmvl=kpcje.getKlalbController().removeRemoteLines(mpsa);
|
||||
if(rmvl.isEmpty()) {
|
||||
System.out.println("未找到匹配移除项");
|
||||
System.out.println("No matched link has been found.");
|
||||
}else {
|
||||
for (Iterator iterator = rmvl.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
|
||||
System.out.println("移除成功:"+klalbRemoteLine.getMonitor().getName());
|
||||
System.out.println("Successfully removed: "+klalbRemoteLine.getMonitor().getName());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
System.out.println("请输入要添加地址:端口!");
|
||||
System.out.println("Invalid arguments.");
|
||||
}
|
||||
break;
|
||||
case "stop":
|
||||
System.out.println("已退出程序");
|
||||
case "exit":
|
||||
System.out.println("Exited.");
|
||||
System.exit(0);
|
||||
break;
|
||||
case "lines-reconnect":
|
||||
System.out.println("尝试重连断开的线路");
|
||||
case "links-reconnect":
|
||||
System.out.println("Trying to reconnect all links.");
|
||||
kpcje.getKlalbController().reconnectImmediately();
|
||||
break;
|
||||
case "route":
|
||||
List<RouteItem> lri=new ArrayList<>( kpcje.getKlalbController().getIpv6Router().getCurrentRouteTabel());
|
||||
Collections.sort(lri);
|
||||
System.out.println("路由表:");
|
||||
System.out.println("前缀\t协议\t优先级\t开销\t标志\t下一跳\t接口");
|
||||
System.out.println("Route Table:");
|
||||
System.out.println("Prefix\tProtocol\tPref\tCost\tFlag\tNext Hop\tInterface");
|
||||
for (Iterator<RouteItem> iterator = lri.iterator(); iterator.hasNext();) {
|
||||
RouteItem routeItem = (RouteItem) iterator.next();
|
||||
System.out.println(routeItem.getDestination()+"\t"+routeItem.getProto()+"\t"+routeItem.getPre()+"\t"+routeItem.getCost()+"\t"+routeItem.getFlag()+"\t"+routeItem.getNexthop().getHostAddress()+"\t"+routeItem.getDestlink().getName());
|
||||
System.out.println(routeItem.getDestination()+"\t"+routeItem.getProto()+"\t"+routeItem.getPre()+"\t"+routeItem.getCost()+"\t"+routeItem.getFlag()+"\t"+routeItem.getNexthop()+"\t"+routeItem.getDestlink().getName());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -167,31 +174,12 @@ public class KLALBMain {
|
||||
Kperf kp=new Kperf(mpsa);
|
||||
kp.startPerfing();
|
||||
}else {
|
||||
System.out.println("请输入测速服务端地址:端口!");
|
||||
System.out.println("Invalid arguments.");
|
||||
}
|
||||
|
||||
break;
|
||||
case "memcpy":
|
||||
System.out.println("数组拷贝测试");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MemcpyBenchmark. testArrayCopySpeed(256*1024*1024);
|
||||
}
|
||||
System.out.println("Bytebuffer拷贝测试");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MemcpyBenchmark.testByteBufferCopySpeed(256*1024*1024);
|
||||
}
|
||||
System.out.println("Directbytebuffer分配测试");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MemcpyBenchmark.testDirectByteBufferAllocateSpeed(65536);
|
||||
}
|
||||
System.out.println("Bytebuffer分配测试");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MemcpyBenchmark.testByteBufferAllocateSpeed(65536);
|
||||
}
|
||||
System.out.println("BytebufferAllocator分配测试");
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MemcpyBenchmark.testByteBufferAllocatorSpeed(65536);
|
||||
}
|
||||
MembandBenchmark.main(args);
|
||||
break;
|
||||
//case "$$SYSTEM:":
|
||||
//System.out.println();
|
||||
@@ -205,13 +193,13 @@ public class KLALBMain {
|
||||
nbc.startPerfing();
|
||||
break;
|
||||
default:
|
||||
System.out.println("未知命令,请输入help以查询命令说明");
|
||||
System.out.println("Unknown command. See \"help\" or \"?\".");
|
||||
}
|
||||
}catch (NoSuchElementException err) {
|
||||
System.out.println("已退出程序");
|
||||
System.out.println("Exited.");
|
||||
System.exit(0);
|
||||
}catch(RuntimeException e) {
|
||||
System.out.println("错误!");
|
||||
System.out.println("Exception Occured!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user