当前位置: 首页>>代码示例>>Java>>正文


Java ChannelPipeline类代码示例

本文整理汇总了Java中org.jboss.netty.channel.ChannelPipeline的典型用法代码示例。如果您正苦于以下问题:Java ChannelPipeline类的具体用法?Java ChannelPipeline怎么用?Java ChannelPipeline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChannelPipeline类属于org.jboss.netty.channel包,在下文中一共展示了ChannelPipeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doOpen

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@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", getTimeout());
    final NettyHandler nettyHandler = new NettyHandler(getUrl(), this);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        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;
        }
    });
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:22,代码来源:NettyClient.java

示例2: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
    BootstrapChannelHandler handler = 
            new BootstrapChannelHandler(bootstrap);
    ChannelPipeline pipeline = Channels.pipeline();

    pipeline.addLast("frameDecoder",
                     new ThriftFrameDecoder(maxFrameSize));
    pipeline.addLast("frameEncoder",
                     new ThriftFrameEncoder());
    pipeline.addLast("timeout",
                     new BootstrapTimeoutHandler(timer, 10));

    pipeline.addLast("handler", handler);

    return pipeline;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:BootstrapPipelineFactory.java

示例3: NettyServerCnxnFactory

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
NettyServerCnxnFactory() {
    bootstrap = new ServerBootstrap(
            new NioServerSocketChannelFactory(
                    Executors.newCachedThreadPool(),
                    Executors.newCachedThreadPool()));
    // parent channel
    bootstrap.setOption("reuseAddress", true);
    // child channels
    bootstrap.setOption("child.tcpNoDelay", true);
    /* set socket linger to off, so that socket close does not block */
    bootstrap.setOption("child.soLinger", -1);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline p = Channels.pipeline();
            if (secure) {
                initSSL(p);
            }
            p.addLast("servercnxnfactory", channelHandler);

            return p;
        }
    });
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:25,代码来源:NettyServerCnxnFactory.java

示例4: initTrackerServers

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            boolean full = Context.getConfig().getBoolean(getName() + ".extended");
            if (full) {
                pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); // tracker bug \n\r
            } else {
                pipeline.addLast("frameDecoder", new XexunFrameDecoder());
            }
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("objectEncoder", new XexunProtocolEncoder());
            pipeline.addLast("objectDecoder", new XexunProtocolDecoder(XexunProtocol.this, full));
        }
    });
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:19,代码来源:XexunProtocol.java

示例5: initTrackerServers

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
            pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
        }
    };
    server.setEndianness(ByteOrder.LITTLE_ENDIAN);
    serverList.add(server);
    server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
            pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
        }
    };
    server.setEndianness(ByteOrder.LITTLE_ENDIAN);
    serverList.add(server);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:25,代码来源:MeitrackProtocol.java

示例6: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
    BgpChannelHandler handler = new BgpChannelHandler(bgpController);

    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("bgpmessagedecoder", new BgpMessageDecoder());
    pipeline.addLast("bgpmessageencoder", new BgpMessageEncoder());
    pipeline.addLast("holdTime", readTimeoutHandler);
    if (isBgpServ) {
        pipeline.addLast("PassiveHandler", handler);
    } else {
        pipeline.addLast("ActiveHandler", handler);
    }

    return pipeline;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:BgpPipelineFactory.java

示例7: initTrackerServers

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
            pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
        }
    };
    server.setEndianness(ByteOrder.LITTLE_ENDIAN);
    serverList.add(server);

    server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
        }
    };
    server.setEndianness(ByteOrder.LITTLE_ENDIAN);
    serverList.add(server);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:22,代码来源:CastelProtocol.java

示例8: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
    RemoteSyncChannelHandler channelHandler = 
            new RemoteSyncChannelHandler(syncManager);
    ChannelPipeline pipeline = Channels.pipeline();

    pipeline.addLast("frameDecoder",
                     new ThriftFrameDecoder(maxFrameSize));
    pipeline.addLast("frameEncoder",
                     new ThriftFrameEncoder());
    pipeline.addLast("timeout",
                     new RSHandshakeTimeoutHandler(channelHandler,
                                                   timer, 3));

    pipeline.addLast("handler", channelHandler);
    return pipeline;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:RemoteSyncPipelineFactory.java

示例9: getPipeline

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  if (sslFactory != null) {
    pipeline.addLast("ssl", new SslHandler(sslFactory.createSSLEngine()));
  }
  pipeline.addLast("decoder", new HttpRequestDecoder());
  pipeline.addLast("aggregator", new HttpChunkAggregator(1 << 16));
  pipeline.addLast("encoder", new HttpResponseEncoder());
  pipeline.addLast("chunking", new ChunkedWriteHandler());
  pipeline.addLast("shuffle", SHUFFLE);
  return pipeline;
  // TODO factor security manager into pipeline
  // TODO factor out encode/decode to permit binary shuffle
  // TODO factor out decode of index to permit alt. models
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ShuffleHandler.java

