当前位置: 首页>>代码示例>>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;未经允许,请勿转载。