code: public ManagedChannel acquireManagedChannel(ChannelKey channelKey, long healthCheckTimeoutMs,
        long shutdownTimeoutMs) {
      boolean shutdownExistingChannel = false;
      ManagedChannelReference managedChannelRef = null;
      try (LockResource lockShared = new LockResource(mLock.readLock())) {
        if (mChannels.containsKey(channelKey)) {
          managedChannelRef = mChannels.get(channelKey);
          if (waitForChannelReady(managedChannelRef.get(),
              healthCheckTimeoutMs)) {
            LOG.debug("Acquiring an existing managed channel. ChannelKey: {}. Ref-count: {}",
                channelKey, managedChannelRef.getRefCount());
            return managedChannelRef.reference();
          } else {
            // Postpone channel shutdown under exclusive lock below.
            shutdownExistingChannel = true;
          }
        }
      }
      try (LockResource lockExclusive = new LockResource(mLock.writeLock())) {
        // Dispose existing channel if required.
        int existingRefCount = 0;
        if (shutdownExistingChannel && mChannels.containsKey(channelKey)
            && mChannels.get(channelKey) == managedChannelRef) {
          existingRefCount = managedChannelRef.getRefCount();
          LOG.debug("Shutting down an existing unhealthy managed channel. "
              + "ChannelKey: {}. Existing Ref-count: {}", channelKey, existingRefCount);
          shutdownManagedChannel(channelKey, shutdownTimeoutMs);
          mChannels.remove(channelKey);
        }
        if (!mChannels.containsKey(channelKey)) {
          LOG.debug("Creating a new managed channel. ChannelKey: {}. Ref-count:{}", channelKey,
              existingRefCount);
          mChannels.put(channelKey,
              new ManagedChannelReference(createManagedChannel(channelKey), existingRefCount));
        }
        return mChannels.get(channelKey).reference();
      }
    }
docs: Acquires and increases the ref-count for the {@link ManagedChannel}.
  
  @param channelKey channel key
  @param healthCheckTimeoutMs health check timeout in milliseconds
  @param shutdownTimeoutMs shutdown timeout in milliseconds
  @return a {@link ManagedChannel}