tp.setMinimumPoolSize(5);
tp.setMaximumPoolSize(25);
tp.setPoolName("TP");
tp.doStart();
ClockPool cp = new ClockPool();
cp.setPoolName("CP");
cp.doStart();
SelectorManager sm = new SelectorManager();
sm.setThreadPool(tp);
sm.setThreadName("SM");
sm.setTimeout(500);
sm.doStart();
SocketProtocol spt = new SocketProtocol();
spt.setUpProtocol(new Protocol() {
public Protocol getUpProtocol() {
throw new NoSuchMethodError();
}
public void setUpProtocol(Protocol up) {
throw new NoSuchMethodError();
}
public Protocol getDownProtocol() {
throw new NoSuchMethodError();
}
public void setDownProtocol(Protocol down) {
throw new NoSuchMethodError();
}
public void clearLinks() {
}
public Protocol cloneProtocol() throws CloneNotSupportedException {
return (Protocol) super.clone();
}
public void setup() {
}
public void drain() {
}
public void teardown() throws ProtocolException {
}
public void sendUp(UpPacket packet) {
System.out.println("BAR ");
}
public void sendDown(DownPacket packet) {
}
});
spt.setTimeout(10 * 1000);
spt.setSelectorManager(sm);
ProtocolFactory pf = new ProtocolFactory();
pf.setClockPool(cp);
pf.setMaxAge(Long.MAX_VALUE);
pf.setMaxInactivity(1 * 60 * 60 * 1000);
pf.setReclaimPeriod(10 * 1000);
pf.setTemplate(spt);
ServerSocketAcceptor ssa = new ServerSocketAcceptor();
ssa.setSelectorManager(sm);
ssa.setTimeOut(5 * 1000);
ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
ssa.setAcceptorListener(pf);
ssa.startup();
SocketProtocol sp = new SocketProtocol();
sp.setUpProtocol(new Protocol() {
public Protocol getUpProtocol() {
throw new NoSuchMethodError();
}
public void setUpProtocol(Protocol up) {
throw new NoSuchMethodError();
}
public Protocol getDownProtocol() {
throw new NoSuchMethodError();
}
public void setDownProtocol(Protocol down) {
throw new NoSuchMethodError();
}
public void clearLinks() {
}
public Protocol cloneProtocol() throws CloneNotSupportedException {
return (Protocol) super.clone();
}
public void setup() {
}
public void drain() {
}
public void teardown() throws ProtocolException {
}
public void sendUp(UpPacket packet) {
}
public void sendDown(DownPacket packet) {
}
});
sp.setTimeout(10 * 1000);
sp.setInterface(new InetSocketAddress(ssa.getConnectURI().getHost(), 0));
sp.setAddress(new InetSocketAddress(ssa.getConnectURI().getHost(), ssa.getConnectURI().getPort()));
sp.setSelectorManager(sm);
sp.setup();
sp.sendDown(getDatagramPacket());
sp.sendDown(getDatagramPacket());
sp.sendDown(getDatagramPacket());
DatagramDownPacket packet = getDatagramPacket();
sp.sendDown(packet);
sp.sendDown(packet);
Thread.sleep(5 * 1000);
sp.drain();
ssa.drain();
pf.drain();
spt.drain();
sm.doStop();
cp.doStop();
tp.doStop();
}