Ejemplo n.º 1
0
  protected TcpTransport(
      final Configuration configuration,
      final Executor bossPool,
      final Executor workerPool,
      final ThroughputCounter throughputCounter,
      final ConnectionCounter connectionCounter,
      final LocalMetricRegistry localRegistry) {
    super(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter);

    final boolean nulDelimiter = configuration.getBoolean(CK_USE_NULL_DELIMITER);
    this.delimiter = nulDelimiter ? nulDelimiter() : lineDelimiter();
    this.tcpKeepalive = configuration.getBoolean(CK_TCP_KEEPALIVE);
    this.maxFrameLength =
        configuration.getInt(CK_MAX_MESSAGE_SIZE, Config.DEFAULT_MAX_FRAME_LENGTH);
  }
  @Override
  public ChannelPipeline getPipeline() throws Exception {
    ChannelBuffer[] delimiter;

    if (config.getBoolean(SyslogTCPInput.CK_USE_NULL_DELIMITER)) {
      delimiter = Delimiters.nulDelimiter();
    } else {
      delimiter = Delimiters.lineDelimiter();
    }

    ChannelPipeline p = Channels.pipeline();
    p.addLast("connection-counter", connectionCounter);
    p.addLast("framer", new DelimiterBasedFrameDecoder(2 * 1024 * 1024, delimiter));
    p.addLast("traffic-counter", throughputCounter);
    p.addLast("handler", new SyslogDispatcher(server, config, sourceInput));
    return p;
  }