Search in sources :

Example 6 with ChannelService

use of org.webpieces.nio.api.deprecated.ChannelService in project webpieces by deanhiller.

the class EventClient method start.

public void start() throws IOException, InterruptedException {
    ChannelService mgr = ChannelServiceFactory.createDefaultChannelMgr("EventServer");
    mgr.start();
    SSLEngineFactory sslFactory = new MockSSLEngineFactory();
    Settings h = new Settings(sslFactory, null);
    TCPChannel channel = mgr.createTCPChannel("SvrChan", h);
    InetAddress addr = InetAddress.getByName("192.168.1.102");
    InetSocketAddress sockAddr = new InetSocketAddress(addr, 801);
    log.info("Connecting to server=" + sockAddr);
    channel.oldConnect(sockAddr, this);
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) InetSocketAddress(java.net.InetSocketAddress) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) InetAddress(java.net.InetAddress) Settings(org.webpieces.nio.api.deprecated.Settings) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 7 with ChannelService

use of org.webpieces.nio.api.deprecated.ChannelService in project webpieces by deanhiller.

the class EventServer method start.

public void start() throws IOException, InterruptedException {
    log.info("Attempting to start server");
    ChannelService mgr = ChannelServiceFactory.createDefaultChannelMgr("EventServer");
    mgr.start();
    SSLEngineFactory sslFactory = new MockSSLEngineFactory();
    Settings h = new Settings(sslFactory, null);
    TCPServerChannel svrChannel = mgr.createTCPServerChannel("SvrChan", h);
    InetAddress addr = InetAddress.getByName("192.168.1.101");
    InetSocketAddress sockAddr = new InetSocketAddress(addr, 801);
    log.info("binding");
    svrChannel.bind(sockAddr);
    log.info("bound to=" + svrChannel.getLocalAddress());
    svrChannel.registerServerSocketChannel(this);
    log.info(svrChannel + "Server started");
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) InetSocketAddress(java.net.InetSocketAddress) TCPServerChannel(org.webpieces.nio.api.channels.TCPServerChannel) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) InetAddress(java.net.InetAddress) Settings(org.webpieces.nio.api.deprecated.Settings) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 8 with ChannelService

use of org.webpieces.nio.api.deprecated.ChannelService in project webpieces by deanhiller.

the class PerfTestZSecure method getServerChanMgr.

@Override
protected ChannelService getServerChanMgr() {
    Map<String, Object> p = new HashMap<String, Object>();
    p.put(ChannelManagerOld.KEY_ID, "echoServer");
    p.put(ChannelManagerOld.KEY_BUFFER_FACTORY, getBufFactory());
    p.put(ChannelManagerOld.KEY_EXECUTORSVC_FACTORY, serverExecFactory);
    ChannelService svcChanMgr = secureFactory.createChannelManager(p);
    return svcChanMgr;
}
Also used : HashMap(java.util.HashMap) ChannelService(org.webpieces.nio.api.deprecated.ChannelService)

Example 9 with ChannelService

use of org.webpieces.nio.api.deprecated.ChannelService in project webpieces by deanhiller.

the class PerfTestZSecure method getClientChanMgr.

@Override
protected ChannelService getClientChanMgr() {
    Map<String, Object> p = new HashMap<String, Object>();
    p.put(ChannelManagerOld.KEY_ID, "client");
    p.put(ChannelManagerOld.KEY_BUFFER_FACTORY, getBufFactory());
    p.put(ChannelManagerOld.KEY_EXECUTORSVC_FACTORY, clientExecFactory);
    ChannelService chanMgr = secureFactory.createChannelManager(p);
    return chanMgr;
}
Also used : HashMap(java.util.HashMap) ChannelService(org.webpieces.nio.api.deprecated.ChannelService)

Example 10 with ChannelService

use of org.webpieces.nio.api.deprecated.ChannelService in project webpieces by deanhiller.

the class ZPerformanceSuper method setUp.

protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    LoggerFactory.getLogger("").setLevel(Level.INFO);
    //and started back up cleanly.....
    if (chanMgr == null) {
        chanMgr = getClientChanMgr();
    }
    if (echoServer == null) {
        ChannelService svrChanMgr = getServerChanMgr();
        echoServer = new EchoServer(svrChanMgr, getServerFactoryHolder());
    }
    chanMgr.start();
    svrAddr = echoServer.start();
    //this is to test EchoServer on a different machine...
    //		InetAddress tmp = InetAddress.getByName("192.168.1.102");
    //		svrAddr = new InetSocketAddress(tmp, 501);
    log.trace("server port =" + svrAddr);
    //loopBack = InetAddress.getByName("127.0.0.1");	
    //loopBackAnyPort = new InetSocketAddress(loopBack, 0);
    mockHandler = MockObjectFactory.createMock(DataListener.class);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    mockConnect = MockObjectFactory.createMock(ConnectionCallback.class);
    mockConnectOp = MockObjectFactory.createMock(OperationCallback.class);
}
Also used : OperationCallback(org.webpieces.nio.api.handlers.OperationCallback) ChannelService(org.webpieces.nio.api.deprecated.ChannelService) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionCallback(org.webpieces.nio.api.deprecated.ConnectionCallback) EchoServer(org.webpieces.nio.test.EchoServer)

Aggregations

ChannelService (org.webpieces.nio.api.deprecated.ChannelService)16 InetSocketAddress (java.net.InetSocketAddress)7 HashMap (java.util.HashMap)7 CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)6 MockNIOServer (org.webpieces.nio.api.testutil.MockNIOServer)6 DataListener (org.webpieces.nio.api.handlers.DataListener)5 ConnectionCallback (org.webpieces.nio.api.deprecated.ConnectionCallback)4 Settings (org.webpieces.nio.api.deprecated.Settings)4 SSLEngineFactory (org.webpieces.nio.api.libs.SSLEngineFactory)3 MockSSLEngineFactory (org.webpieces.nio.api.testutil.MockSSLEngineFactory)3 MockObject (biz.xsoftware.mock.MockObject)2 InetAddress (java.net.InetAddress)2 ChannelServiceFactory (org.webpieces.nio.api.deprecated.ChannelServiceFactory)2 IOException (java.io.IOException)1 SSLEngine (javax.net.ssl.SSLEngine)1 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)1 TCPServerChannel (org.webpieces.nio.api.channels.TCPServerChannel)1 OperationCallback (org.webpieces.nio.api.handlers.OperationCallback)1 AsyncSSLEngine (org.webpieces.nio.api.libs.AsyncSSLEngine)1 FactoryCreator (org.webpieces.nio.api.libs.FactoryCreator)1