本文整理汇总了Java中org.jboss.netty.channel.group.DefaultChannelGroup类的典型用法代码示例。如果您正苦于以下问题:Java DefaultChannelGroup类的具体用法?Java DefaultChannelGroup怎么用?Java DefaultChannelGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultChannelGroup类属于org.jboss.netty.channel.group包,在下文中一共展示了DefaultChannelGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
/**
* 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.info("Listening for PCC connection on {}", sa);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: run
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
/**
* Tell controller that we're ready to accept switches loop.
*/
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 OpenflowPipelineFactory(this, null, sslContext);
bootstrap.setPipelineFactory(pfact);
cg = new DefaultChannelGroup();
openFlowPorts.forEach(port -> {
InetSocketAddress sa = new InetSocketAddress(port);
cg.add(bootstrap.bind(sa));
log.info("Listening for switch connections on {}", sa);
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: init
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
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);
}
示例4: bootstrapNetty
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的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);
}
}
示例5: ProgrammableTSOServer
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
@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);
}
示例6: run
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
/**
* Tell controller that we're ready to accept switches loop.
*/
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 OpenflowPipelineFactory(this, null);
bootstrap.setPipelineFactory(pfact);
InetSocketAddress sa = new InetSocketAddress(openFlowPort);
cg = new DefaultChannelGroup();
cg.add(bootstrap.bind(sa));
log.info("Listening for switch connections on {}", sa);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例7: bootstrapNetty
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的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);
}
}
示例8: bootstrapNetty
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的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);
}
}
示例9: bootstrapNetty
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的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);
}
}
示例10: start
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
public synchronized void start() {
final Executor bossPool = Executors.newCachedThreadPool();
final Executor workerPool = Executors.newCachedThreadPool();
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossPool, workerPool));
final ClientSocketChannelFactory clientSocketChannelFactory = new NioClientSocketChannelFactory(bossPool, workerPool);
bootstrap.setOption("child.tcpNoDelay", true);
allChannels = new DefaultChannelGroup("handler");
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new FrontendHandler(allChannels, clientSocketChannelFactory, serverPool, statistics));
}
});
log.info("Starting on port {}", port);
acceptor = bootstrap.bind(new InetSocketAddress(port));
if (acceptor.isBound()) {
log.info("Server started successfully");
}
}
示例11: withoutPacketTest
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的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();
}
}
示例12: run
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
/**
* 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);
}
}
示例13: HttpTunnelSoakTester
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
public HttpTunnelSoakTester() {
scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
executor = Executors.newCachedThreadPool();
ServerSocketChannelFactory serverChannelFactory = new NioServerSocketChannelFactory(
executor, executor);
HttpTunnelServerChannelFactory serverTunnelFactory = new HttpTunnelServerChannelFactory(
serverChannelFactory);
serverBootstrap = new ServerBootstrap(serverTunnelFactory);
serverBootstrap.setPipelineFactory(createServerPipelineFactory());
ClientSocketChannelFactory clientChannelFactory = new NioClientSocketChannelFactory(
executor, executor);
HttpTunnelClientChannelFactory clientTunnelFactory = new HttpTunnelClientChannelFactory(
clientChannelFactory);
clientBootstrap = new ClientBootstrap(clientTunnelFactory);
clientBootstrap.setPipelineFactory(createClientPipelineFactory());
configureProxy();
channels = new DefaultChannelGroup();
}
示例14: run
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
/**
* 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 RuntimeException(e);
}
}
示例15: PeerGroup
import org.jboss.netty.channel.group.DefaultChannelGroup; //导入依赖的package包/类
/**
* <p>Creates a PeerGroup for the given network and chain, using the provided Netty {@link ClientBootstrap} object.
* </p>
*
* <p>A ClientBootstrap creates raw (TCP) connections to other nodes on the network. Normally you won't need to
* provide one - use the other constructors. Providing your own bootstrap is useful if you want to control
* details like how many network threads are used, the connection timeout value and so on. To do this, you can
* use {@link PeerGroup#createClientBootstrap()} method and then customize the resulting object. Example:</p>
*
* <pre>
* ClientBootstrap bootstrap = PeerGroup.createClientBootstrap();
* bootstrap.setOption("connectTimeoutMillis", 3000);
* PeerGroup peerGroup = new PeerGroup(params, chain, bootstrap);
* </pre>
*
* <p>The ClientBootstrap provided does not need a channel pipeline factory set. If one wasn't set, the provided
* bootstrap will be modified to have one that sets up the pipelines correctly.</p>
*/
public PeerGroup(NetworkParameters params, AbstractBlockChain chain, ClientBootstrap bootstrap) {
this.params = params;
this.chain = chain; // Can be null.
this.fastCatchupTimeSecs = params.genesisBlock.getTimeSeconds();
this.wallets = new CopyOnWriteArrayList<Wallet>();
// This default sentinel value will be overridden by one of two actions:
// - adding a peer discovery source sets it to the default
// - using connectTo() will increment it by one
this.maxConnections = 0;
int height = chain == null ? 0 : chain.getBestChainHeight();
// We never request that the remote node wait for a bloom filter yet, as we have no wallets
this.versionMessage = new VersionMessage(params, height, true);
memoryPool = new MemoryPool();
// Configure Netty. The "ClientBootstrap" creates connections to other nodes. It can be configured in various
// ways to control the network.
if (bootstrap == null) {
this.bootstrap = createClientBootstrap();
this.bootstrap.setPipelineFactory(makePipelineFactory(params, chain));
} else {
this.bootstrap = bootstrap;
}
inactives = Collections.synchronizedList(new ArrayList<PeerAddress>());
peers = new ArrayList<Peer>();
pendingPeers = new ArrayList<Peer>();
channels = new DefaultChannelGroup();
peerDiscoverers = new CopyOnWriteArraySet<PeerDiscovery>();
peerEventListeners = new CopyOnWriteArrayList<PeerEventListener>();
}