@Override protected void initChannel(SocketChannel ch) throws Exception { BasicServer.this.initChannel(ch); }
@Override protected ChannelFutureListener newCloseListener(SocketChannel channel, final UserClientConnectionImpl connection) { final ChannelFutureListener delegate = super.newCloseListener(channel, connection); return new ChannelFutureListener(){ @Override public void operationComplete(ChannelFuture future) throws Exception { try { delegate.operationComplete(future); } finally { CONNECTION_LOGGER.info("[{}] Connection Closed", connection.uuid); } }}; }
/** * Initialize the {@code SocketChannel}. * * This method initializes a new channel created by the {@code ServerBootstrap} * * The default implementation create a remote connection, configures a default pipeline * which handles coding/decoding messages, handshaking, timeout and error handling based * on {@code RpcConfig} instance provided at construction time. * * On each call to this method, every handler added must be a new instance. As of now, the * handlers cannot be shared across connections. * * Subclasses can override it to add extra handlers if needed. * * @param ch the socket channel */ protected void initChannel(final SocketChannel ch) throws SSLException { C connection = initRemoteConnection(ch); connection.setChannelCloseHandler(newCloseListener(ch, connection)); final ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(PROTOCOL_ENCODER, new RpcEncoder("s-" + rpcConfig.getName())); pipeline.addLast(MESSAGE_DECODER, newDecoder(connection.getAllocator())); pipeline.addLast(HANDSHAKE_HANDLER, newHandshakeHandler(connection)); if (rpcConfig.hasTimeout()) { pipeline.addLast(TIMEOUT_HANDLER, new LoggingReadTimeoutHandler(connection, rpcConfig.getTimeout())); } pipeline.addLast(MESSAGE_HANDLER, new InboundHandler(connection)); pipeline.addLast(EXCEPTION_HANDLER, new RpcExceptionHandler<>(connection)); }
@Override public int bind(int initialPort, boolean allowPortHunting) { port = super.bind(initialPort, allowPortHunting); localIdentity = FabricIdentity.newBuilder().setAddress(address).setPort(port).build(); return port; }
@Override protected void initChannel(final SocketChannel ch) throws SSLException { // configure the main pipeline super.initChannel(ch); ch.pipeline().addLast(RPC_COMPATIBILITY_ENCODER, new RpcCompatibilityEncoder()); }