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