Search in sources :

Example 1 with AsyncServerManager

use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.

the class IntegTestLocalhostThroughput method testSoTimeoutOnSocket.

public void testSoTimeoutOnSocket() throws InterruptedException {
    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));
    BufferPool pool2 = new BufferCreationPool();
    DataListener listener = new ClientDataListener(pool2, recorder);
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    TCPChannel channel = createClientChannel(pool2, executor2);
    //TCPChannel channel = createNettyChannel();
    recorder.start();
    CompletableFuture<Channel> connect = channel.connect(new InetSocketAddress(8080), listener);
    connect.thenAccept(p -> runWriting(channel));
    synchronized (this) {
        this.wait();
    }
}
Also used : ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) 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) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) Executor(java.util.concurrent.Executor) BufferPool(org.webpieces.data.api.BufferPool) DataListener(org.webpieces.nio.api.handlers.DataListener)

Example 2 with AsyncServerManager

use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.

the class IntegTestClientNotRead method testSoTimeoutOnSocket.

public void testSoTimeoutOnSocket() throws InterruptedException {
    BufferCreationPool pool = new BufferCreationPool();
    AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer("server", pool);
    AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestClientNotReadListener());
    server.start(new InetSocketAddress(8080));
    BufferCreationPool pool2 = new BufferCreationPool();
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createSingleThreadedChanMgr("client", pool2);
    TCPChannel channel = mgr.createTCPChannel("clientChan");
    log.info("client");
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            logBytesTxfrd();
        }
    }, 1000, 5000);
    CompletableFuture<Channel> connect = channel.connect(new InetSocketAddress(8080), new ClientDataListener());
    connect.thenAccept(p -> runWriting(channel));
    Thread.sleep(1000000000);
}
Also used : ChannelManager(org.webpieces.nio.api.ChannelManager) 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) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimerTask(java.util.TimerTask)

Example 3 with AsyncServerManager

use of org.webpieces.asyncserver.api.AsyncServerManager 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 4 with AsyncServerManager

use of org.webpieces.asyncserver.api.AsyncServerManager 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 5 with AsyncServerManager

use of org.webpieces.asyncserver.api.AsyncServerManager in project webpieces by deanhiller.

the class HttpFrontendFactory method createFrontEnd.

/**
	 * 
	 * @param id Use for logging and also file recording names
	 * @param threadPoolSize The size of the threadpool, although all data comes in order as we
	 * use the SessionExecutorImpl found in webpieces
	 * 
	 * @return
	 */
public static HttpFrontendManager createFrontEnd(String id, int threadPoolSize, ScheduledExecutorService timer, BufferPool pool) {
    Executor executor = Executors.newFixedThreadPool(threadPoolSize, new NamedThreadFactory(id));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager chanMgr = factory.createMultiThreadedChanMgr(id, pool, executor);
    AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(chanMgr);
    HttpParser httpParser = HttpParserFactory.createParser(pool);
    HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
    InjectionConfig injConfig = new InjectionConfig(http2Parser, new TimeImpl(), new Http2Config());
    Http2ServerEngineFactory svrEngineFactory = new Http2ServerEngineFactory(injConfig);
    return new FrontEndServerManagerImpl(svrMgr, timer, svrEngineFactory, httpParser);
}
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) HttpParser(org.webpieces.httpparser.api.HttpParser) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) Http2ServerEngineFactory(com.webpieces.http2engine.api.server.Http2ServerEngineFactory) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(com.webpieces.util.time.TimeImpl) FrontEndServerManagerImpl(org.webpieces.frontend2.impl.FrontEndServerManagerImpl)

Aggregations

AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)6 InetSocketAddress (java.net.InetSocketAddress)4 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)4 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)4 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)4 ChannelManager (org.webpieces.nio.api.ChannelManager)4 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)4 Executor (java.util.concurrent.Executor)3 Channel (org.webpieces.nio.api.channels.Channel)3 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)3 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)3 Http2ServerEngineFactory (com.webpieces.http2engine.api.server.Http2ServerEngineFactory)2 BufferPool (org.webpieces.data.api.BufferPool)2 FrontEndServerManagerImpl (org.webpieces.frontend2.impl.FrontEndServerManagerImpl)2 HpackParser (com.webpieces.hpack.api.HpackParser)1 Http2Config (com.webpieces.http2engine.api.client.Http2Config)1 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)1 TimeImpl (com.webpieces.util.time.TimeImpl)1 TimerTask (java.util.TimerTask)1 Test (org.junit.Test)1