public void start() { bootstrap = new ClientBootstrap(clientChannelFactory); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("reuseAddress", true); bootstrap.setOption("sendBufferSize", bufferSize); bootstrap.setOption("keepAlive", true); // Set up the pipeline factory. bootstrap.setPipelineFactory(new StormClientPipelineFactory(this, stormConf)); reconnect(); }
@Override protected void doOpen() throws Throwable { NettyHelper.setNettyLoggerFactory(); bootstrap = new ClientBootstrap(channelFactory); // config // @see org.jboss.netty.channel.socket.SocketChannelConfig bootstrap.setOption("keepAlive", true); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("connectTimeoutMillis", getConnectTimeout()); final NettyHandler nettyHandler = new NettyHandler(getUrl(), this); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyClient.this); ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", adapter.getDecoder()); pipeline.addLast("encoder", adapter.getEncoder()); pipeline.addLast("handler", nettyHandler); return pipeline; } }); }
@Override protected void doOpen() throws Throwable { NettyHelper.setNettyLoggerFactory(); bootstrap = new ClientBootstrap(channelFactory); // config // @see org.jboss.netty.channel.socket.SocketChannelConfig bootstrap.setOption("keepAlive", true); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("connectTimeoutMillis", getConnectTimeout()); final NettyHandler nettyHandler = new NettyHandler(getUrl(), this); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyClient.this); ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", adapter.getDecoder()); pipeline.addLast("encoder", adapter.getEncoder()); pipeline.addLast("handler", nettyHandler); return pipeline; } }); }
public ServerInfoService() { pool = Executors.newCachedThreadPool(); factory = new NioClientSocketChannelFactory(pool, pool, 1, 1); bootstrap = new ClientBootstrap(factory); bootstrap.setPipelineFactory(new InfoRequestPipelineFactory()); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("keepAlive", true); }
bootstrap.setOption("keepAlive", true); bootstrap.setPipelineFactory(new HttpClientPipelineFactory());
ClientBootstrap bootstrap = new ClientBootstrap(factory); bootstrap.setPipelineFactory(new TerasologyClientPipelineFactory(this)); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("keepAlive", true); ChannelFuture connectCheck = bootstrap.connect(new InetSocketAddress(address, port)); try {
/** * Creates the tcpClient with proper handler. * * @return the bound request builder * @throws HttpRequestCreateException * the http request create exception */ public ClientBootstrap bootStrapTcpClient() throws HttpRequestCreateException { ClientBootstrap tcpClient = null; try { // Configure the client. tcpClient = new ClientBootstrap(tcpMeta.getChannelFactory()); // Configure the pipeline factory. tcpClient.setPipelineFactory(new MyPipelineFactory(TcpUdpSshPingResourceStore.getInstance().getTimer(), this, tcpMeta.getTcpIdleTimeoutSec()) ); tcpClient.setOption("connectTimeoutMillis", tcpMeta.getTcpConnectTimeoutMillis()); tcpClient.setOption("tcpNoDelay", true); // tcpClient.setOption("keepAlive", true); } catch (Exception t) { throw new TcpUdpRequestCreateException( "Error in creating request in Tcpworker. " + " If tcpClient is null. Then fail to create.", t); } return tcpClient; }
/** * Set the default timeout for {@link RedisConnection connections} created by * this client. The timeout applies to connection attempts and non-blocking * commands. * * @param timeout Default connection timeout. * @param unit Unit of time for the timeout. */ public void setDefaultTimeout(long timeout, TimeUnit unit) { this.timeout = timeout; this.unit = unit; bootstrap.setOption("connectTimeoutMillis", unit.toMillis(timeout)); }
public void start() { bootstrap = new ClientBootstrap(clientChannelFactory); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("reuseAddress", true); bootstrap.setOption("sendBufferSize", bufferSize); bootstrap.setOption("keepAlive", true); // Set up the pipeline factory. bootstrap.setPipelineFactory(new StormClientPipelineFactory(this, stormConf)); reconnect(); }
private static ClientBootstrap getBootstrap(final Executor executor, final ClientOptions options) { final ChannelFactory factory = new NioClientSocketChannelFactory(executor, executor); final ClientBootstrap bootstrap = new ClientBootstrap(factory); bootstrap.setPipelineFactory(new ClientPipelineFactory(options)); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("keepAlive", true); return bootstrap; }
private static ClientBootstrap getBootstrap(final Executor executor, final ClientOptions options) { final ChannelFactory factory = new NioClientSocketChannelFactory(executor, executor); final ClientBootstrap bootstrap = new ClientBootstrap(factory); bootstrap.setPipelineFactory(new ClientPipelineFactory(options)); bootstrap.setOption("tcpNoDelay" , true); bootstrap.setOption("keepAlive", true); return bootstrap; }
public void init() { // initialize the connection factory, such as we need create connection pools here. // Configure the client. bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); // Set up the pipeline factory. bootstrap.setPipelineFactory(new DorisClentNettyPipelineFactory()); bootstrap.setOption("connectTimeoutMillis", CONNECT_TIME_OUT_MILLIS); bootstrap.setOption("tcpNoDelay", true); }
public NettyTransport(SenderConfigurer config, ExecutorService executor) { client = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); client.setOption("connectTimeoutMillis", 10000); client.setOption("keepAlive", true); client.setPipelineFactory(new HttpClientPipelineFactory(true)); channels = new DefaultChannelGroup(); }
public TcpClient(final ChannelGroup channelGroup, final Executor executor) { this.channelGroup = channelGroup; channelFactory = new NioClientSocketChannelFactory(executor, executor); channelBufferFactory = new HeapChannelBufferFactory(ByteOrder.LITTLE_ENDIAN); bootstrap = new ClientBootstrap(channelFactory); bootstrap.setOption("bufferFactory", channelBufferFactory); setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT_DURATION, DEFAULT_CONNECTION_TIMEOUT_UNIT); setKeepAlive(DEFAULT_KEEP_ALIVE); namedChannelHandlers = Lists.newArrayList(); }
public void run(Timeout timeout) throws Exception { if (bootstrap instanceof ClientBootstrap) { ClientBootstrap b = (ClientBootstrap) bootstrap; b.setOption("remoteAddress", getRemoteAddress()); b.connect(); } else if (bootstrap instanceof ConnectionlessBootstrap) { ConnectionlessBootstrap b = (ConnectionlessBootstrap) bootstrap; b.setOption("remoteAddress", getRemoteAddress()); b.connect(); } } }, delay.get(), unit);
private NettyTransportHandler(URL url, ChannelPipelineFactory pipelineFactory) { this.url = url; ChannelFactory factory = factoryProvider.getClientSocketChannelFactoryInstance(); ClientBootstrap bootstrap = new ClientBootstrap(factory); bootstrap.setPipelineFactory(pipelineFactory); //Start the connection attempt bootstrap.setOption("tcpNoDelay", true); connectFuture = bootstrap.connect(getSocketAddress(url)); }