Search in sources :

Example 1 with TestHandlersChannelInitializer

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;
    }
}
Also used : TestHandlersChannelInitializer(org.infinispan.server.hotrod.transport.TestHandlersChannelInitializer) NettyChannelInitializer(org.infinispan.server.core.transport.NettyChannelInitializer) HotRodServer(org.infinispan.server.hotrod.HotRodServer) Channel(io.netty.channel.Channel) NettyInitializers(org.infinispan.server.core.transport.NettyInitializers) TimeoutEnabledChannelInitializer(org.infinispan.server.hotrod.transport.TimeoutEnabledChannelInitializer)

Aggregations

Channel (io.netty.channel.Channel)1 NettyChannelInitializer (org.infinispan.server.core.transport.NettyChannelInitializer)1 NettyInitializers (org.infinispan.server.core.transport.NettyInitializers)1 HotRodServer (org.infinispan.server.hotrod.HotRodServer)1 TestHandlersChannelInitializer (org.infinispan.server.hotrod.transport.TestHandlersChannelInitializer)1 TimeoutEnabledChannelInitializer (org.infinispan.server.hotrod.transport.TimeoutEnabledChannelInitializer)1