use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.
the class IntegTestLocalhostThroughput method testSoTimeoutOnSocket.
public void testSoTimeoutOnSocket() throws InterruptedException {
Executor executor = Executors.newFixedThreadPool(10, new NamedThreadFactory("serverThread"));
BufferPool pool = new BufferCreationPool();
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createMultiThreadedChanMgr("server", pool, executor);
AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr);
AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestLocalhostServerListener());
server.start(new InetSocketAddress(8080));
BufferPool pool2 = new BufferCreationPool();
DataListener listener = new ClientDataListener(pool2, recorder);
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
TCPChannel channel = createClientChannel(pool2, executor2);
//TCPChannel channel = createNettyChannel();
recorder.start();
CompletableFuture<Channel> connect = channel.connect(new InetSocketAddress(8080), listener);
connect.thenAccept(p -> runWriting(channel));
synchronized (this) {
this.wait();
}
}
use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.
the class IntegTestClientNotRead method testSoTimeoutOnSocket.
public void testSoTimeoutOnSocket() throws InterruptedException {
BufferCreationPool pool = new BufferCreationPool();
AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer("server", pool);
AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestClientNotReadListener());
server.start(new InetSocketAddress(8080));
BufferCreationPool pool2 = new BufferCreationPool();
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createSingleThreadedChanMgr("client", pool2);
TCPChannel channel = mgr.createTCPChannel("clientChan");
log.info("client");
timer.schedule(new TimerTask() {
@Override
public void run() {
logBytesTxfrd();
}
}, 1000, 5000);
CompletableFuture<Channel> connect = channel.connect(new InetSocketAddress(8080), new ClientDataListener());
connect.thenAccept(p -> runWriting(channel));
Thread.sleep(1000000000);
}
use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.
the class TestBasicSslClientServer method testBasic.
@Test
public void testBasic() throws InterruptedException {
pool = new BufferCreationPool();
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createSingleThreadedChanMgr("sslChanMgr", pool);
AsyncServerManager svrFactory = AsyncServerMgrFactory.createAsyncServer(mgr);
SSLEngineFactoryForTest f = new SSLEngineFactoryForTest();
InetSocketAddress addr = new InetSocketAddress("localhost", 0);
AsyncServer svr = svrFactory.createTcpServer(new AsyncConfig("sslTcpSvr"), new SvrDataListener(), f);
svr.start(addr);
InetSocketAddress bound = svr.getUnderlyingChannel().getLocalAddress();
System.out.println("port=" + bound.getPort());
TCPChannel channel = mgr.createTCPChannel("client", f.createEngineForSocket());
CompletableFuture<Channel> connect = channel.connect(bound, new ClientListener());
connect.thenAccept(c -> writeData(c));
synchronized (pool) {
while (values.size() < 10) pool.wait();
}
for (int i = 0; i < values.size(); i++) {
Assert.assertEquals(new Integer(i), values.get(i));
}
}
use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.
the class IntegTestEchoClientToOurServer method testSoTimeoutOnSocket.
public void testSoTimeoutOnSocket() throws InterruptedException {
EchoClient client = new EchoClient();
Executor executor = Executors.newFixedThreadPool(10, new NamedThreadFactory("serverThread"));
BufferPool pool = new BufferCreationPool();
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createMultiThreadedChanMgr("server", pool, executor);
AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr);
AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestLocalhostServerListener());
server.start(new InetSocketAddress(8080));
client.start(8080);
synchronized (this) {
this.wait();
}
}
use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.
the class HttpFrontendFactory method createFrontEnd.
/**
*
* @param id Use for logging and also file recording names
* @param threadPoolSize The size of the threadpool, although all data comes in order as we
* use the SessionExecutorImpl found in webpieces
*
* @return
*/
public static HttpFrontendManager createFrontEnd(String id, int threadPoolSize, ScheduledExecutorService timer, BufferPool pool) {
Executor executor = Executors.newFixedThreadPool(threadPoolSize, new NamedThreadFactory(id));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager chanMgr = factory.createMultiThreadedChanMgr(id, pool, executor);
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(chanMgr);
HttpParser httpParser = HttpParserFactory.createParser(pool);
HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
InjectionConfig injConfig = new InjectionConfig(http2Parser, new TimeImpl(), new Http2Config());
Http2ServerEngineFactory svrEngineFactory = new Http2ServerEngineFactory(injConfig);
return new FrontEndServerManagerImpl(svrMgr, timer, svrEngineFactory, httpParser);
}
Aggregations