Java Code Examples for org.jboss.netty.channel.Channels#pipeline()

The following examples show how to use org.jboss.netty.channel.Channels#pipeline() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BootstrapPipelineFactory.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: OpenflowPipelineFactory.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    OFChannelHandler handler = new OFChannelHandler(controller);
    
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("ofmessagedecoder", new OFMessageDecoder());
    pipeline.addLast("ofmessageencoder", new OFMessageEncoder());
    pipeline.addLast("idle", idleHandler);
    pipeline.addLast("timeout", readTimeoutHandler);
    pipeline.addLast("handshaketimeout",
                     new HandshakeTimeoutHandler(handler, timer, 15));
    if (pipelineExecutor != null)
        pipeline.addLast("pipelineExecutor",
                         new ExecutionHandler(pipelineExecutor));
    pipeline.addLast("handler", handler);
    return pipeline;
}
 
Example 3
Source File: RemoteSyncPipelineFactory.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 4
Source File: ShuffleHandler.java    From tez with Apache License 2.0 6 votes vote down vote up
@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);
  pipeline.addLast("idle", idleStateHandler);
  pipeline.addLast(TIMEOUT_HANDLER, new TimeoutHandler());
  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
}
 
Example 5
Source File: HttpInvoker.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("codec", new HttpClientCodec());
    pipeline.addLast("aggregator", new HttpChunkAggregator(settings.getAsInt("http.client.maxchunksize", 10 * 1024 * 1024)));
    pipeline.addLast("inflater", new HttpContentDecompressor());
    pipeline.addLast("handler", new HttpInvoker.HttpResponseHandler());
    return pipeline;
}
 
Example 6
Source File: ShuffleHandler.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  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
}
 
Example 7
Source File: IsisPipelineFactory.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("encoder", new IsisMessageDecoder());
    pipeline.addLast("decoder", new IsisMessageEncoder());
    pipeline.addLast("handler", isisChannelHandler);

    return pipeline;
}
 
Example 8
Source File: TimestampPipelineFactoryLite.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    SpliceLogUtils.debug(LOG, "Creating new channel pipeline...");
    ChannelPipeline pipeline = Channels.pipeline();
    ((TimestampServerHandler) tsHandler).initializeIfNeeded();
    pipeline.addLast("decoder", new FixedLengthFrameDecoder(TimestampServer.FIXED_MSG_RECEIVED_LENGTH));
    pipeline.addLast("handler", tsHandler);
    SpliceLogUtils.debug(LOG, "Done creating channel pipeline");
    return pipeline;
}
 
Example 9
Source File: MemcachedPipelineFactory.java    From fqueue with Apache License 2.0 5 votes vote down vote up
public final ChannelPipeline getPipeline() throws Exception {
	SessionStatus status = new SessionStatus().ready();

	return Channels.pipeline(new MemcachedFrameDecoder(status, frameSize),
			new MemcachedCommandDecoder(status), memcachedCommandHandler,
			memcachedResponseEncoder);
}
 
Example 10
Source File: UdpWorker.java    From parallec with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() {

    // cannot have the DelimiterBasedFrameDecoder! does not work with
    // UDP; make packet missing.
    ChannelPipeline pipeline = Channels.pipeline();
    // ORDER matters!!! put the channdler first
    pipeline.addLast("idleTimer", idleStateHandler);
    pipeline.addLast("idleHandler", myIdleHandler);
    pipeline.addLast("stringDecoder", UdpMeta.stringDecoder);
    pipeline.addLast("stringEncoder", UdpMeta.stringEncoder);
    pipeline.addLast("UDPUpstreamHandler", new UdpChannelHandler(
            udpWorker));
    return pipeline;
}
 
Example 11
Source File: RpcTestUtils.java    From mt-flume with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  ZlibEncoder encoder = new ZlibEncoder(6);
  pipeline.addFirst("deflater", encoder);
  pipeline.addFirst("inflater", new ZlibDecoder());
  return pipeline;
}
 
Example 12
Source File: FakeCarbonPipelineFactory.java    From vmstats with Apache License 2.0 5 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
    // this is pretty verbose from the netty examples
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast("decoder", new StringDecoder());
    pipeline.addLast("encoder", new StringEncoder());
    pipeline.addLast("handler", new FakeCarbonHandler(appConfig));
    return pipeline;
}
 
Example 13
Source File: ServerCodecPipelineFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline newPipeline() {
    ChannelPipeline pipeline = Channels.pipeline();

    pipeline.addLast("decoder", new ServerPacketDecoder());
    pipeline.addLast("encoder", new PacketEncoder());

    return pipeline;
}
 
