Exemplo n.º 1
0
 private void forceCloseOnPendingRequests() {
   for (MySqlRequest request : requestQueue) {
     if (request.getRequest().tryCancel()) {
       request.getFuture().trySetException(new DbSessionClosedException("Connection is closed"));
     }
   }
 }
Exemplo n.º 2
0
 @Override
 public DbSessionFuture<Void> rollback() {
   if (!isInTransaction()) {
     throw new DbException("No transaction has been started to rollback");
   }
   checkClosed();
   synchronized (lock) {
     final MySqlRequest request = queRequest(MySqlRequests.rollbackTransaction(this));
     isInTransaction = false;
     return (DbSessionFuture<Void>) request.getFuture();
   }
 }
Exemplo n.º 3
0
 @Override
 public DbFuture<Void> close(CloseMode closeMode) throws DbException {
   synchronized (lock) {
     if (null == closeFuture) {
       final MySqlRequest closeRequest = MySqlRequests.createCloseRequest(this);
       closeFuture = closeRequest.getFuture();
       closeFuture.addListener(
           new DbListener<Void>() {
             @Override
             public void onCompletion(DbFuture<Void> future) {
               MySqlConnection.this.connectionManager.removeConnection(MySqlConnection.this);
             }
           });
       if (closeMode == CloseMode.CANCEL_PENDING_OPERATIONS) {
         forceCloseOnPendingRequests();
       }
       forceQueRequest(closeRequest);
       return closeFuture;
     } else {
       return closeFuture;
     }
   }
 }