Search in sources :

Example 6 with BufferCreationPool

use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.

the class TestBasicSsl method createSvrChanMgr.

private ChannelManager createSvrChanMgr(String name) {
    ExecutorService executor = Executors.newFixedThreadPool(10, new NamedThreadFactory(name));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager svrMgr = factory.createMultiThreadedChanMgr(name + "Mgr", new BufferCreationPool(), executor);
    return svrMgr;
}
Also used : NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) BufferCreationPool(org.webpieces.data.api.BufferCreationPool)

Example 7 with BufferCreationPool

use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.

the class ServerFactory method createTestServer.

static int createTestServer(boolean alwaysHttp2, Long maxConcurrentStreams) {
    BufferCreationPool pool = new BufferCreationPool();
    ScheduledExecutorService timer = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
    HttpFrontendManager frontEndMgr = HttpFrontendFactory.createFrontEnd("frontEnd", 10, timer, pool);
    FrontendConfig config = new FrontendConfig("id2", new InetSocketAddress(0));
    HttpServer server = frontEndMgr.createHttpServer(config, new OurListener());
    server.start();
    return server.getUnderlyingChannel().getLocalAddress().getPort();
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) InetSocketAddress(java.net.InetSocketAddress) HttpServer(org.webpieces.frontend2.api.HttpServer) BufferCreationPool(org.webpieces.data.api.BufferCreationPool)

Example 8 with BufferCreationPool

use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.

the class TestBasicSslClientServer method testBasic.

@Test
public void testBasic() throws InterruptedException {
    pool = new BufferCreationPool();
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createSingleThreadedChanMgr("sslChanMgr", pool);
    AsyncServerManager svrFactory = AsyncServerMgrFactory.createAsyncServer(mgr);
    SSLEngineFactoryForTest f = new SSLEngineFactoryForTest();
    InetSocketAddress addr = new InetSocketAddress("localhost", 0);
    AsyncServer svr = svrFactory.createTcpServer(new AsyncConfig("sslTcpSvr"), new SvrDataListener(), f);
    svr.start(addr);
    InetSocketAddress bound = svr.getUnderlyingChannel().getLocalAddress();
    System.out.println("port=" + bound.getPort());
    TCPChannel channel = mgr.createTCPChannel("client", f.createEngineForSocket());
    CompletableFuture<Channel> connect = channel.connect(bound, new ClientListener());
    connect.thenAccept(c -> writeData(c));
    synchronized (pool) {
        while (values.size() < 10) pool.wait();
    }
    for (int i = 0; i < values.size(); i++) {
        Assert.assertEquals(new Integer(i), values.get(i));
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) Channel(org.webpieces.nio.api.channels.Channel) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) Test(org.junit.Test)

Example 9 with BufferCreationPool

use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.

the class IntegTestEchoClientToOurServer method testSoTimeoutOnSocket.

public void testSoTimeoutOnSocket() throws InterruptedException {
    EchoClient client = new EchoClient();
    Executor executor = Executors.newFixedThreadPool(10, new NamedThreadFactory("serverThread"));
    BufferPool pool = new BufferCreationPool();
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createMultiThreadedChanMgr("server", pool, executor);
    AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr);
    AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestLocalhostServerListener());
    server.start(new InetSocketAddress(8080));
    client.start(8080);
    synchronized (this) {
        this.wait();
    }
}
Also used : Executor(java.util.concurrent.Executor) BufferPool(org.webpieces.data.api.BufferPool) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) InetSocketAddress(java.net.InetSocketAddress) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 10 with BufferCreationPool

use of org.webpieces.data.api.BufferCreationPool in project webpieces by deanhiller.

the class HttpFrontendFactory method createFrontEnd.

public static HttpFrontendManager createFrontEnd(ChannelManager chanMgr, ScheduledExecutorService timer, InjectionConfig injConfig) {
    BufferCreationPool pool = new BufferCreationPool();
    HttpParser httpParser = HttpParserFactory.createParser(pool);
    return createFrontEnd(chanMgr, timer, injConfig, httpParser);
}
Also used : HttpParser(org.webpieces.httpparser.api.HttpParser) BufferCreationPool(org.webpieces.data.api.BufferCreationPool)

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