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();
}
}
Aggregations