Search in sources :

Example 1 with NettyServerRouter

use of org.corfudb.infrastructure.NettyServerRouter in project CorfuDB by CorfuDB.

the class NettyCommTest method runWithBaseServer.

void runWithBaseServer(NettyServerDataConstructor nsdc, NettyClientRouterConstructor ncrc, NettyCommFunction actionFn) throws Exception {
    NettyServerRouter nsr = new NettyServerRouter(new ImmutableMap.Builder<String, Object>().build());
    nsr.addServer(new BaseServer());
    int port = findRandomOpenPort();
    NettyServerData d = nsdc.createNettyServerData(port);
    NettyClientRouter ncr = null;
    try {
        d.bootstrapServer();
        ncr = ncrc.createNettyClientRouter(port);
        ncr.addClient(new BaseClient());
        ncr.start();
        actionFn.runTest(ncr, d);
    } catch (Exception ex) {
        log.error("Exception ", ex);
        throw ex;
    } finally {
        try {
            if (ncr != null) {
                ncr.stop();
            }
        } catch (Exception ex) {
            log.warn("Error shutting down client...", ex);
        }
        d.shutdownServer();
    }
}
Also used : BaseServer(org.corfudb.infrastructure.BaseServer) NettyServerRouter(org.corfudb.infrastructure.NettyServerRouter) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 BaseServer (org.corfudb.infrastructure.BaseServer)1 NettyServerRouter (org.corfudb.infrastructure.NettyServerRouter)1