Java 类org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictorFactory 实例源码

项目:flume-release-1.7.0    文件:SyslogUDPSource.java   
@Override
public void start() {
  // setup Netty server
  ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap(
      new OioDatagramChannelFactory(Executors.newCachedThreadPool()));
  final syslogHandler handler = new syslogHandler();
  handler.setFormater(formaterProp);
  handler.setKeepFields(keepFields);
  serverBootstrap.setOption("receiveBufferSizePredictorFactory",
      new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE,
          DEFAULT_INITIAL_SIZE, maxsize));
  serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() {
      return Channels.pipeline(handler);
    }
  });

  if (host == null) {
    nettyChannel = serverBootstrap.bind(new InetSocketAddress(port));
  } else {
    nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port));
  }

  sourceCounter.start();
  super.start();
}