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
@@ -1,7 +1,7 @@
package org.kne.cloud.network.klalb;
import java.net.SocketException;
import java.net.SocketImpl;
import java.io.IOException;
import java.net.*;
import org.kne.cloud.network.mport.VirtualSocket;
@@ -11,11 +11,52 @@ public class KLALBVirtualSocket extends VirtualSocket {
public KLALBVirtualSocket(KLALBController controler) throws SocketException {
super(controler.createVirtualImpl());
this.controler=controler;
this.controler = controler;
}
protected KLALBController getControler() {
return controler;
}
public KLALBVirtualSocket(KLALBController controler,String host, int port) throws UnknownHostException, IOException {
this(controler,host != null ? new InetSocketAddress(host, port)
: new InetSocketAddress(InetAddress.getByName(null), port), (SocketAddress) null);
}
public KLALBVirtualSocket(KLALBController controler,SocketAddress address, SocketAddress localAddr) throws IOException {
this(controler);
// backward compatibility
if (address == null)
throw new NullPointerException();
try {
if (localAddr != null)
bind(localAddr);
connect(address);
} catch (IOException | IllegalArgumentException | SecurityException e) {
try {
close();
} catch (IOException ce) {
e.addSuppressed(ce);
}
throw e;
}
}
public KLALBVirtualSocket(KLALBController controler,String host, int port, InetAddress localAddr, int localPort) throws IOException {
this(controler,host != null ? new InetSocketAddress(host, port)
: new InetSocketAddress(InetAddress.getByName(null), port),
new InetSocketAddress(localAddr, localPort));
}
public KLALBVirtualSocket(KLALBController controler,InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException {
this(controler,address != null ? new InetSocketAddress(address, port) : null,
new InetSocketAddress(localAddr, localPort));
}
public KLALBVirtualSocket(KLALBController controler,InetAddress address, int port) throws IOException {
this(controler,address != null ? new InetSocketAddress(address, port) : null,
(SocketAddress) null);
}
}