org.jboss.netty.channel.group.DefaultChannelGroup Java Examples
The following examples show how to use
org.jboss.netty.channel.group.DefaultChannelGroup.
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: ProgrammableTSOServer.java From phoenix-omid with Apache License 2.0 | 6 votes |
@Inject public ProgrammableTSOServer(int port) { // Setup netty listener factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(new ThreadFactoryBuilder() .setNameFormat("boss-%d").build()), Executors.newCachedThreadPool(new ThreadFactoryBuilder() .setNameFormat("worker-%d").build()), (Runtime.getRuntime().availableProcessors() * 2 + 1) * 2); // Create the global ChannelGroup channelGroup = new DefaultChannelGroup(ProgrammableTSOServer.class.getName()); ServerBootstrap bootstrap = new ServerBootstrap(factory); bootstrap.setPipelineFactory(new TSOChannelHandler.TSOPipelineFactory(this)); // Add the parent channel to the group Channel channel = bootstrap.bind(new InetSocketAddress(port)); channelGroup.add(channel); LOG.info("********** Dumb TSO Server running on port {} **********", port); }
Example #2
Source File: Controller.java From onos with Apache License 2.0 | 6 votes |
/** * Tell controller that we're ready to accept pcc connections. */ public void run() { try { final ServerBootstrap bootstrap = createServerBootStrap(); bootstrap.setOption("reuseAddr", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE); ChannelPipelineFactory pfact = new PcepPipelineFactory(this); bootstrap.setPipelineFactory(pfact); InetSocketAddress sa = new InetSocketAddress(pcepPort); cg = new DefaultChannelGroup(); cg.add(bootstrap.bind(sa)); log.debug("Listening for PCC connection on {}", sa); } catch (Exception e) { throw new IllegalStateException(e); } }
Example #3
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 #4
Source File: Bootstrap.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
public void init() throws SyncException { cg = new DefaultChannelGroup("Cluster Bootstrap"); bossExecutor = Executors.newCachedThreadPool(); workerExecutor = Executors.newCachedThreadPool(); bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(bossExecutor, workerExecutor)); bootstrap.setOption("child.reuseAddr", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.sendBufferSize", RPCService.SEND_BUFFER_SIZE); bootstrap.setOption("child.receiveBufferSize", RPCService.SEND_BUFFER_SIZE); bootstrap.setOption("child.connectTimeoutMillis", RPCService.CONNECT_TIMEOUT); pipelineFactory = new BootstrapPipelineFactory(this); bootstrap.setPipelineFactory(pipelineFactory); }
Example #5
Source File: MemcachedBinaryPipelineFactory.java From fqueue with Apache License 2.0 | 5 votes |
public MemcachedBinaryPipelineFactory(Cache cache, String version, boolean verbose, int idleTime, DefaultChannelGroup channelGroup) { this.cache = cache; this.version = version; this.verbose = verbose; this.idleTime = idleTime; this.channelGroup = channelGroup; memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup); }
Example #6
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 #7
Source File: Controller.java From onos with Apache License 2.0 | 5 votes |
/** * Tell controller that we're ready to accept bgp peer connections. */ public void run() { try { peerBootstrap = createPeerBootStrap(); peerBootstrap.setOption("reuseAddr", true); peerBootstrap.setOption("child.keepAlive", true); peerBootstrap.setOption("child.tcpNoDelay", true); peerBootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE); final ServerBootstrap bootstrap = createServerBootStrap(); bootstrap.setOption("reuseAddr", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE); ChannelPipelineFactory pfact = new BgpPipelineFactory(bgpController, true); bootstrap.setPipelineFactory(pfact); InetSocketAddress sa = new InetSocketAddress(getBgpPortNum()); cg = new DefaultChannelGroup(); serverChannel = bootstrap.bind(sa); cg.add(serverChannel); log.info("Listening for Peer connection on {}", sa); } catch (Exception e) { throw new IllegalStateException(e); } }
Example #8
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 #9
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 #10
Source File: EventClient.java From hadoop-arch-book with Apache License 2.0 | 5 votes |
public void startClient() { ClientBootstrap bootstrap = new ClientBootstrap( new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); try { bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() { ChannelPipeline p = Channels.pipeline(); handler = new NettyClientHandler(); p.addLast("handler", handler); return p; } }); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("receiveBufferSize", 1048576); bootstrap.setOption("sendBufferSize", 1048576); // Start the connection attempt. LOG.info("EventClient: Connecting " + host + "," + port); ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port)); LOG.info("EventClient: Connected " + host + "," + port); allChannels = new DefaultChannelGroup(); // Wait until the connection is closed or the connection attempt fails. allChannels.add(future.getChannel()); LOG.info("EventClient: Added to Channels "); } catch (Exception e) { e.printStackTrace(); } }
Example #11
Source File: HttpDataServer.java From incubator-tajo with Apache License 2.0 | 5 votes |
public HttpDataServer(final InetSocketAddress addr, final DataRetriever retriever) { this.addr = addr; this.factory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Runtime.getRuntime().availableProcessors() * 2); // Configure the server. this.bootstrap = new ServerBootstrap(factory); // Set up the event pipeline factory. this.bootstrap.setPipelineFactory( new HttpDataServerPipelineFactory(retriever)); this.channelGroup = new DefaultChannelGroup(); }
Example #12
Source File: MemCacheDaemon.java From fqueue with Apache License 2.0 | 5 votes |
/** * Bind the network connection and start the network processing threads. */ public void start() { // TODO provide tweakable options here for passing in custom executors. channelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors .newCachedThreadPool()); allChannels = new DefaultChannelGroup("jmemcachedChannelGroup"); ServerBootstrap bootstrap = new ServerBootstrap(channelFactory); ChannelPipelineFactory pipelineFactory; if (binary) pipelineFactory = createMemcachedBinaryPipelineFactory(cache, memcachedVersion, verbose, idleTime, allChannels); else pipelineFactory = createMemcachedPipelineFactory(cache, memcachedVersion, verbose, idleTime, frameSize, allChannels); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("child.receiveBufferSize", 1024 * 64); bootstrap.setPipelineFactory(pipelineFactory); Channel serverChannel = bootstrap.bind(addr); allChannels.add(serverChannel); log.info("Listening on " + String.valueOf(addr.getHostName()) + ":" + addr.getPort()); running = true; }
Example #13
Source File: MemcachedPipelineFactory.java From fqueue with Apache License 2.0 | 5 votes |
public MemcachedPipelineFactory(Cache cache, String version, boolean verbose, int idleTime, int frameSize, DefaultChannelGroup channelGroup) { this.cache = cache; this.version = version; this.verbose = verbose; this.idleTime = idleTime; this.frameSize = frameSize; this.channelGroup = channelGroup; memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup); }
Example #14
Source File: MemCacheDaemon.java From fqueue with Apache License 2.0 | 5 votes |
/** * Bind the network connection and start the network processing threads. */ public void start() { // TODO provide tweakable options here for passing in custom executors. channelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors .newCachedThreadPool()); allChannels = new DefaultChannelGroup("jmemcachedChannelGroup"); ServerBootstrap bootstrap = new ServerBootstrap(channelFactory); ChannelPipelineFactory pipelineFactory; if (binary) pipelineFactory = createMemcachedBinaryPipelineFactory(cache, memcachedVersion, verbose, idleTime, allChannels); else pipelineFactory = createMemcachedPipelineFactory(cache, memcachedVersion, verbose, idleTime, frameSize, allChannels); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("child.receiveBufferSize", 1024 * 64); bootstrap.setPipelineFactory(pipelineFactory); Channel serverChannel = bootstrap.bind(addr); allChannels.add(serverChannel); log.info("Listening on " + String.valueOf(addr.getHostName()) + ":" + addr.getPort()); running = true; }
Example #15
Source File: MemcachedBinaryPipelineFactory.java From fqueue with Apache License 2.0 | 5 votes |
public MemcachedBinaryPipelineFactory(Cache cache, String version, boolean verbose, int idleTime, DefaultChannelGroup channelGroup) { this.cache = cache; this.version = version; this.verbose = verbose; this.idleTime = idleTime; this.channelGroup = channelGroup; memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup); }
Example #16
Source File: MemcachedPipelineFactory.java From fqueue with Apache License 2.0 | 5 votes |
public MemcachedPipelineFactory(Cache cache, String version, boolean verbose, int idleTime, int frameSize, DefaultChannelGroup channelGroup) { this.cache = cache; this.version = version; this.verbose = verbose; this.idleTime = idleTime; this.frameSize = frameSize; this.channelGroup = channelGroup; memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup); }
Example #17
Source File: AirPlayServer.java From Android-Airplay-Server with MIT License | 5 votes |
private AirPlayServer(){ //create executor service executorService = Executors.newCachedThreadPool(); //create channel execution handler channelExecutionHandler = new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(4, 0, 0)); //channel group channelGroup = new DefaultChannelGroup(); //list of mDNS services jmDNSInstances = new java.util.LinkedList<JmDNS>(); }
Example #18
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 #19
Source File: CanalServerWithNetty.java From canal with Apache License 2.0 | 4 votes |
private CanalServerWithNetty(){ this.embeddedServer = CanalServerWithEmbedded.instance(); this.childGroups = new DefaultChannelGroup(); }
Example #20
Source File: CanalAdminWithNetty.java From canal with Apache License 2.0 | 4 votes |
private CanalAdminWithNetty(){ this.childGroups = new DefaultChannelGroup(); }
Example #21
Source File: NettyIkasoaFactory.java From ikasoa with MIT License | 4 votes |
public NettyIkasoaFactory(NettyServerConfiguration configuration) { this.configuration = configuration; this.channelGroup = new DefaultChannelGroup(); }
Example #22
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 #23
Source File: NettyServerImpl.java From ikasoa with MIT License | 4 votes |
public NettyServerImpl(final String serverName, final int serverPort, final NettyServerConfiguration configuration, final TProcessor processor) { this(serverName, serverPort, configuration, processor, new DefaultChannelGroup()); }
Example #24
Source File: MemCacheDaemon.java From fqueue with Apache License 2.0 | 4 votes |
protected ChannelPipelineFactory createMemcachedPipelineFactory(Cache cache, String memcachedVersion, boolean verbose, int idleTime, int receiveBufferSize, DefaultChannelGroup allChannels) { return new MemcachedPipelineFactory(cache, memcachedVersion, verbose, idleTime, receiveBufferSize, allChannels); }
Example #25
Source File: MemCacheDaemon.java From fqueue with Apache License 2.0 | 4 votes |
protected ChannelPipelineFactory createMemcachedBinaryPipelineFactory(Cache cache, String memcachedVersion, boolean verbose, int idleTime, DefaultChannelGroup allChannels) { return new MemcachedBinaryPipelineFactory(cache, memcachedVersion, verbose, idleTime, allChannels); }
Example #26
Source File: MemCacheDaemon.java From fqueue with Apache License 2.0 | 4 votes |
protected ChannelPipelineFactory createMemcachedBinaryPipelineFactory(Cache cache, String memcachedVersion, boolean verbose, int idleTime, DefaultChannelGroup allChannels) { return new MemcachedBinaryPipelineFactory(cache, memcachedVersion, verbose, idleTime, allChannels); }
Example #27
Source File: CanalServerWithNetty.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
private CanalServerWithNetty(){ this.embeddedServer = CanalServerWithEmbedded.instance(); this.childGroups = new DefaultChannelGroup(); }
Example #28
Source File: MemCacheDaemon.java From fqueue with Apache License 2.0 | 4 votes |
protected ChannelPipelineFactory createMemcachedPipelineFactory(Cache cache, String memcachedVersion, boolean verbose, int idleTime, int receiveBufferSize, DefaultChannelGroup allChannels) { return new MemcachedPipelineFactory(cache, memcachedVersion, verbose, idleTime, receiveBufferSize, allChannels); }
Example #29
Source File: MemcachedCommandHandler.java From fqueue with Apache License 2.0 | 3 votes |
/** * Construct the server session handler * * @param cache * the cache to use * @param memcachedVersion * the version string to return to clients * @param verbosity * verbosity level for debugging * @param idle * how long sessions can be idle for * @param channelGroup */ public MemcachedCommandHandler(Cache cache, String memcachedVersion, boolean verbosity, int idle, DefaultChannelGroup channelGroup) { this.cache = cache; version = memcachedVersion; verbose = verbosity; idle_limit = idle; this.channelGroup = channelGroup; }
Example #30
Source File: MemcachedCommandHandler.java From fqueue with Apache License 2.0 | 3 votes |
/** * Construct the server session handler * * @param cache * the cache to use * @param memcachedVersion * the version string to return to clients * @param verbosity * verbosity level for debugging * @param idle * how long sessions can be idle for * @param channelGroup */ public MemcachedCommandHandler(Cache cache, String memcachedVersion, boolean verbosity, int idle, DefaultChannelGroup channelGroup) { this.cache = cache; version = memcachedVersion; verbose = verbosity; idle_limit = idle; this.channelGroup = channelGroup; }