@Override public void publish(ClusterMetrics cs) { channel.writeAndFlush(cs).syncUninterruptibly(); }
public void stop() throws IOException { serverChannel.close().syncUninterruptibly(); serverChannel = null; channelGroup.close().syncUninterruptibly(); channelGroup = null; conn.close(); conn = null; }
public void start() throws InterruptedException, ExecutionException { NettyRpcClientConfigHelper.setEventLoopConfig(conf, workerGroup, NioSocketChannel.class); conn = ConnectionFactory.createAsyncConnection(conf).get(); channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); serverChannel = new ServerBootstrap().group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class).childOption(ChannelOption.TCP_NODELAY, true) .childHandler(new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addFirst(new HttpServerCodec(), new HttpObjectAggregator(4 * 1024 * 1024), new RequestHandler(conn, channelGroup)); } }).bind(port).syncUninterruptibly().channel(); }
public void stop() throws IOException { serverChannel.close().syncUninterruptibly(); serverChannel = null; channelGroup.close().syncUninterruptibly(); channelGroup = null; conn.close(); conn = null; }
public void start() throws InterruptedException, ExecutionException { NettyRpcClientConfigHelper.setEventLoopConfig(conf, workerGroup, NioSocketChannel.class); conn = ConnectionFactory.createAsyncConnection(conf).get(); channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); serverChannel = new ServerBootstrap().group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class).childOption(ChannelOption.TCP_NODELAY, true) .childHandler(new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addFirst(new HttpServerCodec(), new HttpObjectAggregator(4 * 1024 * 1024), new RequestHandler(conn, channelGroup)); } }).bind(port).syncUninterruptibly().channel(); }