Search in sources :

Example 11 with BufferCreationPool

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();
}
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 12 with BufferCreationPool

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();
}
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 13 with BufferCreationPool

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;
}
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)

Example 14 with BufferCreationPool

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

Example 15 with BufferCreationPool

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);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) Http2Config(com.webpieces.http2engine.api.client.Http2Config) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(com.webpieces.util.time.TimeImpl)

Aggregations

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