Search in sources :

Example 31 with TwoPools

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

the class TestBasicSslClientServer method testBasic.

@Test
public void testBasic() throws InterruptedException, ExecutionException, TimeoutException {
    pool = new TwoPools("pl", new SimpleMeterRegistry());
    MeterRegistry meters = Metrics.globalRegistry;
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(meters);
    ChannelManager mgr = factory.createSingleThreadedChanMgr("sslChanMgr", pool, new BackpressureConfig());
    AsyncServerManager svrFactory = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
    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());
    XFuture<Void> connect = channel.connect(bound, new ClientListener());
    connect.get(10000000, TimeUnit.SECONDS);
    writeData(channel);
    synchronized (pool) {
        while (values.size() < 10) pool.wait();
    }
    for (int i = 0; i < values.size(); i++) {
        Integer expected = i;
        Assert.assertEquals(expected, values.get(i));
    }
}
Also used : 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) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.Test)

Example 32 with TwoPools

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

the class TestAccepting method setup.

@Before
public void setup() {
    MeterRegistry meters = Metrics.globalRegistry;
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), new DirectExecutor());
    svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) DirectExecutor(org.webpieces.util.threading.DirectExecutor) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Before(org.junit.Before)

Example 33 with TwoPools

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

the class TestSslCloseSvr method createServer.

private AsyncServer createServer() {
    MeterRegistry meters = Metrics.globalRegistry;
    SSLEngineFactoryForTestOld sslFactory = new SSLEngineFactoryForTestOld();
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), new DirectExecutor());
    AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
    AsyncServer server1 = svrMgr.createTcpServer(new AsyncConfig(), listener, sslFactory);
    return server1;
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) DirectExecutor(org.webpieces.util.threading.DirectExecutor) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry)

Example 34 with TwoPools

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

the class TestSslCloseSvr method createClientParser.

private SSLParser createClientParser() {
    SSLEngineFactoryForTestOld sslFactory = new SSLEngineFactoryForTestOld();
    BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
    SSLEngine clientSsl = sslFactory.createEngineForSocket();
    SSLMetrics sslMetrics = new SSLMetrics("", new SimpleMeterRegistry());
    SSLParser clientSslParser1 = AsyncSSLFactory.create("svr", clientSsl, pool, sslMetrics);
    return clientSslParser1;
}
Also used : SSLParser(org.webpieces.ssl.api.SSLParser) BufferPool(org.webpieces.data.api.BufferPool) TwoPools(org.webpieces.data.api.TwoPools) SSLEngine(javax.net.ssl.SSLEngine) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SSLMetrics(org.webpieces.ssl.api.SSLMetrics)

Example 35 with TwoPools

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

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