本文整理汇总了Java中org.jboss.netty.channel.group.ChannelGroup.add方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelGroup.add方法的具体用法?Java ChannelGroup.add怎么用?Java ChannelGroup.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.channel.group.ChannelGroup
的用法示例。
在下文中一共展示了ChannelGroup.add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bootstrapNetty
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
/**
* Bootstraps netty, the server that handles all openflow connections
*/
public void bootstrapNetty() {
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 = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, keyStore, keyStorePassword) :
new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);
bootstrap.setPipelineFactory(pfact);
InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
final ChannelGroup cg = new DefaultChannelGroup();
cg.add(bootstrap.bind(sa));
log.info("Listening for switch connections on {}", sa);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: bootstrapNetty
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
/**
* Bootstraps netty, the server that handles all openflow connections
*/
public void bootstrapNetty() {
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 = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, ofBitmaps, defaultFactory, keyStore, keyStorePassword) :
new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, ofBitmaps, defaultFactory);
bootstrap.setPipelineFactory(pfact);
InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
final ChannelGroup cg = new DefaultChannelGroup();
cg.add(bootstrap.bind(sa));
log.info("Listening for switch connections on {}", sa);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: bootstrapNetty
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
/**
* Bootstraps netty, the server that handles all openflow connections
* 启动netty,处理所有OF连接
*/
public void bootstrapNetty() {
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 = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, keyStore, keyStorePassword) :
new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);
bootstrap.setPipelineFactory(pfact);
InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
final ChannelGroup cg = new DefaultChannelGroup();
cg.add(bootstrap.bind(sa));
log.info("Listening for switch connections on {}", sa);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: bootstrapNetty
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
/**
* Bootstraps netty, the server that handles all openflow connections
*/
public void bootstrapNetty() {
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 OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);
bootstrap.setPipelineFactory(pfact);
InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
final ChannelGroup cg = new DefaultChannelGroup();
cg.add(bootstrap.bind(sa));
log.info("Listening for switch connections on {}", sa);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例5: withoutPacketTest
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
@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();
}
}
示例6: HttpTunnelServerChannel
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
protected HttpTunnelServerChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, ServerSocketChannelFactory inboundFactory, ChannelGroup realConnections) {
super(factory, pipeline, sink);
tunnelIdPrefix = Long.toHexString(random.nextLong());
tunnels = new ConcurrentHashMap<String, HttpTunnelAcceptedChannel>();
config = new HttpTunnelServerChannelConfig();
realChannel = inboundFactory.newChannel(this.createRealPipeline(realConnections));
config.setRealChannel(realChannel);
opened = new AtomicBoolean(true);
bindState = new AtomicReference<BindState>(BindState.UNBOUND);
realConnections.add(realChannel);
Channels.fireChannelOpen(this);
}
示例7: legacyPingPacketTest
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
@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();
}
}
示例8: pingPacketTest
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
@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();
}
}
示例9: initHttpBootstrap
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
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");
}
示例10: addSubscription
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
public void addSubscription( String path, Channel channel ) {
ChannelGroup group = subscribers.get( path );
synchronized ( group ) {
group.add( channel );
}
}
示例11: HttpTunnelClientChannel
import org.jboss.netty.channel.group.ChannelGroup; //导入方法依赖的package包/类
/**
* @see HttpTunnelClientChannelFactory#newChannel(ChannelPipeline)
*/
protected HttpTunnelClientChannel(ChannelFactory factory, ChannelPipeline pipeline, HttpTunnelClientChannelSink sink, ClientSocketChannelFactory outboundFactory, ChannelGroup realConnections) {
super(null, factory, pipeline, sink);
this.outboundFactory = outboundFactory;
final WorkerCallbacks callbackProxy = new WorkerCallbacks();
incomingBuffer = new IncomingBuffer<ChannelBuffer>(this);
Metrics.newGauge(HttpTunnelClientChannel.class, "incomingBuffer", new Gauge<Integer>() {
@Override
public Integer value() {
return incomingBuffer.size();
}
});
sendChannel = outboundFactory.newChannel(Channels.pipeline(new SimpleChannelHandler()));
pollChannel = outboundFactory.newChannel(Channels.pipeline(new SimpleChannelHandler()));
config = new HttpTunnelClientChannelConfig(sendChannel.getConfig(), pollChannel.getConfig());
saturationManager = new SaturationManager(config.getWriteBufferLowWaterMark(), config.getWriteBufferHighWaterMark());
sendHttpHandler = new HttpTunnelClientChannelProxyHandler();
sendHandler = new HttpTunnelClientChannelSendHandler(callbackProxy);
pollHttpHandler = new HttpTunnelClientChannelProxyHandler();
pollHandler = new HttpTunnelClientChannelPollHandler(callbackProxy);
opened = new AtomicBoolean(true);
bindState = new AtomicReference<BindState>(BindState.UNBOUND);
connectState = new AtomicReference<ConnectState>(ConnectState.DISCONNECTED);
connectFuture = new AtomicReference<ChannelFuture>(null);
tunnelId = null;
remoteAddress = null;
this.initSendPipeline(sendChannel.getPipeline());
this.initPollPipeline(pollChannel.getPipeline());
realConnections.add(sendChannel);
realConnections.add(pollChannel);
Channels.fireChannelOpen(this);
}