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


Java DefaultChannelGroup.add方法代碼示例

本文整理匯總了Java中org.jboss.netty.channel.group.DefaultChannelGroup.add方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultChannelGroup.add方法的具體用法?Java DefaultChannelGroup.add怎麽用?Java DefaultChannelGroup.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.channel.group.DefaultChannelGroup的用法示例。


在下文中一共展示了DefaultChannelGroup.add方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: startClient

import org.jboss.netty.channel.group.DefaultChannelGroup; //導入方法依賴的package包/類
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();
  }
}
 
開發者ID:amitchmca,項目名稱:hadooparchitecturebook,代碼行數:39,代碼來源:EventClient.java

示例7: start

import org.jboss.netty.channel.group.DefaultChannelGroup; //導入方法依賴的package包/類
/**
 * 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.setPipelineFactory(pipelineFactory);
    bootstrap.setOption("sendBufferSize", 65536 );
    bootstrap.setOption("receiveBufferSize", 65536);

    Channel serverChannel = bootstrap.bind(addr);
    allChannels.add(serverChannel);

    log.info("Listening on " + String.valueOf(addr.getHostName()) + ":" + addr.getPort());

    running = true;
}
 
開發者ID:rdaum,項目名稱:jmemcache-daemon,代碼行數:32,代碼來源:MemCacheDaemon.java

示例8: start

import org.jboss.netty.channel.group.DefaultChannelGroup; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:sunli1223,項目名稱:fqueue,代碼行數:33,代碼來源:MemCacheDaemon.java

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

示例10: start

import org.jboss.netty.channel.group.DefaultChannelGroup; //導入方法依賴的package包/類
public boolean start() throws IOException {
	hostname = configuration.getServerHostname();
	InetSocketAddress address;

	if (StringUtils.isNotBlank(hostname)) {
		LOGGER.info("Using forced address " + hostname);
		InetAddress tempIA = InetAddress.getByName(hostname);

		if (tempIA != null && networkInterface != null && networkInterface.equals(NetworkInterface.getByInetAddress(tempIA))) {
			address = new InetSocketAddress(tempIA, port);
		} else {
			address = new InetSocketAddress(hostname, port);
		}
	} else if (isAddressFromInterfaceFound(configuration.getNetworkInterface())) { // XXX sets iafinal and networkInterface
		LOGGER.info("Using address {} found on network interface: {}", iafinal, networkInterface.toString().trim().replace('\n', ' '));
		address = new InetSocketAddress(iafinal, port);
	} else {
		LOGGER.info("Using localhost address");
		address = new InetSocketAddress(port);
	}

	LOGGER.info("Created socket: {}", address);

	if (configuration.isHTTPEngineV2()) { // HTTP Engine V2
		ThreadRenamingRunnable.setThreadNameDeterminer(ThreadNameDeterminer.CURRENT);
		group = new DefaultChannelGroup("HTTPServer");
		factory = new NioServerSocketChannelFactory(
			Executors.newCachedThreadPool(new NettyBossThreadFactory()),
			Executors.newCachedThreadPool(new NettyWorkerThreadFactory())
		);

		ServerBootstrap bootstrap = new ServerBootstrap(factory);
		HttpServerPipelineFactory pipeline = new HttpServerPipelineFactory(group);
		bootstrap.setPipelineFactory(pipeline);
		bootstrap.setOption("child.tcpNoDelay", true);
		bootstrap.setOption("child.keepAlive", true);
		bootstrap.setOption("reuseAddress", true);
		bootstrap.setOption("child.reuseAddress", true);
		bootstrap.setOption("child.sendBufferSize", 65536);
		bootstrap.setOption("child.receiveBufferSize", 65536);

		try {
			channel = bootstrap.bind(address);

			group.add(channel);
		} catch (Exception e) {
			LOGGER.error("Another program is using port " + port + ", which DMS needs.");
			LOGGER.error("You can change the port DMS uses on the General Configuration tab.");
			LOGGER.trace("The error was: " + e);
			PMS.get().getFrame().setConnectionState(ConnectionState.BLOCKED);
		}

		if (hostname == null && iafinal != null) {
			hostname = iafinal.getHostAddress();
		} else if (hostname == null) {
			hostname = InetAddress.getLocalHost().getHostAddress();
		}
	} else { // HTTP Engine V1
		serverSocketChannel = ServerSocketChannel.open();

		serverSocket = serverSocketChannel.socket();
		serverSocket.setReuseAddress(true);
		serverSocket.bind(address);

		if (hostname == null && iafinal != null) {
			hostname = iafinal.getHostAddress();
		} else if (hostname == null) {
			hostname = InetAddress.getLocalHost().getHostAddress();
		}

		runnable = new Thread(this, "HTTPv1 Request Handler");
		runnable.setDaemon(false);
		runnable.start();
	}

	return true;
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:78,代碼來源:HTTPServer.java

示例11: afterPropertiesSet

import org.jboss.netty.channel.group.DefaultChannelGroup; //導入方法依賴的package包/類
public void afterPropertiesSet() throws Exception {
    cache = new SpaceCache(space);
    channelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());

    allChannels = new DefaultChannelGroup("memcachedChannelGroup");

    ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);

    ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(new UnifiedProtocolDecoder(cache, allChannels, memcachedVersion, idleTime, false, threaded));
        }
    };
    if ("binary".equalsIgnoreCase(protocol)) {
        pipelineFactory = createMemcachedBinaryPipelineFactory(cache, memcachedVersion, false, idleTime, allChannels);
    } else if ("text".equalsIgnoreCase(protocol)) {
        pipelineFactory = createMemcachedPipelineFactory(cache, memcachedVersion, false, idleTime, frameSize, allChannels);
    }

    bootstrap.setPipelineFactory(pipelineFactory);
    bootstrap.setOption("sendBufferSize", 65536);
    bootstrap.setOption("receiveBufferSize", 65536);

    InetAddress address = null;
    if (host != null) {
        address = InetAddress.getByName(host);
    }

    Exception lastException = null;
    boolean success = false;
    int i;
    for (i = 0; i < portRetries; i++) {
        try {
            Channel serverChannel = bootstrap.bind(new InetSocketAddress(address, port + i));
            allChannels.add(serverChannel);
            success = true;
            break;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (!success) {
        throw lastException;
    }
    boundedPort = port + i;
    logger.info("memcached started on port [" + boundedPort + "]");
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:48,代碼來源:MemCacheDaemon.java


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