Search in sources :

Example 6 with BackpressureConfig

use of org.webpieces.nio.api.BackpressureConfig in project webpieces by deanhiller.

the class IntegTestClientToEchoServer method createClientChannel.

private TCPChannel createClientChannel(BufferPool pool2, Executor executor) {
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor);
    TCPChannel channel = mgr.createTCPChannel("clientChan");
    return channel;
}
Also used : BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) ChannelManager(org.webpieces.nio.api.ChannelManager) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 7 with BackpressureConfig

use of org.webpieces.nio.api.BackpressureConfig in project webpieces by deanhiller.

the class IntegTestLocalhostThroughput method testThroughput.

public void testThroughput() throws InterruptedException, ExecutionException, TimeoutException {
    Executor executor = Executors.newFixedThreadPool(10, new NamedThreadFactory("serverThread"));
    BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
    BackpressureConfig config = new BackpressureConfig();
    config.setMaxBytes(16_384 * 10);
    config.setStartReadingThreshold(512);
    ChannelManager mgr = createChanMgr("server", executor, pool, config);
    AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr, Metrics.globalRegistry);
    AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new AsyncServerDataListener(recorder, pool));
    server.start(new InetSocketAddress(8080));
    BufferPool pool2 = new TwoPools("p2", new SimpleMeterRegistry());
    DataListener listener = new ClientDataListener(pool2, recorder);
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    TCPChannel channel = createClientChannel(pool2, executor2, config);
    recorder.setClientChannel(channel);
    recorder.start();
    XFuture<Void> connect = channel.connect(new InetSocketAddress(8080), listener);
    connect.get(2, TimeUnit.SECONDS);
    synchronized (this) {
        this.wait();
    }
}
Also used : BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) TwoPools(org.webpieces.data.api.TwoPools) InetSocketAddress(java.net.InetSocketAddress) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) Executor(java.util.concurrent.Executor) BufferPool(org.webpieces.data.api.BufferPool) DataListener(org.webpieces.nio.api.handlers.DataListener)

Example 8 with BackpressureConfig

use of org.webpieces.nio.api.BackpressureConfig in project webpieces by deanhiller.

the class IntegSingleRequest method createHttpClient.

public static Http2Socket createHttpClient(String id, boolean isHttp, InetSocketAddress addr) {
    BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
    HpackParser hpackParser = HpackParserFactory.createParser(pool2, false);
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
    InjectionConfig injConfig = new InjectionConfig(hpackParser);
    String host = addr.getHostName();
    int port = addr.getPort();
    ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
    SSLEngine engine = ssl.createSslEngine(host, port);
    Http2Client client = Http2ClientFactory.createHttpClient(id, mgr, injConfig);
    Http2Socket socket;
    if (isHttp) {
        socket = client.createHttpSocket(new SocketListener());
    } else {
        socket = client.createHttpsSocket(engine, new SocketListener());
    }
    return socket;
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) ChannelManager(org.webpieces.nio.api.ChannelManager) TwoPools(org.webpieces.data.api.TwoPools) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) SSLEngine(javax.net.ssl.SSLEngine) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) SocketListener(org.webpieces.http2client.SocketListener) Http2Socket(org.webpieces.http2client.api.Http2Socket) Http2Client(org.webpieces.http2client.api.Http2Client)

Example 9 with BackpressureConfig

use of org.webpieces.nio.api.BackpressureConfig 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 TwoPools("pl", new SimpleMeterRegistry());
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("server", pool, new BackpressureConfig(), executor);
    AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr, Metrics.globalRegistry);
    AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), null);
    server.start(new InetSocketAddress(8080));
    client.start(8080);
    synchronized (this) {
        this.wait();
    }
}
Also used : BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) TwoPools(org.webpieces.data.api.TwoPools) InetSocketAddress(java.net.InetSocketAddress) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) Executor(java.util.concurrent.Executor) BufferPool(org.webpieces.data.api.BufferPool)

Example 10 with BackpressureConfig

use of org.webpieces.nio.api.BackpressureConfig in project webpieces by deanhiller.

the class IntegGoogleHttps method createHttpClient.

public static HttpClient createHttpClient() {
    BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
    HttpParser parser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), pool2);
    HttpClient client = HttpClientFactory.createHttpClient("myClient", mgr, parser);
    return client;
}
Also used : BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) TwoPools(org.webpieces.data.api.TwoPools) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpClient(org.webpieces.httpclient11.api.HttpClient) HttpParser(org.webpieces.httpparser.api.HttpParser) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Aggregations

BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)10 ChannelManager (org.webpieces.nio.api.ChannelManager)8 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)7 TwoPools (org.webpieces.data.api.TwoPools)7 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)7 BufferPool (org.webpieces.data.api.BufferPool)6 Executor (java.util.concurrent.Executor)5 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)5 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)4 InetSocketAddress (java.net.InetSocketAddress)3 SSLEngine (javax.net.ssl.SSLEngine)3 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)3 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)3 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)3 Http2Client (org.webpieces.http2client.api.Http2Client)3 HpackParser (com.webpieces.hpack.api.HpackParser)2 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)2 Http2Socket (org.webpieces.http2client.api.Http2Socket)2 Provides (com.google.inject.Provides)1 TimerTask (java.util.TimerTask)1