Search in sources :

Example 16 with TwoPools

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

the class IntegTestClientToEchoServer method testSoTimeoutOnSocket.

public void testSoTimeoutOnSocket() throws InterruptedException {
    runEchoServer();
    BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
    DataListener listener = new ClientDataListener(pool2, recorder);
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    TCPChannel channel = createClientChannel(pool2, executor2);
    // TCPChannel channel = createNettyChannel();
    recorder.start();
    XFuture<Void> connect = channel.connect(new InetSocketAddress(4444), listener);
    connect.thenAccept(p -> runWriting(channel));
    synchronized (this) {
        this.wait();
    }
}
Also used : BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) ClientDataListener(org.webpieces.nio.api.throughput.ClientDataListener) TwoPools(org.webpieces.data.api.TwoPools) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) InetSocketAddress(java.net.InetSocketAddress) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) DataListener(org.webpieces.nio.api.handlers.DataListener) ClientDataListener(org.webpieces.nio.api.throughput.ClientDataListener)

Example 17 with TwoPools

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

the class TestSvrReading method setup.

@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
    MeterRegistry meters = Metrics.globalRegistry;
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
    DirectExecutor exec = new DirectExecutor();
    BackpressureConfig config = new BackpressureConfig();
    config.setMaxBytes(6);
    config.setStartReadingThreshold(2);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), config, exec);
    AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
    listener = new MockAsyncListener();
    AsyncServer server = svrMgr.createTcpServer(new AsyncConfig(), listener);
    XFuture<Void> future = server.start(new InetSocketAddress(4444));
    Assert.assertFalse(future.isDone());
    mockJdk.setThread(Thread.currentThread());
    mockJdk.fireSelector();
    future.get(2, TimeUnit.SECONDS);
    mockSvrChannel.addNewChannel(mockChannel);
    mockJdk.setThread(Thread.currentThread());
    mockJdk.fireSelector();
    Assert.assertEquals(1, listener.getNumTimesCalledConnectionOpen());
}
Also used : 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) MockAsyncListener(org.webpieces.nio.api.mocks.MockAsyncListener) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) DirectExecutor(org.webpieces.util.threading.DirectExecutor) Before(org.junit.Before)

Example 18 with TwoPools

use of org.webpieces.data.api.TwoPools 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 19 with TwoPools

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

the class TestCancelStream method setup.

@Before
public void setup() {
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    TwoPools pool = new TwoPools("client.bufferpool", metrics);
    HttpParser parser = HttpParserFactory.createParser("testParser", metrics, pool);
    httpClient = HttpClientFactory.createHttpClient("testClient", mockChanMgr, parser);
    mockChannel.setConnectFuture(XFuture.completedFuture(null));
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    httpSocket = httpClient.createHttpSocket(new SocketListener());
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpParser(org.webpieces.httpparser.api.HttpParser) Before(org.junit.Before)

Example 20 with TwoPools

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

the class TestChunking method setup.

@Before
public void setup() {
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    TwoPools pool = new TwoPools("client.bufferpool", metrics);
    HttpParser parser = HttpParserFactory.createParser("testParser", metrics, pool);
    httpClient = HttpClientFactory.createHttpClient("testClient", mockChanMgr, parser);
    mockChannel.setConnectFuture(XFuture.completedFuture(null));
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    httpSocket = httpClient.createHttpSocket(new SocketListener());
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpParser(org.webpieces.httpparser.api.HttpParser) Before(org.junit.Before)

Aggregations

TwoPools (org.webpieces.data.api.TwoPools)43 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)39 Before (org.junit.Before)15 BufferPool (org.webpieces.data.api.BufferPool)15 ChannelManager (org.webpieces.nio.api.ChannelManager)12 InetSocketAddress (java.net.InetSocketAddress)11 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)11 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)10 Executor (java.util.concurrent.Executor)8 SSLEngine (javax.net.ssl.SSLEngine)8 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)8 DirectExecutor (org.webpieces.util.threading.DirectExecutor)8 ByteBuffer (java.nio.ByteBuffer)7 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)7 BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)7 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)6 HttpParser (org.webpieces.httpparser.api.HttpParser)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)5 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)5 ArrayList (java.util.ArrayList)4