use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class IntegTestClientToEchoServer method testSoTimeoutOnSocket.
public void testSoTimeoutOnSocket() throws InterruptedException {
runEchoServer();
BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
DataListener listener = new ClientDataListener(pool2, recorder);
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
TCPChannel channel = createClientChannel(pool2, executor2);
// TCPChannel channel = createNettyChannel();
recorder.start();
XFuture<Void> connect = channel.connect(new InetSocketAddress(4444), listener);
connect.thenAccept(p -> runWriting(channel));
synchronized (this) {
this.wait();
}
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestSvrReading method setup.
@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
MeterRegistry meters = Metrics.globalRegistry;
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
DirectExecutor exec = new DirectExecutor();
BackpressureConfig config = new BackpressureConfig();
config.setMaxBytes(6);
config.setStartReadingThreshold(2);
ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), config, exec);
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
listener = new MockAsyncListener();
AsyncServer server = svrMgr.createTcpServer(new AsyncConfig(), listener);
XFuture<Void> future = server.start(new InetSocketAddress(4444));
Assert.assertFalse(future.isDone());
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
future.get(2, TimeUnit.SECONDS);
mockSvrChannel.addNewChannel(mockChannel);
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
Assert.assertEquals(1, listener.getNumTimesCalledConnectionOpen());
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class IntegTestLocalhostThroughput method testThroughput.
public void testThroughput() throws InterruptedException, ExecutionException, TimeoutException {
Executor executor = Executors.newFixedThreadPool(10, new NamedThreadFactory("serverThread"));
BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
BackpressureConfig config = new BackpressureConfig();
config.setMaxBytes(16_384 * 10);
config.setStartReadingThreshold(512);
ChannelManager mgr = createChanMgr("server", executor, pool, config);
AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr, Metrics.globalRegistry);
AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new AsyncServerDataListener(recorder, pool));
server.start(new InetSocketAddress(8080));
BufferPool pool2 = new TwoPools("p2", new SimpleMeterRegistry());
DataListener listener = new ClientDataListener(pool2, recorder);
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
TCPChannel channel = createClientChannel(pool2, executor2, config);
recorder.setClientChannel(channel);
recorder.start();
XFuture<Void> connect = channel.connect(new InetSocketAddress(8080), listener);
connect.get(2, TimeUnit.SECONDS);
synchronized (this) {
this.wait();
}
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestCancelStream method setup.
@Before
public void setup() {
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
TwoPools pool = new TwoPools("client.bufferpool", metrics);
HttpParser parser = HttpParserFactory.createParser("testParser", metrics, pool);
httpClient = HttpClientFactory.createHttpClient("testClient", mockChanMgr, parser);
mockChannel.setConnectFuture(XFuture.completedFuture(null));
mockChanMgr.addTCPChannelToReturn(mockChannel);
httpSocket = httpClient.createHttpSocket(new SocketListener());
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestChunking method setup.
@Before
public void setup() {
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
TwoPools pool = new TwoPools("client.bufferpool", metrics);
HttpParser parser = HttpParserFactory.createParser("testParser", metrics, pool);
httpClient = HttpClientFactory.createHttpClient("testClient", mockChanMgr, parser);
mockChannel.setConnectFuture(XFuture.completedFuture(null));
mockChanMgr.addTCPChannelToReturn(mockChannel);
httpSocket = httpClient.createHttpSocket(new SocketListener());
}
Aggregations