code: Session getReadWriteSession() {
      Span span = Tracing.getTracer().getCurrentSpan();
      span.addAnnotation("Acquiring read write session");
      Waiter waiter = null;
      PooledSession sess = null;
      synchronized (lock) {
        if (closureFuture != null) {
          throw new IllegalStateException("Pool has been closed");
        }
        sess = writePreparedSessions.poll();
        if (sess == null) {
          if (numSessionsBeingPrepared <= readWriteWaiters.size()) {
            PooledSession readSession = readSessions.poll();
            if (readSession != null) {
              span.addAnnotation("Acquired read only session. Preparing for read write transaction");
              prepareSession(readSession);
            } else {
              span.addAnnotation("No session available");
              maybeCreateSession();
            }
          }
          waiter = new Waiter();
          readWriteWaiters.add(waiter);
        } else {
          span.addAnnotation("Acquired read write session");
        }
      }
      if (waiter != null) {
        logger.log(
            Level.FINE,
            "No session available in the pool. Blocking for one to become available/created");
        span.addAnnotation("Waiting for read write session to be available");
        sess = waiter.take();
      }
      sess.markBusy();
      incrementNumSessionsInUse();
      span.addAnnotation(sessionAnnotation(sess));
      return sess;
    }
docs: Returns a session which has been prepared for writes by invoking BeginTransaction rpc. It will
  block if such a session is not currently available.In case the pool is exhausted and {@link
  SessionPoolOptions#isFailIfPoolExhausted()} has been set, it will throw an exception. Returned
  session must closed by invoking {@link Session#close()}.
  
  <p>Implementation strategy:
  
  <ol>
  <li>If a writePreparedSession is available, return that.
  <li>Otherwise if we have an extra session being prepared for write, wait for that.
  <li>Otherwise, if there is a read session available, start preparing that for write and wait.
  <li>Otherwise start creating a new session and wait.
  <li>Wait for write prepared session to become available. This can be unblocked either by the
  session create/prepare request we fired in above request or by a session being released
  to the pool which is then write prepared.
  </ol>