private QldbSession getSession()

in src/main/java/software/amazon/qldb/QldbDriverImpl.java [205:224]


    private QldbSession getSession() {
        logger.debug("Getting session. There are {} free sessions; currently available permits is: {}.",
                pool.size(), poolPermits.availablePermits());

        try {
            if (poolPermits.tryAcquire(DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
                QldbSession session = pool.poll();
                if (session == null) {
                    session = createNewSession();
                    logger.debug("Creating new pooled session. Session ID: {}.", session.getSessionId());
                }
                return session;
            } else {
                throw QldbDriverException.create(String.format(Errors.NO_SESSION_AVAILABLE.get(), DEFAULT_TIMEOUT_MS));
            }
        } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
            throw QldbDriverException.create(Errors.GET_SESSION_INTERRUPTED.get());
        }
    }