code: private SettableFuture<OpenedSocket> getConnectionImpl(UUID id, Source source) {
      lock.lock();
      try {
        checkState(connectionState.put(source, id), "Connection for %s has already been %s",
            id, source);
        SettableFuture<OpenedSocket> future = halfFinishedConnections.get(id);
        if (future == null) {
          future = SettableFuture.create();
          halfFinishedConnections.put(id, future);
        } else {
          halfFinishedConnections.remove(id);
        }
        return future;
      } finally {
        lock.unlock();
      }
    }
docs: Returns a {@link SettableFuture} from the map of connections.
  
  <p>This method has the following properties:
  <ul>
  <li>If the id is present in {@link #connectionState}, this will throw an
  {@link IllegalStateException}.
  <li>The id and source are recorded in {@link #connectionState}
  <li>If the future is already in {@link #halfFinishedConnections}, it is removed and
  returned.
  <li>If the future is not in {@link #halfFinishedConnections}, a new {@link SettableFuture}
  is added and then returned.
  
  <p>These features together ensure that each connection can only be accepted once, only
  requested once and once both have happened it will be removed from
  {@link #halfFinishedConnections}.