use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestHandshakeBackpressure method setup.
@Before
public void setup() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
System.setProperty("jdk.tls.server.protocols", "TLSv1.2");
System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
SSLMetrics metrics = new SSLMetrics("", new SimpleMeterRegistry());
MockSSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
SSLEngine client = sslEngineFactory.createEngineForSocket();
SSLEngine svr = sslEngineFactory.createEngineForServerSocket();
clientEngine = AsyncSSLFactory.create("client", client, pool, clientListener, metrics);
svrEngine = AsyncSSLFactory.create("svr", svr, pool, svrListener, metrics);
Assert.assertEquals(ConnectionState.NOT_STARTED, clientEngine.getConnectionState());
Assert.assertEquals(ConnectionState.NOT_STARTED, svrEngine.getConnectionState());
XFuture<Void> cliFuture = clientEngine.beginHandshake();
Assert.assertEquals(ConnectionState.CONNECTING, clientEngine.getConnectionState());
BufferedFuture toSend = clientListener.getSingleHandshake();
assertFutureJustResolved(cliFuture, toSend);
XFuture<Void> svrFuture = svrEngine.feedEncryptedPacket(toSend.engineToSocketData);
Assert.assertEquals(ConnectionState.CONNECTING, svrEngine.getConnectionState());
Assert.assertEquals(ConnectionState.CONNECTING, svrEngine.getConnectionState());
BufferedFuture toSend2 = svrListener.getSingleHandshake();
assertFutureJustResolved(svrFuture, toSend2);
XFuture<Void> clientFuture = clientEngine.feedEncryptedPacket(toSend2.engineToSocketData);
Assert.assertEquals(ConnectionState.CONNECTING, clientEngine.getConnectionState());
buffers = clientListener.getHandshake();
buffers.get(0).future.complete(null);
buffers.get(1).future.complete(null);
assertFutureJustResolved(clientFuture, buffers.get(2));
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class IntegGoogleHttps method createHttpClient.
public static HttpClient createHttpClient() {
BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
HttpParser parser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), pool2);
HttpClient client = HttpClientFactory.createHttpClient("myClient", mgr, parser);
return client;
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class HttpClientFactory method createHttpClient.
public static HttpClient createHttpClient(String id, int numThreads, BackpressureConfig backPressureConfig, MeterRegistry metrics) {
Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
MetricsCreator.monitor(metrics, executor, id);
TwoPools pool = new TwoPools(id + ".bufferpool", metrics);
HttpParser parser = HttpParserFactory.createParser(id, metrics, pool);
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, backPressureConfig, executor);
return createHttpClient(id, mgr, parser);
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestSslCloseClient method createSslSvrParser.
public static SSLParser createSslSvrParser() throws GeneralSecurityException, IOException {
MockSSLEngineFactory sslFactory = new MockSSLEngineFactory();
BufferPool pool = new TwoPools("pSvr", new SimpleMeterRegistry());
SSLEngine svrSsl = sslFactory.createEngineForServerSocket();
SSLMetrics metrics = new SSLMetrics("", new SimpleMeterRegistry());
return AsyncSSLFactory.create("svr", svrSsl, pool, metrics);
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestSslOverLocalhost method createSvrChanMgr.
private ChannelManager createSvrChanMgr(String name) {
ExecutorService executor = Executors.newFixedThreadPool(10, new NamedThreadFactory(name));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
ChannelManager svrMgr = factory.createMultiThreadedChanMgr(name + "Mgr", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), executor);
return svrMgr;
}
Aggregations