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

Controller.java 文件源码 项目:athena 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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);
    }

}
Controller.java 文件源码 项目:athena 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Bootstrap.java 文件源码 项目:iTAP-controller 阅读 28 收藏 0 点赞 0 评论 0
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);
}
OFSwitchManager.java 文件源码 项目:iTAP-controller 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Bootstrap.java 文件源码 项目:QoS-floodlight 阅读 27 收藏 0 点赞 0 评论 0
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);
}
ProgrammableTSOServer.java 文件源码 项目:incubator-omid 阅读 22 收藏 0 点赞 0 评论 0
@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);
}
Bootstrap.java 文件源码 项目:fast-failover-demo 阅读 31 收藏 0 点赞 0 评论 0
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);
}
OFSwitchManager.java 文件源码 项目:fast-failover-demo 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Controller.java 文件源码 项目:ravikumaran201504 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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);
    }

}
Bootstrap.java 文件源码 项目:floodlightLB 阅读 33 收藏 0 点赞 0 评论 0
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);
}
OFSwitchManager.java 文件源码 项目:floodlightLB 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Bootstrap.java 文件源码 项目:DSC 阅读 26 收藏 0 点赞 0 评论 0
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);
}
OFSwitchManager.java 文件源码 项目:DSC 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Bootstrap.java 文件源码 项目:floodlight_with_topoguard 阅读 28 收藏 0 点赞 0 评论 0
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);
}
Bootstrap.java 文件源码 项目:floodlight 阅读 26 收藏 0 点赞 0 评论 0
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);
}
OFSwitchManager.java 文件源码 项目:floodlight 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
LoadBalancer.java 文件源码 项目:tightrope 阅读 32 收藏 0 点赞 0 评论 0
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");
    }
}
Bootstrap.java 文件源码 项目:FloodligtModule 阅读 32 收藏 0 点赞 0 评论 0
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);
}
HealthCheckManagerTest.java 文件源码 项目:pinpoint 阅读 25 收藏 0 点赞 0 评论 0
@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();
    }
}
Bootstrap.java 文件源码 项目:multicastSDN 阅读 34 收藏 0 点赞 0 评论 0
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);
}
Controller.java 文件源码 项目:onos 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
HttpTunnelSoakTester.java 文件源码 项目:httptunnel 阅读 27 收藏 0 点赞 0 评论 0
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();
}
Controller.java 文件源码 项目:athena 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
PeerGroup.java 文件源码 项目:NithPointsj 阅读 23 收藏 0 点赞 0 评论 0
/**
 * <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>();
}
NettyIkasoaFactory.java 文件源码 项目:ikasoa 阅读 24 收藏 0 点赞 0 评论 0
public NettyIkasoaFactory(NettyServerConfig nettyServerConfig, ChannelGroup channelGroup) {
    this.nettyServerConfig = nettyServerConfig;
    if (channelGroup == null)
        this.channelGroup = new DefaultChannelGroup();
    else
        this.channelGroup = channelGroup;
}
EventClient.java 文件源码 项目:hadooparchitecturebook 阅读 22 收藏 0 点赞 0 评论 0
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();
  }
}
ServiceServer.java 文件源码 项目:BJAF3.x 阅读 22 收藏 0 点赞 0 评论 0
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());
}
AirPlayServer.java 文件源码 项目:Android-Airplay-Server 阅读 27 收藏 0 点赞 0 评论 0
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>();
}
SingleUDPNettyServerBootstrapFactory.java 文件源码 项目:Camel 阅读 28 收藏 0 点赞 0 评论 0
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());
}
SingleUDPNettyServerBootstrapFactory.java 文件源码 项目:Camel 阅读 27 收藏 0 点赞 0 评论 0
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());
}


问题


面经


文章

微信
公众号

扫码关注公众号