Examples of ClientBootstrap


Examples of org.jboss.netty.bootstrap.ClientBootstrap

      init();
   }

   private void init() {
      // Configure the client.
      ClientBootstrap bootstrap = new ClientBootstrap(
            new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));

      // Set up the event pipeline factory.
      bootstrap.setPipelineFactory(new HotrodClientPipelaneFactory(decoder));

      // Start the connection attempt.
      ChannelFuture future = bootstrap.connect(serverAddress);

      // Wait until the connection attempt succeeds or fails.
      channel = future.awaitUninterruptibly().getChannel();
      if (!future.isSuccess()) {
         bootstrap.releaseExternalResources();
         throw new TransportException("Could not create netty transport", future.getCause());
      }
   }
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

        flushCheckInterval = Utils.getInt(storm_conf.get(Config.STORM_NETTY_FLUSH_CHECK_INTERVAL_MS), 10); // default 10 ms

        LOG.info("New Netty Client, connect to " + host + ", " + port
                + ", config: " + ", buffer_size: " + buffer_size);

        bootstrap = new ClientBootstrap(factory);
        bootstrap.setOption("tcpNoDelay", true);
        bootstrap.setOption("sendBufferSize", buffer_size);
        bootstrap.setOption("keepAlive", true);

        // Set up the pipeline factory.
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

        this.address = address;
        this.factory = factory;
        this.dispatcher = new Dispatcher();
        this.name = name;

        ClientBootstrap bootstrap = factory.newBootstrap();
        ProtocolOptions protocolOptions = factory.configuration.getProtocolOptions();
        ProtocolVersion protocolVersion = factory.protocolVersion == null ? ProtocolVersion.NEWEST_SUPPORTED : factory.protocolVersion;
        bootstrap.setPipelineFactory(new PipelineFactory(this, protocolVersion, protocolOptions.getCompression().compressor, protocolOptions.getSSLOptions()));

        ChannelFuture future = bootstrap.connect(address);

        writer.incrementAndGet();
        try {
            // Wait until the connection attempt succeeds or fails.
            this.channel = future.awaitUninterruptibly().getChannel();
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

        public long getReadTimeoutMillis() {
            return configuration.getSocketOptions().getReadTimeoutMillis();
        }

        private ClientBootstrap newBootstrap() {
            ClientBootstrap b = new ClientBootstrap(channelFactory);

            SocketOptions options = configuration.getSocketOptions();

            b.setOption("connectTimeoutMillis", options.getConnectTimeoutMillis());
            Boolean keepAlive = options.getKeepAlive();
            if (keepAlive != null)
                b.setOption("keepAlive", keepAlive);
            Boolean reuseAddress = options.getReuseAddress();
            if (reuseAddress != null)
                b.setOption("reuseAddress", reuseAddress);
            Integer soLinger = options.getSoLinger();
            if (soLinger != null)
                b.setOption("soLinger", soLinger);
            Boolean tcpNoDelay = options.getTcpNoDelay();
            if (tcpNoDelay != null)
                b.setOption("tcpNoDelay", tcpNoDelay);
            Integer receiveBufferSize = options.getReceiveBufferSize();
            if (receiveBufferSize != null)
                b.setOption("receiveBufferSize", receiveBufferSize);
            Integer sendBufferSize = options.getSendBufferSize();
            if (sendBufferSize != null)
                b.setOption("sendBufferSize", sendBufferSize);

            return b;
        }
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

   @Override
   public void start(CoprocessorEnvironment e) throws IOException {
      System.out.println("Starting compacter");
      Configuration conf = e.getConfiguration();
      factory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor, 3);
      bootstrap = new ClientBootstrap(factory);

      bootstrap.getPipeline().addLast("decoder", new ObjectDecoder());
      bootstrap.getPipeline().addLast("handler", new Handler());
      bootstrap.setOption("tcpNoDelay", false);
      bootstrap.setOption("keepAlive", true);
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

      // Start client with Nb of active threads = 3 as maximum.
      factory = new NioClientSocketChannelFactory(Executors
                                                  .newCachedThreadPool(), Executors.newCachedThreadPool(), 3);
      // Create the bootstrap
      bootstrap = new ClientBootstrap(factory);
     
      int executorThreads = conf.getInt("tso.executor.threads", 3);

      bootstrap.getPipeline().addLast("executor", new ExecutionHandler(
            new OrderedMemoryAwareThreadPoolExecutor(executorThreads, 1024*1024, 4*1024*1024)));
 
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

    }

    protected void establishConnection() throws IOException
    {
        // Configure the client.
        bootstrap = new ClientBootstrap(
                        new NioClientSocketChannelFactory(
                            Executors.newCachedThreadPool(),
                            Executors.newCachedThreadPool()));

        bootstrap.setOption("tcpNoDelay", true);
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

    protected ChannelFuture openConnection() throws Exception {
        ChannelFuture answer;

        if (isTcp()) {
            // its okay to create a new bootstrap for each new channel
            ClientBootstrap clientBootstrap = new ClientBootstrap(channelFactory);
            clientBootstrap.setOption("keepAlive", configuration.isKeepAlive());
            clientBootstrap.setOption("tcpNoDelay", configuration.isTcpNoDelay());
            clientBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
            clientBootstrap.setOption("connectTimeoutMillis", configuration.getConnectTimeout());

            // set any additional netty options
            if (configuration.getOptions() != null) {
                for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
                    clientBootstrap.setOption(entry.getKey(), entry.getValue());
                }
            }

            // set the pipeline factory, which creates the pipeline for each newly created channels
            clientBootstrap.setPipelineFactory(pipelineFactory);
            answer = clientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
            if (LOG.isDebugEnabled()) {
                LOG.debug("Created new TCP client bootstrap connecting to {}:{} with options: {}",
                        new Object[]{configuration.getHost(), configuration.getPort(), clientBootstrap.getOptions()});
            }
            return answer;
        } else {
            // its okay to create a new bootstrap for each new channel
            ConnectionlessBootstrap connectionlessClientBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

  public void init(InetSocketAddress addr, ChannelPipelineFactory pipeFactory, ClientSocketChannelFactory factory)
      throws IOException {
    try {

      this.bootstrap = new ClientBootstrap(factory);
      this.bootstrap.setPipelineFactory(pipeFactory);
      // TODO - should be configurable
      this.bootstrap.setOption("connectTimeoutMillis", 10000);
      this.bootstrap.setOption("connectResponseTimeoutMillis", 10000);
      this.bootstrap.setOption("receiveBufferSize", 1048576 * 10);
 
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

    protected ChannelFuture openConnection() throws Exception {
        ChannelFuture answer;

        if (isTcp()) {
            // its okay to create a new bootstrap for each new channel
            ClientBootstrap clientBootstrap = new ClientBootstrap(channelFactory);
            clientBootstrap.setOption("keepAlive", configuration.isKeepAlive());
            clientBootstrap.setOption("tcpNoDelay", configuration.isTcpNoDelay());
            clientBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
            clientBootstrap.setOption("connectTimeoutMillis", configuration.getConnectTimeout());

            // set any additional netty options
            if (configuration.getOptions() != null) {
                for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
                    clientBootstrap.setOption(entry.getKey(), entry.getValue());
                }
            }

            // set the pipeline factory, which creates the pipeline for each newly created channels
            clientBootstrap.setPipelineFactory(pipelineFactory);
            answer = clientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
            if (LOG.isDebugEnabled()) {
                LOG.debug("Created new TCP client bootstrap connecting to {}:{} with options: {}",
                        new Object[]{configuration.getHost(), configuration.getPort(), clientBootstrap.getOptions()});
            }
            return answer;
        } else {
            // its okay to create a new bootstrap for each new channel
            ConnectionlessBootstrap connectionlessClientBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.