org.jboss.netty.channel.group.ChannelGroup Java Examples
The following examples show how to use
org.jboss.netty.channel.group.ChannelGroup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HealthCheckManagerTest.java From pinpoint with Apache License 2.0 | 6 votes |
@Test public void withoutPacketTest() throws Exception { ChannelGroup channelGroup = new DefaultChannelGroup(); HealthCheckManager healthCheckManager = new HealthCheckManager(timer, 3000, channelGroup); healthCheckManager.start(1000); Channel mockChannel = createMockChannel(HealthCheckState.WAIT); channelGroup.add(mockChannel); try { verify(mockChannel, timeout(5000).atLeastOnce()).close(); } finally { healthCheckManager.stop(); } }
Example #2
Source File: HealthCheckManager.java From pinpoint with Apache License 2.0 | 5 votes |
public HealthCheckManager(Timer timer, long waitTimeMillis, ChannelGroup channelGroup) { Assert.requireNonNull(timer, "timer"); Assert.isTrue(waitTimeMillis > 0, "waitTimeMillis is must greater than 0"); Assert.requireNonNull(channelGroup, "channelGroup"); this.timer = timer; this.waitTimeMillis = waitTimeMillis; this.channelGroup = channelGroup; }
Example #3
Source File: WebSocketChannelHandler.java From usergrid with Apache License 2.0 | 5 votes |
public void removeSubscription( String path, Channel channel ) { ChannelGroup group = subscribers.get( path ); synchronized ( group ) { group.remove( channel ); if ( group.isEmpty() ) { subscribers.remove( path, group ); } } }
Example #4
Source File: RpcProgramPortmap.java From hadoop with Apache License 2.0 | 5 votes |
RpcProgramPortmap(ChannelGroup allChannels) { this.allChannels = allChannels; PortmapMapping m = new PortmapMapping(PROGRAM, VERSION, PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT); PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION, PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT); map.put(PortmapMapping.key(m), m); map.put(PortmapMapping.key(m1), m1); }
Example #5
Source File: RpcProgramPortmap.java From big-c with Apache License 2.0 | 5 votes |
RpcProgramPortmap(ChannelGroup allChannels) { this.allChannels = allChannels; PortmapMapping m = new PortmapMapping(PROGRAM, VERSION, PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT); PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION, PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT); map.put(PortmapMapping.key(m), m); map.put(PortmapMapping.key(m1), m1); }
Example #6
Source File: HealthCheckManagerTest.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void legacyPingPacketTest() throws Exception { ChannelGroup channelGroup = new DefaultChannelGroup(); HealthCheckManager healthCheckManager = new HealthCheckManager(timer, 3000, channelGroup); healthCheckManager.start(1000); Channel mockChannel = createMockChannel(HealthCheckState.RECEIVED_LEGACY); channelGroup.add(mockChannel); try { verify(mockChannel, timeout(3000).atLeastOnce()).write(PingPacket.PING_PACKET); } finally { healthCheckManager.stop(); } }
Example #7
Source File: NettyServerImpl.java From ikasoa with MIT License | 5 votes |
public NettyServerImpl(final String serverName, final int serverPort, final NettyServerConfiguration configuration, final TProcessor processor, final ChannelGroup allChannels) { setServerName(serverName); requestedPort = serverPort; setConfiguration(ObjectUtil.isNull(configuration) ? new NettyServerConfiguration(new TProcessorFactory(processor)) : configuration); setProcessor(processor); this.allChannels = allChannels; }
Example #8
Source File: WebSocketChannelHandler.java From usergrid with Apache License 2.0 | 5 votes |
private ChannelGroup getChannelGroupWithDefault( String path ) { ChannelGroup group = subscribers.get( path ); if ( group == null ) { group = subscribers.putIfAbsent( path, new DefaultChannelGroup() ); } return group; }
Example #9
Source File: NettyServer.java From james-project with Apache License 2.0 | 5 votes |
@Override protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) { return new AbstractSSLAwareChannelPipelineFactory( getTimeout(), maxCurConnections, maxCurConnectionsPerIP, group, secure != null ? secure.getEnabledCipherSuites() : null, eHandler, getFrameHandlerFactory(), hashedWheelTimer) { @Override protected ChannelUpstreamHandler createHandler() { return coreHandler; } @Override protected boolean isSSLSocket() { return getSSLContext() != null && secure != null && !secure.isStartTLS(); } @Override protected SSLContext getSSLContext() { if (secure != null) { return secure.getContext(); } else { return null; } } }; }
Example #10
Source File: AbstractConfigurableAsyncServer.java From james-project with Apache License 2.0 | 5 votes |
@Override protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) { return new AbstractExecutorAwareChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group, enabledCipherSuites, getExecutionHandler(), getFrameHandlerFactory(), timer) { @Override protected SSLContext getSSLContext() { if (encryption == null) { return null; } else { return encryption.getContext(); } } @Override protected boolean isSSLSocket() { return encryption != null && !encryption.isStartTLS(); } @Override protected ChannelUpstreamHandler createHandler() { return AbstractConfigurableAsyncServer.this.createCoreHandler(); } @Override protected ConnectionCountHandler getConnectionCountHandler() { return AbstractConfigurableAsyncServer.this.getConnectionCountHandler(); } }; }
Example #11
Source File: HealthCheckManagerTest.java From pinpoint with Apache License 2.0 | 5 votes |
@Test public void pingPacketTest() throws Exception { ChannelGroup channelGroup = new DefaultChannelGroup(); HealthCheckManager healthCheckManager = new HealthCheckManager(timer, 3000, channelGroup); healthCheckManager.start(1000); Channel mockChannel = createMockChannel(HealthCheckState.RECEIVED); channelGroup.add(mockChannel); try { verify(mockChannel, timeout(3000).atLeastOnce()).write(PingSimplePacket.PING_PACKET); } finally { healthCheckManager.stop(); } }
Example #12
Source File: AbstractSSLAwareChannelPipelineFactory.java From james-project with Apache License 2.0 | 5 votes |
public AbstractSSLAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup group, String[] enabledCipherSuites, ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) { this(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory, hashedWheelTimer); // We need to copy the String array because of possible security issues. // See https://issues.apache.org/jira/browse/PROTOCOLS-18 this.enabledCipherSuites = ArrayUtils.clone(enabledCipherSuites); }
Example #13
Source File: AbstractChannelPipelineFactory.java From james-project with Apache License 2.0 | 5 votes |
public AbstractChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup channels, ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) { this.connectionLimitHandler = new ConnectionLimitUpstreamHandler(maxConnections); this.connectionPerIpLimitHandler = new ConnectionPerIpLimitUpstreamHandler(maxConnectsPerIp); this.groupHandler = new ChannelGroupHandler(channels); this.timeout = timeout; this.eHandler = eHandler; this.frameHandlerFactory = frameHandlerFactory; this.timer = hashedWheelTimer; }
Example #14
Source File: HandshakeInitializationHandler.java From canal with Apache License 2.0 | 4 votes |
public HandshakeInitializationHandler(ChannelGroup childGroups){ this.childGroups = childGroups; }
Example #15
Source File: HandshakeInitializationHandler.java From canal with Apache License 2.0 | 4 votes |
public HandshakeInitializationHandler(ChannelGroup childGroups){ this.childGroups = childGroups; }
Example #16
Source File: AbstractExecutorAwareChannelPipelineFactory.java From james-project with Apache License 2.0 | 4 votes |
public AbstractExecutorAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup group, String[] enabledCipherSuites, ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) { super(timeout, maxConnections, maxConnectsPerIp, group, enabledCipherSuites, eHandler, frameHandlerFactory, hashedWheelTimer); }
Example #17
Source File: WebSocketChannelHandler.java From usergrid with Apache License 2.0 | 4 votes |
public void addSubscription( String path, Channel channel ) { ChannelGroup group = subscribers.get( path ); synchronized ( group ) { group.add( channel ); } }
Example #18
Source File: WebSocketChannelHandler.java From usergrid with Apache License 2.0 | 4 votes |
public ChannelGroup getSubscriptionGroup( String path ) { return subscribers.get( path ); }
Example #19
Source File: IMAPServer.java From james-project with Apache License 2.0 | 4 votes |
@Override protected ChannelPipelineFactory createPipelineFactory(final ChannelGroup group) { return new ChannelPipelineFactory() { private final ChannelGroupHandler groupHandler = new ChannelGroupHandler(group); private final HashedWheelTimer timer = new HashedWheelTimer(); private final TimeUnit timeoutUnit = TimeUnit.SECONDS; @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast(GROUP_HANDLER, groupHandler); pipeline.addLast("idleHandler", new IdleStateHandler(timer, 0, 0, timeout, timeoutUnit)); pipeline.addLast(TIMEOUT_HANDLER, new ImapIdleStateHandler()); pipeline.addLast(CONNECTION_LIMIT_HANDLER, new ConnectionLimitUpstreamHandler(IMAPServer.this.connectionLimit)); pipeline.addLast(CONNECTION_LIMIT_PER_IP_HANDLER, new ConnectionPerIpLimitUpstreamHandler(IMAPServer.this.connPerIP)); // Add the text line decoder which limit the max line length, // don't strip the delimiter and use CRLF as delimiter // Use a SwitchableDelimiterBasedFrameDecoder, see JAMES-1436 pipeline.addLast(FRAMER, getFrameHandlerFactory().create(pipeline)); Encryption secure = getEncryption(); if (secure != null && !secure.isStartTLS()) { // We need to set clientMode to false. // See https://issues.apache.org/jira/browse/JAMES-1025 SSLEngine engine = secure.getContext().createSSLEngine(); engine.setUseClientMode(false); pipeline.addFirst(SSL_HANDLER, new SslHandler(engine)); } pipeline.addLast(CONNECTION_COUNT_HANDLER, getConnectionCountHandler()); pipeline.addLast(CHUNK_WRITE_HANDLER, new ChunkedWriteHandler()); ExecutionHandler ehandler = getExecutionHandler(); if (ehandler != null) { pipeline.addLast(EXECUTION_HANDLER, ehandler); } pipeline.addLast(REQUEST_DECODER, new ImapRequestFrameDecoder(decoder, inMemorySizeLimit, literalSizeLimit)); pipeline.addLast(CORE_HANDLER, createCoreHandler()); return pipeline; } }; }
Example #20
Source File: ManageSieveServer.java From james-project with Apache License 2.0 | 4 votes |
@Override protected ChannelPipelineFactory createPipelineFactory(final ChannelGroup group) { return new ChannelPipelineFactory() { private final ChannelGroupHandler groupHandler = new ChannelGroupHandler(group); @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); Encryption secure = getEncryption(); if (secure != null && !secure.isStartTLS()) { // We need to set clientMode to false. // See https://issues.apache.org/jira/browse/JAMES-1025 SSLEngine engine = secure.getContext().createSSLEngine(); engine.setUseClientMode(false); pipeline.addFirst(SSL_HANDLER, new SslHandler(engine)); } pipeline.addLast(GROUP_HANDLER, groupHandler); pipeline.addLast(CONNECTION_LIMIT_HANDLER, new ConnectionLimitUpstreamHandler(ManageSieveServer.this.connectionLimit)); pipeline.addLast(CONNECTION_LIMIT_PER_IP_HANDLER, new ConnectionPerIpLimitUpstreamHandler(ManageSieveServer.this.connPerIP)); // Add the text line decoder which limit the max line length, // don't strip the delimiter and use CRLF as delimiter // Use a SwitchableDelimiterBasedFrameDecoder, see JAMES-1436 pipeline.addLast(FRAMER, getFrameHandlerFactory().create(pipeline)); pipeline.addLast(CONNECTION_COUNT_HANDLER, getConnectionCountHandler()); pipeline.addLast(CHUNK_WRITE_HANDLER, new ChunkedWriteHandler()); ExecutionHandler ehandler = getExecutionHandler(); if (ehandler != null) { pipeline.addLast(EXECUTION_HANDLER, ehandler); } pipeline.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8)); pipeline.addLast(CORE_HANDLER, createCoreHandler()); pipeline.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8)); return pipeline; } }; }
Example #21
Source File: HandshakeInitializationHandler.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
public HandshakeInitializationHandler(ChannelGroup childGroups){ this.childGroups = childGroups; }
Example #22
Source File: ChannelGroupHandler.java From james-project with Apache License 2.0 | 4 votes |
public ChannelGroupHandler(ChannelGroup channels) { this.channels = channels; }
Example #23
Source File: AbstractSSLAwareChannelPipelineFactory.java From james-project with Apache License 2.0 | 4 votes |
public AbstractSSLAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup group, ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) { super(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory, hashedWheelTimer); }
Example #24
Source File: AirPlayServer.java From Android-Airplay-Server with MIT License | 4 votes |
public ChannelGroup getChannelGroup() { return channelGroup; }
Example #25
Source File: NettyIkasoaFactory.java From ikasoa with MIT License | 4 votes |
public NettyIkasoaFactory(NettyServerConfiguration configuration, ChannelGroup channelGroup) { this.configuration = configuration; this.channelGroup = ObjectUtil.isNull(channelGroup) ? new DefaultChannelGroup() : channelGroup; }
Example #26
Source File: RpcServerBootstrap.java From voyage with Apache License 2.0 | 4 votes |
private void initHttpBootstrap(int myport) { logger.info("initHttpBootstrap..........."); final ServerConfig serverConfig = new ServerConfig(myport); final ChannelGroup channelGroup = new DefaultChannelGroup(getClass().getName()); bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( //建议用ThreadPoolExecutor代替 Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), serverConfig.getThreadCnt())); //设置常见参数 bootstrap.setOption("tcpNoDelay","true");//禁用nagle算法 bootstrap.setOption("reuseAddress", "true"); bootstrap.setOption("SO_RCVBUF",1024*128); bootstrap.setOption("SO_SNDBUF",1024*128); timer = new HashedWheelTimer(); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); int readTimeout = serverConfig.getReadTimeout(); if (readTimeout > 0) { pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout, TimeUnit.MILLISECONDS)); } pipeline.addLast("decoder", new RpcRequestDecode()); pipeline.addLast("encoder", new RpcResponseEncode()); pipeline.addLast("handler", new NettyRpcServerHandler(channelGroup)); return pipeline; } }); int port = serverConfig.getPort(); if (!checkPortConfig(port)) { throw new IllegalStateException("port: " + port + " already in use!"); } Channel channel = bootstrap.bind(new InetSocketAddress(port)); channelGroup.add(channel); logger.info("voyage server started"); waitForShutdownCommand(); ChannelGroupFuture future = channelGroup.close(); future.awaitUninterruptibly(); bootstrap.releaseExternalResources(); timer.stop(); timer = null; logger.info("voyage server stoped"); }
Example #27
Source File: NettyRpcServerHandler.java From voyage with Apache License 2.0 | 4 votes |
public NettyRpcServerHandler(ChannelGroup channelGroups) { this.channelGroups = channelGroups; }
Example #28
Source File: AbstractAsyncServer.java From james-project with Apache License 2.0 | 2 votes |
/** * Create ChannelPipelineFactory to use by this Server implementation */ protected abstract ChannelPipelineFactory createPipelineFactory(ChannelGroup group);