Example 14
Source File: FpmManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private void startServer() {
    HashedWheelTimer timer = new HashedWheelTimer(
            groupedThreads("onos/fpm", "fpm-timer-%d", log));

    ChannelFactory channelFactory = new NioServerSocketChannelFactory(
            newCachedThreadPool(groupedThreads("onos/fpm", "sm-boss-%d", log)),
            newCachedThreadPool(groupedThreads("onos/fpm", "sm-worker-%d", log)));
    ChannelPipelineFactory pipelineFactory = () -> {
        // Allocate a new session per connection
        IdleStateHandler idleHandler =
                new IdleStateHandler(timer, IDLE_TIMEOUT_SECS, 0, 0);
        FpmSessionHandler fpmSessionHandler =
                new FpmSessionHandler(this, new InternalFpmListener());
        FpmFrameDecoder fpmFrameDecoder = new FpmFrameDecoder();

        // Setup the processing pipeline
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast("FpmFrameDecoder", fpmFrameDecoder);
        pipeline.addLast("idle", idleHandler);
        pipeline.addLast("FpmSession", fpmSessionHandler);
        return pipeline;
    };

    InetSocketAddress listenAddress = new InetSocketAddress(FPM_PORT);

    serverBootstrap = new ServerBootstrap(channelFactory);
    serverBootstrap.setOption("child.reuseAddr", true);
    serverBootstrap.setOption("child.keepAlive", true);
    serverBootstrap.setOption("child.tcpNoDelay", true);
    serverBootstrap.setPipelineFactory(pipelineFactory);
    try {
        serverChannel = serverBootstrap.bind(listenAddress);
        allChannels.add(serverChannel);
    } catch (ChannelException e) {
        log.debug("Exception binding to FPM port {}: ",
                listenAddress.getPort(), e);
        stopServer();
    }
}
 
Example 15
Source File: StreamPipelineFactory.java    From msgpack-rpc-java with Apache License 2.0 5 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = Channels.pipeline();
    p.addLast("msgpack-decode-stream", new MessagePackStreamDecoder(messagePack));
    p.addLast("msgpack-encode", new MessagePackEncoder(messagePack));
    p.addLast("message", new MessageHandler(handler));
    return p;
}
 
Example 16
Source File: SimpleTcpClient.java    From hadoop with Apache License 2.0 5 votes vote down vote up
protected ChannelPipelineFactory setPipelineFactory() {
  this.pipelineFactory = new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() {
      return Channels.pipeline(
          RpcUtil.constructRpcFrameDecoder(),
          new SimpleTcpClientHandler(request));
    }
  };
  return this.pipelineFactory;
}
 
Example 17
Source File: StormServerPipelineFactory.java    From jstorm with Apache License 2.0 5 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = Channels.pipeline();

    // Decoder
    pipeline.addLast("decoder", new MessageDecoder(true, conf));
    // Encoder
    pipeline.addLast("encoder", new MessageEncoder());
    // business logic.
    pipeline.addLast("handler", new StormServerHandler(server));

    return pipeline;
}
 
Example 18
Source File: MyChannelPipelineFactory.java    From whiteboard with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
	ChannelPipeline pipeline = Channels.pipeline();

	pipeline.addLast("objectencoder", new ObjectEncoder());

	pipeline.addLast("objectdecoder", new ObjectDecoder(ClassResolvers
			.cacheDisabled(this.getClass().getClassLoader())));
	pipeline.addLast("serverhandler", new MyServerHandler());
	return pipeline;
}
 
Example 19
Source File: ServerPipelineFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();

    // ServerPacketDecoder passes the PING related packets(without status value) to the pinpointServerChannelHandler.
    pipeline.addLast("decoder", new ServerPacketDecoder());
    pipeline.addLast("encoder", new PacketEncoder());
    pipeline.addLast("handler", pinpointServerChannelHandler);

    return pipeline;
}
 
Example 20
Source File: BgpSessionManagerTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Starts up the BGP peer and connects it to the tested BgpSessionManager
 * instance.
 *
 * @param connectToSocket the socket to connect to
 */
private void connect(InetSocketAddress connectToSocket)
    throws InterruptedException {
    //
    // Setup the BGP Peer, i.e., the "remote" BGP router that will
    // initiate the BGP connection, send BGP UPDATE messages, etc.
    //
    ChannelFactory channelFactory =
        new NioClientSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool());
    ChannelPipelineFactory pipelineFactory = () -> {
        // Setup the transmitting pipeline
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast("TestBgpPeerFrameDecoder",
                peerFrameDecoder);
        pipeline.addLast("TestBgpPeerChannelHandler",
                peerChannelHandler);
        return pipeline;
    };

    peerBootstrap = new ClientBootstrap(channelFactory);
    peerBootstrap.setOption("child.keepAlive", true);
    peerBootstrap.setOption("child.tcpNoDelay", true);
    peerBootstrap.setPipelineFactory(pipelineFactory);
    peerBootstrap.connect(connectToSocket);

    boolean result;
    // Wait until the OPEN message is received
    result = peerFrameDecoder.receivedOpenMessageLatch.await(
        MESSAGE_TIMEOUT_MS,
        TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
    // Wait until the KEEPALIVE message is received
    result = peerFrameDecoder.receivedKeepaliveMessageLatch.await(
        MESSAGE_TIMEOUT_MS,
        TimeUnit.MILLISECONDS);
    assertThat(result, is(true));

    for (BgpSession bgpSession : bgpSessionManager.getBgpSessions()) {
        if (bgpSession.remoteInfo().bgpId().equals(BGP_PEER1_ID)) {
            bgpSession1 = bgpSession;
        }
        if (bgpSession.remoteInfo().bgpId().equals(BGP_PEER2_ID)) {
            bgpSession2 = bgpSession;
        }
        if (bgpSession.remoteInfo().bgpId().equals(BGP_PEER3_ID)) {
            bgpSession3 = bgpSession;
        }
    }
}