Search in sources :

Example 1 with SniRouteSource

use of org.infinispan.server.router.routes.SniRouteSource in project infinispan by infinispan.

the class SniRouteHandler method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    super.decode(ctx, in, out);
    if (isHandShaked()) {
        // At this point Netty has replaced SNIHandler (formally this) with SSLHandler in the pipeline.
        // Now we need to add other handlers at the tail of the queue
        RouterLogger.SERVER.debugf("Handshaked with hostname %s", hostname());
        Optional<Route<SniRouteSource, HotRodServerRouteDestination>> route = routingTable.streamRoutes(SniRouteSource.class, HotRodServerRouteDestination.class).filter(r -> r.getRouteSource().getSniHostName().equals(this.hostname())).findAny();
        HotRodServerRouteDestination routeDestination = route.orElseThrow(() -> RouterLogger.SERVER.noRouteFound()).getRouteDestination();
        ChannelInitializer<Channel> channelInitializer = routeDestination.getProtocolServer().getInitializer();
        ctx.pipeline().addLast(channelInitializer);
        RouterLogger.SERVER.debug("Replaced with route destination's handlers");
    }
}
Also used : RouterLogger(org.infinispan.server.router.logging.RouterLogger) SniHandler(io.netty.handler.ssl.SniHandler) HotRodServerRouteDestination(org.infinispan.server.router.routes.hotrod.HotRodServerRouteDestination) ChannelInitializer(io.netty.channel.ChannelInitializer) SslContext(io.netty.handler.ssl.SslContext) SniRouteSource(org.infinispan.server.router.routes.SniRouteSource) RoutingTable(org.infinispan.server.router.RoutingTable) Channel(io.netty.channel.Channel) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) List(java.util.List) ByteBuf(io.netty.buffer.ByteBuf) DomainNameMapping(io.netty.util.DomainNameMapping) Optional(java.util.Optional) Route(org.infinispan.server.router.routes.Route) Channel(io.netty.channel.Channel) HotRodServerRouteDestination(org.infinispan.server.router.routes.hotrod.HotRodServerRouteDestination) Route(org.infinispan.server.router.routes.Route)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 Channel (io.netty.channel.Channel)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 SniHandler (io.netty.handler.ssl.SniHandler)1 SslContext (io.netty.handler.ssl.SslContext)1 DomainNameMapping (io.netty.util.DomainNameMapping)1 List (java.util.List)1 Optional (java.util.Optional)1 RoutingTable (org.infinispan.server.router.RoutingTable)1 RouterLogger (org.infinispan.server.router.logging.RouterLogger)1 Route (org.infinispan.server.router.routes.Route)1 SniRouteSource (org.infinispan.server.router.routes.SniRouteSource)1 HotRodServerRouteDestination (org.infinispan.server.router.routes.hotrod.HotRodServerRouteDestination)1