bootstrap.setPipelineFactory(new HttpClientPipelineFactory());
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.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws Exception {
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(); }
synchronized (bootstrap) bootstrap.setPipelineFactory(pipelineFactory); future = bootstrap.connect(serverAddress); future.addListener(new ChannelFutureListener()
@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; } }); }
bootstrap.setPipelineFactory(new TerasologyClientPipelineFactory(this)); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("keepAlive", true);
URLParamType.maxContentLength.getIntValue()); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() {
wsProcessor = new Processor(config, this, requestSender, wsProtocol); plainBootstrap.setPipelineFactory(new ChannelPipelineFactory() { webSocketBootstrap.setPipelineFactory(new ChannelPipelineFactory() { secureBootstrap.setPipelineFactory(new ChannelPipelineFactory() { secureWebSocketBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
/** * 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; }
protected ChannelFuture createChannel() { // Configure the client. bootstrap = new ClientBootstrap(factory); // Set up the event pipeline factory. bootstrap.setPipelineFactory(new BucketMonitorPipelineFactory()); // Start the connection attempt. return bootstrap.connect(new InetSocketAddress(host, port)); }
private void createBootStrap() { bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); bootstrap.setPipelineFactory(createPipelineFactory()); }
public static void main(String args[]) { // Client服务启动器 ClientBootstrap bootstrap = new ClientBootstrap( new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); // 设置一个处理服务端消息和各种消息事件的类(Handler) bootstrap.setPipelineFactory(() -> Channels.pipeline(new HelloClientHandler())); // 连接到本地的8000端口的服务端 bootstrap.connect(new InetSocketAddress("127.0.0.1", 8000)); }
/** * Create a server for this cluster. * @param cluster */ public GossipServer(GossipCluster cluster) { this.cluster = cluster; serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(8))); serverBootstrap.setPipelineFactory(new GossipPipelineFactory(cluster,false)); clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(8))); clientBootstrap.setPipelineFactory(new GossipPipelineFactory(cluster,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(); }
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 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)); }
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 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(); }