use of org.infinispan.server.hotrod.transport.TestHandlersChannelInitializer in project infinispan by infinispan.
the class HotRodTestingUtil method startHotRodServer.
public static HotRodServer startHotRodServer(EmbeddedCacheManager manager, String host, int port, HotRodServerConfigurationBuilder builder) {
log.infof("Start server in port %d", port);
HotRodServer server = new HotRodServer() {
@Override
public ChannelInitializer<Channel> getInitializer() {
if (configuration.idleTimeout() > 0)
return new NettyInitializers(new NettyChannelInitializer<>(this, transport, getEncoder(), getDecoder()), new TimeoutEnabledChannelInitializer<>(this), new TestHandlersChannelInitializer());
else
// Idle timeout logic is disabled with -1 or 0 values
return new NettyInitializers(new NettyChannelInitializer<>(this, transport, getEncoder(), getDecoder()), new TestHandlersChannelInitializer());
}
};
String shortTestName = TestResourceTracker.getCurrentTestShortName();
if (!builder.name().contains(shortTestName)) {
// Only set the name once if HotRodClientTestingUtil.startHotRodServer() retries
builder.name(shortTestName + builder.name());
}
builder.host(host).port(port);
builder.ioThreads(3);
try {
server.start(builder.build(), manager);
return server;
} catch (Throwable t) {
server.stop();
throw t;
}
}
Aggregations