use of org.infinispan.server.core.transport.NettyInitializers in project infinispan by infinispan.
the class SinglePortEndpointRouter method getInitializer.
@Override
public ChannelInitializer<Channel> getInitializer() {
Map<String, ProtocolServer<?>> upgradeServers = new HashMap<>();
RestServer restServer = routingTable.streamRoutes(SinglePortRouteSource.class, RestServerRouteDestination.class).findFirst().map(r -> r.getRouteDestination().getProtocolServer()).orElseThrow(() -> new IllegalStateException("There must be a REST route!"));
routingTable.streamRoutes(SinglePortRouteSource.class, HotRodServerRouteDestination.class).findFirst().ifPresent(r -> upgradeServers.put("HR", r.getRouteDestination().getProtocolServer()));
routingTable.streamRoutes(SinglePortRouteSource.class, RespServerRouteDestination.class).findFirst().ifPresent(r -> upgradeServers.put("RP", r.getRouteDestination().getProtocolServer()));
SinglePortChannelInitializer restChannelInitializer = new SinglePortChannelInitializer(this, transport, restServer, upgradeServers);
return new NettyInitializers(restChannelInitializer);
}
use of org.infinispan.server.core.transport.NettyInitializers in project infinispan by infinispan.
the class RecoveryOp method initializeChannel.
private Channel initializeChannel() {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup);
bootstrap.handler(new NettyInitializers(new ClientChannelInitializer(this, rspTimeoutSeconds, sslEngine, protocolVersion)));
bootstrap.channel(NioSocketChannel.class);
bootstrap.option(ChannelOption.TCP_NODELAY, true);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
// Make a new connection.
ChannelFuture connectFuture = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection is made successfully.
Channel ch = connectFuture.syncUninterruptibly().channel();
assertTrue(connectFuture.isSuccess());
return ch;
}
use of org.infinispan.server.core.transport.NettyInitializers 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