src/main/java/com/github/ddth/cql/SessionManager.java
public void executeAsync(FutureCallback<ResultSet> callback, Statement stm,
            ConsistencyLevel consistencyLevel) throws ExceedMaxAsyncJobsException {
        if (!asyncSemaphore.tryAcquire()) {
            if (callback == null) {
                throw new ExceedMaxAsyncJobsException(maxSyncJobs);
            } else {
                callback.onFailure(new ExceedMaxAsyncJobsException(maxSyncJobs));
            }
        } else {
            try {
                if (consistencyLevel != null) {
                    if (consistencyLevel == ConsistencyLevel.SERIAL
                            || consistencyLevel == ConsistencyLevel.LOCAL_SERIAL) {
                        stm.setSerialConsistencyLevel(consistencyLevel);
                    } else {
                        stm.setConsistencyLevel(consistencyLevel);
                    }
                }
                ResultSetFuture rsf = CqlUtils.executeAsync(getSession(), stm);
                if (callback != null) {
                    Futures.addCallback(rsf, wrapCallbackResultSet(callback), asyncExecutor);
                }
            } catch (Exception e) {
                asyncSemaphore.release();
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
public void executeAsync(FutureCallback<ResultSet> callback, Statement stm,
            ConsistencyLevel consistencyLevel) throws ExceedMaxAsyncJobsException {
        if (!asyncSemaphore.tryAcquire()) {
            if (callback == null) {
                throw new ExceedMaxAsyncJobsException(maxSyncJobs);
            } else {
                callback.onFailure(new ExceedMaxAsyncJobsException(maxSyncJobs));
            }
        } else {
            try {
                if (consistencyLevel != null) {
                    if (consistencyLevel == ConsistencyLevel.SERIAL
                            || consistencyLevel == ConsistencyLevel.LOCAL_SERIAL) {
                        stm.setSerialConsistencyLevel(consistencyLevel);
                    } else {
                        stm.setConsistencyLevel(consistencyLevel);
                    }
                }
                ResultSetFuture rsf = CqlUtils.executeAsync(getSession(), stm);
                if (callback != null) {
                    Futures.addCallback(rsf, wrapCallbackResultSet(callback), asyncExecutor);
                }
            } catch (Exception e) {
                asyncSemaphore.release();
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
public void executeAsync ( FutureCallback < ResultSet > callback , Statement stm , ConsistencyLevel consistencyLevel ) throws ExceedMaxAsyncJobsException { if ( ! asyncSemaphore . tryAcquire ( ) ) { if ( callback == null ) { throw new ExceedMaxAsyncJobsException ( maxSyncJobs ) ; } else { callback . onFailure ( new ExceedMaxAsyncJobsException ( maxSyncJobs ) ) ; } } else { try { if ( consistencyLevel != null ) { if ( consistencyLevel == ConsistencyLevel . SERIAL || consistencyLevel == ConsistencyLevel . LOCAL_SERIAL ) { stm . setSerialConsistencyLevel ( consistencyLevel ) ; } else { stm . setConsistencyLevel ( consistencyLevel ) ; } } ResultSetFuture rsf = CqlUtils . executeAsync ( getSession ( ) , stm ) ; if ( callback != null ) { Futures . addCallback ( rsf , wrapCallbackResultSet ( callback ) , asyncExecutor ) ; } } catch ( Exception e ) { asyncSemaphore . release ( ) ; LOGGER . error ( e . getMessage ( ) , e ) ; } } }
Async-execute a query.

<p>
The default session (obtained via {@link #getSession()} is used to execute the query.
</p>

@param callback
{@link ExceedMaxAsyncJobsException} will be passed to
{@link FutureCallback#onFailure(Throwable)} if number of async-jobs exceeds
{@link #getMaxAsyncJobs()}.
@param stm
@param consistencyLevel
@since 0.4.0.2
@throws ExceedMaxAsyncJobsException
If number of running jobs exceeds a threshold <i>and</i> {@code callback} is
{@code null}.
Async - execute a query .