src/main/java/com/github/ddth/cql/SessionManager.java
synchronized protected Session getSession(SessionIdentifier si, boolean forceNew) {
        /*
         * Since 0.2.6: refresh cluster cache before obtaining the session to
         * avoid exception
         * "You may have used a PreparedStatement that was created with another Cluster instance"
         */
        Cluster cluster = getCluster(si);
        if (cluster == null) {
            return null;
        }

        try {
            LoadingCache<SessionIdentifier, Session> cacheSessions = sessionCache.get(si);
            Session existingSession = cacheSessions.getIfPresent(si);
            if (existingSession != null && existingSession.isClosed()) {
                LOGGER.info("Session [" + existingSession + "] was closed, obtaining a new one...");
                cacheSessions.invalidate(si);
                return cacheSessions.get(si);
            }
            if (forceNew) {
                if (existingSession != null) {
                    cacheSessions.invalidate(si);
                }
                return cacheSessions.get(si);
            }
            return existingSession != null ? existingSession : cacheSessions.get(si);
        } catch (ExecutionException e) {
            Throwable t = e.getCause();
            throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
        }
    }
synchronized protected Session getSession(SessionIdentifier si, boolean forceNew) {
        /*
         * Since 0.2.6: refresh cluster cache before obtaining the session to
         * avoid exception
         * "You may have used a PreparedStatement that was created with another Cluster instance"
         */
        Cluster cluster = getCluster(si);
        if (cluster == null) {
            return null;
        }

        try {
            LoadingCache<SessionIdentifier, Session> cacheSessions = sessionCache.get(si);
            Session existingSession = cacheSessions.getIfPresent(si);
            if (existingSession != null && existingSession.isClosed()) {
                LOGGER.info("Session [" + existingSession + "] was closed, obtaining a new one...");
                cacheSessions.invalidate(si);
                return cacheSessions.get(si);
            }
            if (forceNew) {
                if (existingSession != null) {
                    cacheSessions.invalidate(si);
                }
                return cacheSessions.get(si);
            }
            return existingSession != null ? existingSession : cacheSessions.get(si);
        } catch (ExecutionException e) {
            Throwable t = e.getCause();
            throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
        }
    }
Obtain a Cassandra session instance.

@param si
@param forceNew
@return