Java 类org.jboss.netty.channel.group.DefaultChannelGroup 实例源码

项目:athena    文件:Controller.java   
/**
 * 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);
    }

}
项目:athena    文件:Controller.java   
/**
 * 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);
    }
}
项目:iTAP-controller    文件:Bootstrap.java   
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);
}
项目:iTAP-controller    文件:OFSwitchManager.java   
/**
 * 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);
    }
}
项目:QoS-floodlight    文件:Bootstrap.java   
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);
}
项目:incubator-omid    文件:ProgrammableTSOServer.java   
@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);
}
项目:fast-failover-demo    文件:Bootstrap.java   
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);
}
项目:fast-failover-demo    文件:OFSwitchManager.java   
/**
 * 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);
    }
}
项目:ravikumaran201504    文件:Controller.java   
/**
 * 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);
    }

}
项目:floodlightLB    文件:Bootstrap.java   
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);
}
项目:floodlightLB    文件:OFSwitchManager.java   
/**
 * 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);
    }
}
项目:DSC    文件:Bootstrap.java   
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);
}
项目:DSC    文件:OFSwitchManager.java   
/**
 * 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);
    }
}
项目:floodlight_with_topoguard    文件:Bootstrap.java   
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);
}
项目:floodlight    文件:Bootstrap.java   
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);
}
项目:floodlight    文件:OFSwitchManager.java   
/**
 * 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);
    }
}
项目:tightrope    文件:LoadBalancer.java   
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");
    }
}
项目:FloodligtModule    文件:Bootstrap.java   
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);
}
项目:pinpoint    文件:HealthCheckManagerTest.java   
@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();
    }
}
项目:multicastSDN    文件:Bootstrap.java   
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);
}
项目:onos    文件:Controller.java   
/**
 * 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);
    }
}
项目:httptunnel    文件:HttpTunnelSoakTester.java   
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();
}
项目:athena    文件:Controller.java   
/**
 * 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);
    }
}
项目:NithPointsj    文件:PeerGroup.java   
/**
 * <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>();
}
项目:ikasoa    文件:NettyIkasoaFactory.java   
public NettyIkasoaFactory(NettyServerConfig nettyServerConfig, ChannelGroup channelGroup) {
    this.nettyServerConfig = nettyServerConfig;
    if (channelGroup == null)
        this.channelGroup = new DefaultChannelGroup();
    else
        this.channelGroup = channelGroup;
}
项目:hadooparchitecturebook    文件:EventClient.java   
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();
  }
}
项目:BJAF3.x    文件:ServiceServer.java   
public ServiceServer(int port) {
    this.port = port;
    this.channelGroup = new DefaultChannelGroup();
    bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
            Executors.newCachedThreadPool(new NamedThreadFactory(
                    "ServiceServer-bossExecutor-", false)),
            Executors.newCachedThreadPool(new NamedThreadFactory(
                    "ServiceServer-workerExecutor-", true))));
    bootstrap.setOption("tcpNoDelay", Boolean.parseBoolean(AppProperties
            .get("rpc_server_tcpNoDelay", "true")));
    bootstrap.setOption("reuseAddress", Boolean.parseBoolean(AppProperties
            .get("rpc_server_reuseAddress", "true")));
    String c1 = AppProperties.get("rpc_server_child_tcpNoDelay");
    if (c1 != null && c1.trim().length() > 0) {
        bootstrap.setOption("child.tcpNoDelay", Boolean.parseBoolean(c1));
    }
    c1 = AppProperties.get("rpc_server_child_receiveBufferSize");
    if (c1 != null && c1.trim().length() > 0) {
        bootstrap
                .setOption("child.receiveBufferSize", Integer.parseInt(c1));
    }
    this.taskThreadPool = new TaskThreadPool(AppProperties.getAsInt(
            "rpc_server_workThreadPool_coreSize", 50),
            AppProperties
                    .getAsInt("rpc_server_workThreadPool_MaxSize", 200),
            AppProperties.getAsInt(
                    "rpc_server_workThreadPool_keepAliveTime",
                    60 * 1000 * 5), true, new CallerRunsPolicy());
}
项目:Android-Airplay-Server    文件:AirPlayServer.java   
private AirPlayServer(){
    //create executor service
    executorService = Executors.newCachedThreadPool();

    //create channel execution handler
    channelExecutionHandler = new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(4, 0, 0));

    //channel group
    channelGroup = new DefaultChannelGroup();

    //list of mDNS services
    jmDNSInstances = new java.util.LinkedList<JmDNS>();
}
项目:Camel    文件:SingleUDPNettyServerBootstrapFactory.java   
public void init(CamelContext camelContext, NettyServerBootstrapConfiguration configuration, ChannelPipelineFactory pipelineFactory) {
    this.camelContext = camelContext;
    this.configuration = configuration;
    this.pipelineFactory = pipelineFactory;

    this.allChannels = configuration.getChannelGroup() != null
        ? configuration.getChannelGroup()
        : new DefaultChannelGroup(SingleUDPNettyServerBootstrapFactory.class.getName());
}
项目:Camel    文件:SingleUDPNettyServerBootstrapFactory.java   
public void init(ThreadFactory threadFactory, NettyServerBootstrapConfiguration configuration, ChannelPipelineFactory pipelineFactory) {
    this.threadFactory = threadFactory;
    this.configuration = configuration;
    this.pipelineFactory = pipelineFactory;

    this.allChannels = configuration.getChannelGroup() != null
        ? configuration.getChannelGroup()
        : new DefaultChannelGroup(SingleUDPNettyServerBootstrapFactory.class.getName());
}
项目:Camel    文件:SingleTCPNettyServerBootstrapFactory.java   
public void init(CamelContext camelContext, NettyServerBootstrapConfiguration configuration, ChannelPipelineFactory pipelineFactory) {
    this.camelContext = camelContext;
    this.configuration = configuration;
    this.pipelineFactory = pipelineFactory;

    this.allChannels = configuration.getChannelGroup() != null
        ? configuration.getChannelGroup()
        : new DefaultChannelGroup(SingleTCPNettyServerBootstrapFactory.class.getName());
}
项目:Camel    文件:SingleTCPNettyServerBootstrapFactory.java   
public void init(ThreadFactory threadFactory, NettyServerBootstrapConfiguration configuration, ChannelPipelineFactory pipelineFactory) {
    this.threadFactory = threadFactory;
    this.configuration = configuration;
    this.pipelineFactory = pipelineFactory;

    this.allChannels = configuration.getChannelGroup() != null
        ? configuration.getChannelGroup()
        : new DefaultChannelGroup(SingleTCPNettyServerBootstrapFactory.class.getName());
}
项目:jmemcache-daemon    文件:MemcachedPipelineFactory.java   
public MemcachedPipelineFactory(Cache cache, String version, boolean verbose, int idleTime, int frameSize, DefaultChannelGroup channelGroup) {
    this.cache = cache;
    this.version = version;
    this.verbose = verbose;
    this.idleTime = idleTime;
    this.frameSize = frameSize;
    this.channelGroup = channelGroup;
    memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup);
}
项目:jmemcache-daemon    文件:MemCacheDaemon.java   
/**
 * 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;
}
项目:xap-openspaces    文件:UnifiedProtocolDecoder.java   
public UnifiedProtocolDecoder(SpaceCache cache, DefaultChannelGroup channelGroup, String version, int idle_limit, boolean verbose,
                              boolean threaded) {
    this.cache = cache;
    this.channelGroup = channelGroup;
    this.version = version;
    this.idle_limit = idle_limit;
    this.verbose = verbose;
    this.threaded = threaded;
}
项目:xap-openspaces    文件:MemcachedPipelineFactory.java   
public MemcachedPipelineFactory(SpaceCache cache, String version, boolean verbose, int idleTime, int frameSize, DefaultChannelGroup channelGroup) {
    this.cache = cache;
    this.version = version;
    this.verbose = verbose;
    this.idleTime = idleTime;
    this.frameSize = frameSize;
    this.channelGroup = channelGroup;
    memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup);
}
项目:fqueue    文件:MemcachedPipelineFactory.java   
public MemcachedPipelineFactory(Cache cache, String version,
        boolean verbose, int idleTime, int frameSize,
        DefaultChannelGroup channelGroup) {
    this.cache = cache;
    this.version = version;
    this.verbose = verbose;
    this.idleTime = idleTime;
    this.frameSize = frameSize;
    this.channelGroup = channelGroup;
    memcachedCommandHandler = new MemcachedCommandHandler(this.cache,
            this.version, this.verbose, this.idleTime, this.channelGroup);
}
项目:fqueue    文件:MemcachedBinaryPipelineFactory.java   
public MemcachedBinaryPipelineFactory(Cache cache, String version, boolean verbose, int idleTime, DefaultChannelGroup channelGroup) {
    this.cache = cache;
    this.version = version;
    this.verbose = verbose;
    this.idleTime = idleTime;
    this.channelGroup = channelGroup;
    memcachedCommandHandler = new MemcachedCommandHandler(this.cache, this.version, this.verbose, this.idleTime, this.channelGroup);
}
项目:fqueue    文件:MemCacheDaemon.java   
/**
 * 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;
}
项目:incubator-tajo    文件:HttpDataServer.java   
public HttpDataServer(final InetSocketAddress addr, 
    final DataRetriever retriever) {
  this.addr = addr;
  this.factory = new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool(),
      Runtime.getRuntime().availableProcessors() * 2);

  // Configure the server.
  this.bootstrap = new ServerBootstrap(factory);
  // Set up the event pipeline factory.
  this.bootstrap.setPipelineFactory(
      new HttpDataServerPipelineFactory(retriever));    
  this.channelGroup = new DefaultChannelGroup();
}