示例10: initTrackerServers

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(4 * 1024));
            pipeline.addLast("stringEncoder", new StringEncoder());
            boolean utf8 = Context.getConfig().getBoolean(getName() + ".utf8");
            if (utf8) {
                pipeline.addLast("stringDecoder", new StringDecoder(StandardCharsets.UTF_8));
            } else {
                pipeline.addLast("stringDecoder", new StringDecoder());
            }
            pipeline.addLast("objectEncoder", new WialonProtocolEncoder());
            pipeline.addLast("objectDecoder", new WialonProtocolDecoder(WialonProtocol.this));
        }
    });
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:19,代码来源:WialonProtocol.java

示例11: startHttpServer

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
private ServerBootstrap startHttpServer(int port,
    final Token<DelegationTokenIdentifier> token, final URI url) {
  ServerBootstrap bootstrap = new ServerBootstrap(
      new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
          Executors.newCachedThreadPool()));

  bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new HttpRequestDecoder(),
          new HttpChunkAggregator(65536), new HttpResponseEncoder(),
          new CredentialsLogicHandler(token, url.toString()));
    }
  });
  bootstrap.bind(new InetSocketAddress("localhost", port));
  return bootstrap;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestDelegationTokenRemoteFetcher.java

示例12: connectFrom

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
private Channel connectFrom(InetSocketAddress connectToSocket, SocketAddress localAddress)
     throws InterruptedException {

     ChannelFactory channelFactory =
         new NioClientSocketChannelFactory(
                 Executors.newCachedThreadPool(),
                 Executors.newCachedThreadPool());
     ChannelPipelineFactory pipelineFactory = () -> {
         ChannelPipeline pipeline = Channels.pipeline();
         pipeline.addLast("BgpPeerFrameDecoderTest",
                 peerFrameDecoder);
         pipeline.addLast("BgpPeerChannelHandlerTest",
                 peerChannelHandler);
         return pipeline;
     };

     peerBootstrap = new ClientBootstrap(channelFactory);
     peerBootstrap.setOption("child.keepAlive", true);
     peerBootstrap.setOption("child.tcpNoDelay", true);
     peerBootstrap.setPipelineFactory(pipelineFactory);
     Channel channel = peerBootstrap.connect(connectToSocket, localAddress).getChannel();
     return channel;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:BgpControllerImplTest.java

示例13: open

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
/**
	 * @param connectStatus 心跳检测状态是否正常
	 * @throws Throwable
	 */
	public void open(boolean connectStatus) throws Throwable {
		logger.info("open start,"+getConnStr());
		bootstrap = new ClientBootstrap(factory);
//		timer = new HashedWheelTimer();
		{
			bootstrap.setOption("tcpNoDelay", Boolean.parseBoolean(clientConfig.getTcpNoDelay()));
			bootstrap.setOption("reuseAddress", Boolean.parseBoolean(clientConfig.getReuseAddress()));
			bootstrap.setOption("SO_RCVBUF",1024*128);
			bootstrap.setOption("SO_SNDBUF",1024*128);
			bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
				public ChannelPipeline getPipeline() {
					ChannelPipeline pipeline = Channels.pipeline();
//					int readTimeout = clientConfig.getReadTimeout();
//					if (readTimeout > 0) {
//						pipeline.addLast("timeout", new ReadTimeoutHandler(timer,
//								readTimeout, TimeUnit.MILLISECONDS));
//					}
					pipeline.addLast("encoder", new RpcRequestEncode());
					pipeline.addLast("decoder", new RpcResponseDecode());
					pipeline.addLast("handler", NettyRpcConnection.this);
					return pipeline;
				}
			});
		}
		connected.set(connectStatus);
		logger.info("open finish,"+getConnStr());
	}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:32,代码来源:NettyRpcConnection.java

示例14: initTrackerServers

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new IntellitracFrameDecoder(1024));
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("objectDecoder", new IntellitracProtocolDecoder(IntellitracProtocol.this));
        }
    });
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:13,代码来源:IntellitracProtocol.java

示例15: initTrackerServers

import org.jboss.netty.channel.ChannelPipeline; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new HuabaoFrameDecoder());
            pipeline.addLast("objectEncoder", new HuabaoProtocolEncoder());
            pipeline.addLast("objectDecoder", new HuabaoProtocolDecoder(HuabaoProtocol.this));
        }
    });
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:12,代码来源:HuabaoProtocol.java


注:本文中的org.jboss.netty.channel.ChannelPipeline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。