當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultChannelGroup類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:Controller.java

示例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);
    }

}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:29,代碼來源:Controller.java

示例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);
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:22,代碼來源:Bootstrap.java

示例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);
	}
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:26,代碼來源:OFSwitchManager.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-omid,代碼行數:20,代碼來源:ProgrammableTSOServer.java

示例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);
    }

}
 
開發者ID:ravikumaran2015,項目名稱:ravikumaran201504,代碼行數:27,代碼來源:Controller.java

示例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);
	}
}
 
開發者ID:rhoybeen,項目名稱:floodlightLB,代碼行數:26,代碼來源:OFSwitchManager.java

示例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);
	}
}
 
開發者ID:DaiDongLiang,項目名稱:DSC,代碼行數:27,代碼來源:OFSwitchManager.java

示例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);
	}
}
 
開發者ID:pixuan,項目名稱:floodlight,代碼行數:25,代碼來源:OFSwitchManager.java

示例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");
    }
}
 
開發者ID:iamseth,項目名稱:tightrope,代碼行數:23,代碼來源:LoadBalancer.java

示例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();
    }
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:17,代碼來源:HealthCheckManagerTest.java

示例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);
    }
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:24,代碼來源:Controller.java

示例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();
}
 
開發者ID:reines,項目名稱:httptunnel,代碼行數:23,代碼來源:HttpTunnelSoakTester.java

示例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);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:34,代碼來源:Controller.java

示例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>();
}
 
開發者ID:appteam-nith,項目名稱:NithPointsj,代碼行數:52,代碼來源:PeerGroup.java


注:本文中的org.jboss.netty.channel.group.DefaultChannelGroup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。