/** * * @return The number of clients currently connected to this server. */ public int getNumActiveConnections() { //allChannels also contains the server channel, so exclude that from the //count. return allChannels.size() - 1; }
@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); }
@Override public void closeAll() { if (LOG.isDebugEnabled()) { LOG.debug("closeAll()"); } NettyServerCnxn[] allCnxns = null; synchronized (cnxns) { allCnxns = cnxns.toArray(new NettyServerCnxn[cnxns.size()]); } // got to clear all the connections that we have in the selector for (NettyServerCnxn cnxn : allCnxns) { try { cnxn.close(); } catch (Exception e) { LOG.warn("Ignoring exception closing cnxn sessionid 0x" + Long.toHexString(cnxn.getSessionId()), e); } } if (LOG.isDebugEnabled()) { LOG.debug("allChannels size:" + allChannels.size() + " cnxns size:" + allCnxns.length); } }
/** * * @return The number of clients currently connected to this server. */ public int getNumActiveConnections() { //allChannels also contains the server channel, so exclude that from the //count. return allChannels.size() - 1; }
@Override public int getConnectionSize() { return this.channels.size(); }
@Override public int getConnectionSize() { return this.channels.size(); }
public int getConnectionSize() { return this.channels.size(); }
/** * @return the number of {@link Channel}s which have been added to this queue */ public int getNumberOfChannels() { return channelGroup.size(); }
public int getConnectionSize() { return this.channels.size(); }
public int getConnectionSize() { return this.channels.size(); }
@Override public int getConnectionSize() { return this.channels.size(); }
@Override public int getNumberOfConnections() { return allChannels.size() - 1; }
@Override public ServerStatistics getStatistics() { // The all channels collection contains the server channel which must be // removed from the count to get the number of client connections. return new ServerStatistics(totalRequests, allChannels.size() - 1); } }
private static ChannelGroupFuture getChannelGroupCloseFuture(ChannelGroup g) { Collection<ChannelFuture> futures = new ArrayList<ChannelFuture>(g.size()); for (Channel c: g) { futures.add(c.getCloseFuture()); } return new DefaultChannelGroupFuture(g, futures); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception { accepted.add(evt.getChannel()); if(LOG.isDebugEnabled()) { LOG.debug(String.format("Current number of shuffle connections (%d)", accepted.size())); } super.channelOpen(ctx, evt); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception { accepted.add(evt.getChannel()); LOG.info(String.format("Current number of shuffle connections (%d)", accepted.size())); super.channelOpen(ctx, evt); }
@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 static final void release() { if (allChannels.size() > 0) allChannels.close().awaitUninterruptibly(); bootstrap.releaseExternalResources(); }
@Override public void stop() { if (this.channels.size() > 0) { logger.info("{} currently has [{}] open child channel(s) that will be closed as part of stop()", configuration.getName(), this.channels.size()); } // close all channels still open within this session "bootstrap" this.channels.close().awaitUninterruptibly(); // clean up all external resources if (this.serverChannel != null) { this.serverChannel.close().awaitUninterruptibly(); this.serverChannel = null; } logger.info("{} stopped at {}:{}", configuration.getName(), configuration.getHost(), configuration.getPort()); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { activeChannels.add(e.getChannel()); if (logger.isDebugEnabled()) { logger.debug("Open new connection : " + e.getChannel().getRemoteAddress()); } // 如果连接数过大,停止响应新的连接请求 if (activeChannels.size() > networkModule.getMaxConnections()) { Channels.close(e.getChannel()); logger.error("Too many connections has established."); } }