org.jboss.netty.channel.Channels.pipeline()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.jboss.netty.channel.Channels.pipeline()方法的一些代码示例,展示了Channels.pipeline()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channels.pipeline()方法的具体详情如下:
包路径:org.jboss.netty.channel.Channels
类名称:Channels
方法名:pipeline

Channels.pipeline介绍

[英]Creates a new ChannelPipeline.
[中]创建新的ChannelPipeline。

代码示例

代码示例来源:origin: menacher/java-game-server

static ChannelPipeline init()
{
  ChannelPipeline pipeline = Channels.pipeline();
  pipeline.addLast("eventDecoder", EVENT_DECODER);
  pipeline.addLast("eventEncoder", EVENT_ENCODER);
  pipeline.addLast("UDPUpstreamHandler",UDP_UPSTREAM_HANDLER);
  return pipeline;
}

代码示例来源:origin: menacher/java-game-server

/**
 * This method creates a single pipeline object that will be shared for all
 * the channels.
 */
public void init()
{
  pipeline = pipeline();
  
  pipeline.addLast("messageBufferEventDecoder", messageBufferEventDecoder);
  pipeline.addLast("upstream", upstream);
  
  // Downstream handlers - Filter for data which flows from server to
  // client. Note that the last handler added is actually the first
  // handler for outgoing data.
  pipeline.addLast("messageBufferEventEncoder",messageBufferEventEncoder);
}

代码示例来源:origin: apache/incubator-dubbo

@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;
  }
});

代码示例来源:origin: apache/incubator-dubbo

@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;
  }
});

代码示例来源:origin: weibocom/motan

@Override
  public ChannelPipeline getPipeline() {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("channel_manage", channelManage);
    pipeline.addLast("decoder", new NettyDecoder(codec, NettyServer.this, maxContentLength));
    pipeline.addLast("encoder", new NettyEncoder(codec, NettyServer.this));
    pipeline.addLast("nettyChannelHandler", nettyChannelHandler);
    return pipeline;
  }
});

代码示例来源:origin: apache/incubator-dubbo

@Override
  public ChannelPipeline getPipeline() {
    NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyServer.this);
    ChannelPipeline pipeline = Channels.pipeline();
    /*int idleTimeout = getIdleTimeout();
    if (idleTimeout > 10000) {
      pipeline.addLast("timer", new IdleStateHandler(timer, idleTimeout / 1000, 0, 0));
    }*/
    pipeline.addLast("decoder", adapter.getDecoder());
    pipeline.addLast("encoder", adapter.getEncoder());
    pipeline.addLast("handler", nettyHandler);
    return pipeline;
  }
});

代码示例来源:origin: alibaba/canal

public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipelines = Channels.pipeline();
    pipelines.addLast(FixedHeaderFrameDecoder.class.getName(), new FixedHeaderFrameDecoder());
    // support to maintain child socket channel.
    pipelines.addLast(HandshakeInitializationHandler.class.getName(),
      new HandshakeInitializationHandler(childGroups));
    pipelines.addLast(ClientAuthenticationHandler.class.getName(),
      new ClientAuthenticationHandler(embeddedServer));
    SessionHandler sessionHandler = new SessionHandler(embeddedServer);
    pipelines.addLast(SessionHandler.class.getName(), sessionHandler);
    return pipelines;
  }
});

代码示例来源:origin: apache/incubator-dubbo

@Override
  public ChannelPipeline getPipeline() {
    NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyServer.this);
    ChannelPipeline pipeline = Channels.pipeline();
    /*int idleTimeout = getIdleTimeout();
    if (idleTimeout > 10000) {
      pipeline.addLast("timer", new IdleStateHandler(timer, idleTimeout / 1000, 0, 0));
    }*/
    pipeline.addLast("decoder", adapter.getDecoder());
    pipeline.addLast("encoder", adapter.getEncoder());
    pipeline.addLast("handler", nettyHandler);
    return pipeline;
  }
});

代码示例来源:origin: io.netty/netty

/**
 * Creates a new {@link ChannelPipeline} which contains the same entries
 * with the specified {@code pipeline}.  Please note that only the names
 * and the references of the {@link ChannelHandler}s will be copied; a new
 * {@link ChannelHandler} instance will never be created.
 */
public static ChannelPipeline pipeline(ChannelPipeline pipeline) {
  ChannelPipeline newPipeline = pipeline();
  for (Map.Entry<String, ChannelHandler> e: pipeline.toMap().entrySet()) {
    newPipeline.addLast(e.getKey(), e.getValue());
  }
  return newPipeline;
}

代码示例来源:origin: alibaba/jstorm

public ChannelPipeline getPipeline() throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = Channels.pipeline();

    // Decoder
    pipeline.addLast("decoder", new MessageDecoder(false, conf));
    // Encoder
    pipeline.addLast("encoder", new MessageEncoder());
    // business logic.
    pipeline.addLast("handler", new StormClientHandler(client));

    return pipeline;
  }
}

代码示例来源:origin: menacher/java-game-server

@Override
public ChannelPipeline getPipeline() throws Exception
{
  // Create a default pipeline implementation.
  ChannelPipeline pipeline = pipeline();
  pipeline.addLast("idleStateCheck", new IdleStateHandler(timer, 0, 0,
      MAX_IDLE_SECONDS));
  pipeline.addLast("idleCheckHandler", idleCheckHandler);
  pipeline.addLast("multiplexer", createProtcolMultiplexerDecoder());
  return pipeline;
}

