Search in sources :

Example 6 with BufferPool

use of org.webpieces.data.api.BufferPool 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();
}
Also used : BufferPool(org.webpieces.data.api.BufferPool) SSLEngine(javax.net.ssl.SSLEngine) ByteBuffer(java.nio.ByteBuffer) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) Before(org.junit.Before)

Example 7 with BufferPool

use of org.webpieces.data.api.BufferPool 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;
}
Also used : BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) HttpClient(org.webpieces.httpclient.api.HttpClient) HttpParser(org.webpieces.httpparser.api.HttpParser) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Aggregations

BufferCreationPool (org.webpieces.data.api.BufferCreationPool)7 BufferPool (org.webpieces.data.api.BufferPool)7 Executor (java.util.concurrent.Executor)5 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)5 ChannelManager (org.webpieces.nio.api.ChannelManager)4 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)4 InetSocketAddress (java.net.InetSocketAddress)3 SSLEngine (javax.net.ssl.SSLEngine)3 ByteBuffer (java.nio.ByteBuffer)2 Before (org.junit.Before)2 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)2 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)2 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)2 Channel (org.webpieces.nio.api.channels.Channel)2 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)2 DataListener (org.webpieces.nio.api.handlers.DataListener)2 HpackParser (com.webpieces.hpack.api.HpackParser)1 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)1 Http2Client (org.webpieces.http2client.api.Http2Client)1 Http2Socket (org.webpieces.http2client.api.Http2Socket)1