Search in sources :

Example 6 with DirectExecutor

use of org.webpieces.util.threading.DirectExecutor 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 7 with DirectExecutor

use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.

the class TestReading method setup.

@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
    DirectExecutor exec = new DirectExecutor();
    BackpressureConfig config = new BackpressureConfig();
    config.setMaxBytes(6);
    config.setStartReadingThreshold(2);
    mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), config, exec);
    listener = new MockDataListener();
    channel = mgr.createTCPChannel("myid");
    mockChannel.addConnectReturnValue(true);
    mockJdk.setThread(Thread.currentThread());
    XFuture<Void> future = channel.connect(new InetSocketAddress(4444), listener);
    future.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(mockChannel.isRegisteredForReads());
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) InetSocketAddress(java.net.InetSocketAddress) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MockDataListener(org.webpieces.nio.api.mocks.MockDataListener) DirectExecutor(org.webpieces.util.threading.DirectExecutor) Before(org.junit.Before)

Example 8 with DirectExecutor

use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.

the class TestWriting method setup.

@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
    DirectExecutor exec = new DirectExecutor();
    mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), exec);
    MockDataListener listener = new MockDataListener();
    channel = mgr.createTCPChannel("myid");
    mockChannel.addConnectReturnValue(true);
    mockJdk.setThread(Thread.currentThread());
    XFuture<Void> future = channel.connect(new InetSocketAddress(4444), listener);
    future.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(mockChannel.isRegisteredForReads());
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) InetSocketAddress(java.net.InetSocketAddress) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MockDataListener(org.webpieces.nio.api.mocks.MockDataListener) DirectExecutor(org.webpieces.util.threading.DirectExecutor) Before(org.junit.Before)

Aggregations

SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)8 TwoPools (org.webpieces.data.api.TwoPools)8 DirectExecutor (org.webpieces.util.threading.DirectExecutor)8 Before (org.junit.Before)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)4 InetSocketAddress (java.net.InetSocketAddress)4 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)3 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)3 SSLEngine (javax.net.ssl.SSLEngine)2 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)2 BufferPool (org.webpieces.data.api.BufferPool)2 MockDataListener (org.webpieces.nio.api.mocks.MockDataListener)2 BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)1 ChannelManager (org.webpieces.nio.api.ChannelManager)1 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)1 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)1 MockAsyncListener (org.webpieces.nio.api.mocks.MockAsyncListener)1 ConnectionOpen (org.webpieces.nio.api.mocks.MockAsyncListener.ConnectionOpen)1 SSLMetrics (org.webpieces.ssl.api.SSLMetrics)1 SslAction (org.webpieces.ssl.api.dto.SslAction)1