代码示例来源:origin: alibaba/jstorm

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;
  }
}

代码示例来源:origin: io.netty/netty

/**
 * Creates a new {@link ChannelPipeline} which contains the specified
 * {@link ChannelHandler}s.  The names of the specified handlers are
 * generated automatically; the first handler's name is {@code "0"},
 * the second handler's name is {@code "1"}, the third handler's name is
 * {@code "2"}, and so on.
 */
public static ChannelPipeline pipeline(ChannelHandler... handlers) {
  if (handlers == null) {
    throw new NullPointerException("handlers");
  }
  ChannelPipeline newPipeline = pipeline();
  for (int i = 0; i < handlers.length; i ++) {
    ChannelHandler h = handlers[i];
    if (h == null) {
      break;
    }
    newPipeline.addLast(ConversionUtil.toString(i), h);
  }
  return newPipeline;
}

代码示例来源:origin: menacher/java-game-server

@Override
  public ChannelPipeline getPipeline() throws Exception
  {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("lengthDecoder", new LengthFieldBasedFrameDecoder(
        Integer.MAX_VALUE, 0, 2, 0, 2));
    pipeline.addLast("eventDecoder", EVENT_DECODER);
    pipeline.addLast(DefaultToClientHandler.getName(),
        defaultToClientHandler);
    
    // Down stream handlers are added now. Note that the last one added to
    // pipeline is actually the first encoder in the pipeline.
    pipeline.addLast("lengthFieldPrepender", LENGTH_FIELD_PREPENDER);
    pipeline.addLast("eventEncoder", EVENT_ENCODER);
    
    return pipeline;
  }
}

代码示例来源:origin: voldemort/voldemort

@Override
public ChannelPipeline getPipeline() throws Exception {
  // Create a default pipeline implementation.
  ChannelPipeline pipeline = pipeline();
  pipeline.addLast("connectionStats", connectionStatsHandler);
  pipeline.addLast("decoder", new HttpRequestDecoder());
  pipeline.addLast("aggregator", new HttpChunkAggregator(maxHttpContentLength));
  pipeline.addLast("encoder", new HttpResponseEncoder());
  pipeline.addLast("deflater", new HttpContentCompressor());
  pipeline.addLast("handler", new RestServerRequestHandler(storeRepository));
  pipeline.addLast("storageExecutionHandler", storageExecutionHandler);
  return pipeline;
}

代码示例来源:origin: menacher/java-game-server

public ChannelPipeline getPipeline() throws Exception {
  // Create a default pipeline implementation.
  ChannelPipeline pipeline = pipeline();
  pipeline.addLast("timeout", new ReadTimeoutHandler(timer, 30));
  pipeline.addLast("decoder", new FlashPolicyServerDecoder());
  pipeline.addLast("handler", getFlashPolicyServerHandler());
  return pipeline;
}

代码示例来源:origin: apache/avro

@Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = Channels.pipeline();
  p.addLast("frameDecoder", new NettyFrameDecoder());
  p.addLast("frameEncoder", new NettyFrameEncoder());
  p.addLast("handler", createNettyClientAvroHandler());
  return p;
 }
});

代码示例来源:origin: voldemort/voldemort

@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = pipeline();
  pipeline.addLast("decoder", new HttpRequestDecoder());
  pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_AGGREGATE_SIZE));
  pipeline.addLast("encoder", new HttpResponseEncoder());
  pipeline.addLast("deflater", new HttpContentCompressor());
  pipeline.addLast("handler", new CoordinatorAdminRequestHandler(storeClientConfigs));
  return pipeline;
}

代码示例来源:origin: weibocom/motan

@Override
  public ChannelPipeline getPipeline() {
    final ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("decoder", new NettyDecoder(codec, NettyClient.this, maxContentLength));
    pipeline.addLast("encoder", new NettyEncoder(codec, NettyClient.this));
    pipeline.addLast("handler", new NettyChannelHandler(NettyClient.this, new MessageHandler() {
      @Override
      public Object handle(Channel channel, Object message) {
        Response response = (Response) message;
        ResponseFuture responseFuture = NettyClient.this.removeCallback(response.getRequestId());
        if (responseFuture == null) {
          LoggerUtil.warn(
              "NettyClient has response from server, but resonseFuture not exist,  requestId={}",
              response.getRequestId());
          return null;
        }
        if (response.getException() != null) {
          responseFuture.onFailure(response);
        } else {
          responseFuture.onSuccess(response);
        }
        return null;
      }
    }));
    return pipeline;
  }
});

代码示例来源:origin: kairosdb/kairosdb

@Override
public ChannelPipeline getPipeline() throws Exception
{
  ChannelPipeline pipeline = Channels.pipeline();
  // Add the text line codec combination first,
  DelimiterBasedFrameDecoder frameDecoder = new DelimiterBasedFrameDecoder(
      maxCommandLength, Delimiters.lineDelimiter());
  pipeline.addLast("framer", frameDecoder);
  pipeline.addLast("decoder", new WordSplitter());
  pipeline.addLast("encoder", new StringEncoder());
  // and then business logic.
  pipeline.addLast("handler", this);
  return pipeline;
}

相关文章