public void close() {
    if (closed.compareAndSet(false, true)) {
      try {
        channelManager.close();

        // FIXME shouldn't close if not allowed
        config.executorService().shutdown();

        if (allowStopNettyTimer) nettyTimer.stop();

      } catch (Throwable t) {
        LOGGER.warn("Unexpected error on close", t);
      }
    }
  }
  public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {

    this.config = config;
    NettyAsyncHttpProviderConfig nettyConfig =
        config.getAsyncHttpProviderConfig() instanceof NettyAsyncHttpProviderConfig
            ? //
            (NettyAsyncHttpProviderConfig) config.getAsyncHttpProviderConfig()
            : new NettyAsyncHttpProviderConfig();

    allowStopNettyTimer = nettyConfig.getNettyTimer() == null;
    nettyTimer = allowStopNettyTimer ? newNettyTimer() : nettyConfig.getNettyTimer();

    channelManager = new ChannelManager(config, nettyConfig, nettyTimer);
    requestSender = new NettyRequestSender(config, channelManager, nettyTimer, closed);
    channelManager.configureBootstraps(requestSender, closed);
  }
 public void flushChannelPoolPartitions(ChannelPoolPartitionSelector selector) {
   channelManager.flushPartitions(selector);
 }
 public void flushChannelPoolPartition(String partitionId) {
   channelManager.flushPartition(partitionId);
 }