use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.
the class TestSSLEngine2 method setup.
@Before
public void setup() throws GeneralSecurityException, IOException {
MockSSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
BufferPool pool = new BufferCreationPool(false, 17000, 1000);
SSLEngine client = sslEngineFactory.createEngineForSocket();
SSLEngine svr = sslEngineFactory.createEngineForServerSocket();
clientEngine = AsyncSSLFactory.create("client", client, pool, clientListener);
svrEngine = AsyncSSLFactory.create("svr", svr, pool, svrListener);
Assert.assertEquals(ConnectionState.NOT_STARTED, clientEngine.getConnectionState());
Assert.assertEquals(ConnectionState.NOT_STARTED, svrEngine.getConnectionState());
clientEngine.beginHandshake();
Assert.assertEquals(ConnectionState.CONNECTING, clientEngine.getConnectionState());
ByteBuffer buffer = clientListener.getToSendToSocket().get(0);
svrEngine.feedEncryptedPacket(buffer);
Assert.assertEquals(ConnectionState.CONNECTING, svrEngine.getConnectionState());
Runnable r = svrListener.getRunnable();
r.run();
Assert.assertEquals(ConnectionState.CONNECTING, svrEngine.getConnectionState());
ByteBuffer buf = svrListener.getToSendToSocket().get(0);
clientEngine.feedEncryptedPacket(buf);
Assert.assertEquals(ConnectionState.CONNECTING, clientEngine.getConnectionState());
clientListener.getRunnable().run();
}
use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.
the class TestSSLEngineClose method setup.
@Before
public void setup() throws GeneralSecurityException, IOException {
MockSSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
BufferPool pool = new BufferCreationPool(false, 17000, 1000);
SSLEngine client = sslEngineFactory.createEngineForSocket();
SSLEngine svr = sslEngineFactory.createEngineForServerSocket();
clientEngine = AsyncSSLFactory.create("client", client, pool, clientListener);
svrEngine = AsyncSSLFactory.create("svr", svr, pool, svrListener);
clientEngine.beginHandshake();
ByteBuffer buffer = clientListener.getToSendToSocket().get(0);
svrEngine.feedEncryptedPacket(buffer);
svrListener.getRunnable().run();
ByteBuffer buf = svrListener.getToSendToSocket().get(0);
clientEngine.feedEncryptedPacket(buf);
clientListener.getRunnable().run();
List<ByteBuffer> buffers = clientListener.getToSendToSocket();
svrEngine.feedEncryptedPacket(buffers.get(0));
svrListener.getRunnable().run();
svrEngine.feedEncryptedPacket(buffers.get(1));
svrEngine.feedEncryptedPacket(buffers.get(2));
Assert.assertTrue(svrListener.connected);
List<ByteBuffer> toClientBuffers = svrListener.getToSendToSocket();
clientEngine.feedEncryptedPacket(toClientBuffers.get(0));
clientEngine.feedEncryptedPacket(toClientBuffers.get(1));
Assert.assertTrue(clientListener.connected);
transferBigData();
}
use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.
the class IntegGoogleHttps method createHttpClient.
public static HttpClient createHttpClient() {
BufferPool pool2 = new BufferCreationPool();
Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, executor2);
HttpParser parser = HttpParserFactory.createParser(pool2);
HttpClient client = HttpClientFactory.createHttpClient(mgr, parser);
return client;
}
use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.
the class HttpClientFactory method createHttpClient.
public static HttpClient createHttpClient(int numThreads) {
Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
BufferCreationPool pool = new BufferCreationPool();
HttpParser parser = HttpParserFactory.createParser(pool);
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, executor);
return createHttpClient(mgr, parser);
}
use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.
the class Http2ClientFactory method createHttpClient.
public static Http2Client createHttpClient(int numThreads) {
Http2Config config = new Http2Config();
Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
BufferCreationPool pool = new BufferCreationPool();
HpackParser hpackParser = HpackParserFactory.createParser(pool, false);
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, executor);
InjectionConfig injConfig = new InjectionConfig(hpackParser, new TimeImpl(), config);
return createHttpClient(mgr, injConfig);
}
Aggregations