void registerChannel(Channel channel) { allChannels.add(channel); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { allChannels.add(e.getChannel()); super.channelOpen(ctx, e); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { NettyTCPClient.ALL_CHANNELS.add(e.getChannel()); super.channelConnected(ctx, e); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { AbstractNettyServer.ALL_CHANNELS.add(e.getChannel()); LOG.debug("Added Channel with id: {} as the {}th open channel", e .getChannel().getId(), CHANNEL_COUNTER.incrementAndGet()); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { connectionStats.reportChannelConnect(); if(allchannels != null) { allchannels.add(e.getChannel()); } ctx.sendUpstream(e); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (LOG.isTraceEnabled()) { LOG.trace("Channel connected " + e); } allChannels.add(ctx.getChannel()); NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(), zkServer, NettyServerCnxnFactory.this); ctx.setAttachment(cnxn); addCnxn(cnxn); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception { if ((maxShuffleConnections > 0) && (accepted.size() >= maxShuffleConnections)) { LOG.info(String.format("Current number of shuffle connections (%d) is " + "greater than or equal to the max allowed shuffle connections (%d)", accepted.size(), maxShuffleConnections)); evt.getChannel().close(); return; } accepted.add(evt.getChannel()); super.channelOpen(ctx, evt); }
public void start() throws Exception { ServerBootstrap bootstrap = new ServerBootstrap(selector); // Timer is shared across entire factory and must be released separately timer = new HashedWheelTimer(); try { pipelineFact = new HttpPipelineFactory(conf, timer); } catch (Exception ex) { throw new RuntimeException(ex); } bootstrap.setPipelineFactory(pipelineFact); bootstrap.setOption("backlog", NetUtil.SOMAXCONN); port = conf.getInt(SHUFFLE_PORT_CONFIG_KEY, DEFAULT_SHUFFLE_PORT); Channel ch = bootstrap.bind(new InetSocketAddress(port)); accepted.add(ch); port = ((InetSocketAddress)ch.getLocalAddress()).getPort(); conf.set(SHUFFLE_PORT_CONFIG_KEY, Integer.toString(port)); pipelineFact.SHUFFLE.setPort(port); if (dirWatcher != null) { dirWatcher.start(); } LOG.info("LlapShuffleHandler" + " listening on port " + port + " (SOMAXCONN: " + bootstrap.getOption("backlog") + ")"); }
allChannels.add(serverChannel);
bootstrap.setOption("child.keepAlive", true); Channel listenChannel = bootstrap.bind(new InetSocketAddress(port)); allChannels.add(listenChannel); logger.info("Started server on port {}", port); if (config.getServerMOTD() != null) {
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { // add new socket channel in channel container, used to manage sockets. if (childGroups != null) { childGroups.add(ctx.getChannel()); } byte[] body = Packet.newBuilder() .setType(CanalPacket.PacketType.HANDSHAKE) .setBody(Handshake.newBuilder().build().toByteString()) .build() .toByteArray(); NettyUtils.write(ctx.getChannel(), body, null); logger.info("send handshake initialization packet to : {}", ctx.getChannel()); } }
@Override protected void startInner() { // Configure the server. this.workerPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(config.getNumRestServiceNettyWorkerThreads()); this.bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newFixedThreadPool(config.getNumRestServiceNettyBossThreads()), workerPool)); this.bootstrap.setOption("backlog", config.getRestServiceNettyServerBacklog()); this.bootstrap.setOption("child.tcpNoDelay", true); this.bootstrap.setOption("child.keepAlive", true); this.bootstrap.setOption("child.reuseAddress", true); this.bootstrap.setPipelineFactory(new RestPipelineFactory(storeRepository, config, localZoneId, storeDefinitions, allChannels)); // Bind and start to accept incoming connections. this.nettyServerChannel = this.bootstrap.bind(new InetSocketAddress(this.port)); allChannels.add(nettyServerChannel); logger.info("REST service started on port " + this.port); // Register MBeans for Netty worker pool stats if(config.isJmxEnabled()) { JmxUtils.registerMbean(this, JmxUtils.createObjectName(JmxUtils.getPackageName(this.getClass()), JmxUtils.getClassName(this.getClass()))); } }
return new JoinStatusImpl("Failed to connect to server - " + connectCheck.getCause().getMessage()); } else { allChannels.add(connectCheck.getChannel()); ClientConnectionHandler connectionHandler = connectCheck.getChannel().getPipeline().get(ClientConnectionHandler.class); if (connectionHandler == null) {
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { // This lock is to deal with the race condition when closeAllConnections() is called, // but the server is still accepting connections. Any new channels will be automatically closed. closingLock.readLock().lock(); try { if (closed) { e.getChannel().close(); } else { openConnections.add(e.getChannel()); } } finally { closingLock.readLock().unlock(); } }
public void registerOpenChannel(Channel channel, Object partitionKey) { openChannels.add(channel); if (maxConnectionsPerHostEnabled) { channelId2PartitionKey.put(channel.getId(), partitionKey); } }
allChannels.add(channel); runtimePort = ((InetSocketAddress) channel.getLocalAddress()).getPort();
NettyJaxrsServer.allChannels.add(e.getChannel());
@Override public void channelOpen( ChannelHandlerContext ctx, ChannelStateEvent e ) { channelGroup.add( e.getChannel() ); }
@Override public void operationComplete(ChannelFuture future) throws Exception { Channel channel = future.getChannel(); if (channel != null && channel.isOpen()) { allChannels.add(channel); } } });
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { allChannels.add(e.getChannel()); super.channelOpen(ctx, e); }