本文整理汇总了Java中org.jboss.netty.channel.group.ChannelGroup类的典型用法代码示例。如果您正苦于以下问题:Java ChannelGroup类的具体用法?Java ChannelGroup怎么用?Java ChannelGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelGroup类属于org.jboss.netty.channel.group包,在下文中一共展示了ChannelGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: RpcProgramPortmap
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
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);
}
示例8: NettyIkasoaFactory
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
public NettyIkasoaFactory(NettyServerConfig nettyServerConfig, ChannelGroup channelGroup) {
this.nettyServerConfig = nettyServerConfig;
if (channelGroup == null)
this.channelGroup = new DefaultChannelGroup();
else
this.channelGroup = channelGroup;
}
示例9: NettyServerUpstreamHandler
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
public NettyServerUpstreamHandler(LoggerFactory loggerFactory, ChannelHandler channelHandler,
ChannelGroup channelGroup) {
this.logger = loggerFactory.create(this);
this.ioErrorLogger = loggerFactory.create(this.getClass().getSimpleName() + ".IOError");
this.channelHandler = channelHandler;
this.allChannels = channelGroup;
}
示例10: NettyServerTransport
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
@Inject
public NettyServerTransport(final ThriftServerDef def, final NettyServerConfig nettyServerConfig, final ChannelGroup allChannels, final boolean local) {
this.def = def;
this.nettyServerConfig = nettyServerConfig;
this.requestedPort = def.getServerPort();
this.allChannels = allChannels;
this.local = local;
// connectionLimiter must be instantiated exactly once (and thus outside
// the pipeline factory)
final ConnectionLimiter connectionLimiter = new ConnectionLimiter(def.getMaxConnections());
this.channelStatistics = new ChannelStatistics(allChannels);
this.pipelineFactory = new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline cp = Channels.pipeline();
TProtocolFactory inputProtocolFactory = def.getDuplexProtocolFactory().getInputProtocolFactory();
NiftySecurityHandlers securityHandlers = def.getSecurityFactory().getSecurityHandlers(def, nettyServerConfig);
cp.addLast("connectionContext", new ConnectionContextHandler());
cp.addLast("connectionLimiter", connectionLimiter);
cp.addLast(ChannelStatistics.NAME, channelStatistics);
cp.addLast("encryptionHandler", securityHandlers.getEncryptionHandler());
cp.addLast("frameCodec", def.getThriftFrameCodecFactory().create(def.getMaxFrameSize(), inputProtocolFactory));
if (def.getClientIdleTimeout() != null) {
// Add handlers to detect idle client connections and
// disconnect them
cp.addLast("idleTimeoutHandler", new IdleStateHandler(nettyServerConfig.getTimer(), def.getClientIdleTimeout().toMillis(),
NO_WRITER_IDLE_TIMEOUT, NO_ALL_IDLE_TIMEOUT, TimeUnit.MILLISECONDS));
cp.addLast("idleDisconnectHandler", new IdleDisconnectHandler());
}
cp.addLast("authHandler", securityHandlers.getAuthenticationHandler());
cp.addLast("dispatcher", new NiftyDispatcher(def, nettyServerConfig.getTimer()));
cp.addLast("exceptionLogger", new NiftyExceptionLogger());
return cp;
}
};
}
示例11: ClientChannelPipeline
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
public ClientChannelPipeline(
final OpenVirteXController openVirteXController,
final ChannelGroup cg, final ThreadPoolExecutor pipelineExecutor,
final ClientBootstrap bootstrap, final OVXSwitch sw) {
super();
this.ctrl = openVirteXController;
this.pipelineExecutor = pipelineExecutor;
this.timer = PhysicalNetwork.getTimer();
this.idleHandler = new IdleStateHandler(this.timer, 20, 25, 0);
this.readTimeoutHandler = new ReadTimeoutHandler(this.timer, 30);
this.bootstrap = bootstrap;
this.sw = sw;
this.cg = cg;
}
示例12: ReconnectHandler
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
public ReconnectHandler(final OVXSwitch sw,
final ClientBootstrap bootstrap, final Timer timer,
final int maxBackOff, final ChannelGroup cg) {
super();
this.sw = sw;
this.bootstrap = bootstrap;
this.timer = timer;
this.maxBackOff = maxBackOff;
this.cg = cg;
}
示例13: ChannelPoolLifecycle
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
public ChannelPoolLifecycle(SocketAddress address, ClientBootstrap bootstrap, long getTimeout,
ScheduledExecutorService executor, ChannelGroup channelGroup)
{
_remoteAddress = address;
_rateLimiter = new RateLimiter(0, getTimeout / 2, Math.max(10, getTimeout / 32), executor);
_bootstrap = bootstrap;
_channelGroup = channelGroup;
}
示例14: HealthCheckManager
import org.jboss.netty.channel.group.ChannelGroup; //导入依赖的package包/类
public HealthCheckManager(Timer timer, long waitTimeMillis, ChannelGroup channelGroup) {
Assert.requireNonNull(timer, "timer must not be null");
Assert.isTrue(waitTimeMillis > 0, "waitTimeMillis is must greater than 0");
Assert.requireNonNull(channelGroup, "channelGroup must not be null");
this.timer = timer;
this.waitTimeMillis = waitTimeMillis;
this.channelGroup = channelGroup;
}
示例15: 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();
}
}