public void commit() throws ResourceException {
    if (DEBUG) {
      try {
        throw new NullPointerException("Asif:JCALocalTransaction:commit");
      } catch (NullPointerException npe) {
        npe.printStackTrace();
      }
    }
    LogWriter logger = cache.getLogger();
    if (logger.fineEnabled()) {
      logger.fine("JCALocalTransaction:invoked commit");
    }
    TXStateProxy tsp = this.gfTxMgr.getTXState();
    if (tsp != null && this.tid != tsp.getTransactionId()) {
      throw new IllegalStateException(
          "Local Transaction associated with Tid = "
              + this.tid
              + " attempting to commit a different transaction");
    }
    try {
      this.gfTxMgr.commit();
      this.tid = null;
    } catch (Exception e) {
      throw new LocalTransactionException(e.toString());
    }
    // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
    // ConnectionEvent ce = new
    // ConnectionEvent(this,ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
    // while( itr.hasNext()) {
    // itr.next().localTransactionCommitted(ce);
    // }

  }
 private void init() throws SystemException {
   this.cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
   LogWriter logger = this.cache.getLogger();
   if (logger.fineEnabled()) {
     logger.fine("JCAManagedConnection:init. Inside init");
   }
   gfTxMgr = cache.getTxManager();
   this.initDone = true;
 }
Beispiel #3
0
 @Override
 public void log(String message) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     printMessage("info", message);
   } else {
     logger.info(message);
   }
 }
Beispiel #4
0
 @Override
 public boolean isWarningEnabled() {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     return false;
   } else {
     return logger.warningEnabled();
   }
 }
Beispiel #5
0
 @Override
 public void warning(String message) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     printMessage("warning", getLogMessage(message));
   } else {
     logger.warning(getLogMessage(message));
   }
 }
Beispiel #6
0
 @Override
 public void fine(String message) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     printMessage("fine", getLogMessage(message));
   } else {
     logger.fine(getLogMessage(message));
   }
 }
Beispiel #7
0
 @Override
 public void severe(String message) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     System.err.println(getLogMessage(message));
   } else {
     logger.severe(getLogMessage(message));
   }
 }
Beispiel #8
0
 @Override
 public void warning(Throwable th) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     printMessage("warning", getLogMessage());
     th.printStackTrace(System.out);
   } else {
     logger.warning(getLogMessage(), th);
   }
 }
Beispiel #9
0
 @Override
 public void fine(String message, Throwable th) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     printMessage("fine", getLogMessage(message));
     th.printStackTrace(System.out);
   } else {
     logger.fine(getLogMessage(message), th);
   }
 }
Beispiel #10
0
 @Override
 public void severe(Throwable th) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     System.err.println(getLogMessage());
     th.printStackTrace(System.err);
   } else {
     logger.severe(getLogMessage(), th);
   }
 }
Beispiel #11
0
 @Override
 public void error(String message, Throwable th) {
   LogWriter logger = getLogWriter();
   if (logger == null) {
     System.err.println(getLogMessage(message));
     th.printStackTrace(System.err);
   } else {
     logger.error(getLogMessage(message), th);
   }
 }
  public void begin() throws ResourceException {
    if (DEBUG) {
      try {
        throw new NullPointerException("Asif:JCALocalTransaction:begin");
      } catch (NullPointerException npe) {
        npe.printStackTrace();
      }
    }
    try {
      if (!initDone || this.cache.isClosed()) {
        this.init();
      }
      // System.out.println("JCALocalTransaction:Asif: cache is ="+cache +
      // " for tx ="+this);
      LogWriter logger = cache.getLogger();
      if (logger.fineEnabled()) {
        logger.fine("JCALocalTransaction::begin:");
      }
      TransactionManager tm = cache.getJTATransactionManager();
      if (this.tid != null) {
        throw new LocalTransactionException(" A transaction is already in progress");
      }
      if (tm != null && tm.getTransaction() != null) {
        if (logger.fineEnabled()) {
          logger.fine("JCAManagedConnection: JTA transaction is on");
        }
        // This is having a JTA transaction. Assuming ignore jta flag is true,
        // explicitly being a gemfire transaction.
        TXStateProxy tsp = this.gfTxMgr.getTXState();
        if (tsp == null) {
          this.gfTxMgr.begin();
          tsp = this.gfTxMgr.getTXState();
          tsp.setJCATransaction();
          this.tid = tsp.getTransactionId();
          if (logger.fineEnabled()) {
            logger.fine("JCALocalTransaction:begun GFE transaction");
          }
        } else {
          throw new LocalTransactionException("GemFire is already associated with a transaction");
        }
      } else {
        if (logger.fineEnabled()) {
          logger.fine("JCAManagedConnection: JTA Transaction does not exist.");
        }
      }
    } catch (SystemException e) {
      // this.onError();
      throw new ResourceException(e);
    }
    // Not to be invoked for local transactions managed by the container
    // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
    // ConnectionEvent ce = new ConnectionEvent(this,
    // ConnectionEvent.LOCAL_TRANSACTION_STARTED);
    // while (itr.hasNext()) {
    // itr.next().localTransactionStarted(ce);
    // }

  }
  private static AsyncEventQueue createAsyncEventQueue(
      AsyncEventQueueDescription aeqd, Cache cache) {
    // configure the factory
    AsyncEventQueueFactory f = cache.createAsyncEventQueueFactory();
    log.info("Configuring async event queue factory");
    aeqd.configure(f);
    log.info("Configured async event queue factory " + f);

    // create the async event queue
    log.info("Creating and starting async event queue " + aeqd.getName());
    AsyncEventQueue queue = f.create(aeqd.getName(), aeqd.getAsyncEventListenerInstance());
    log.info("Created and started async event queue: " + asyncEventQueueToString(queue));
    return queue;
  }
 /**
  * Returns the {@link AsyncEventQueueDescription} with the given configuration name from {@link
  * AsyncEventQueuePrms#names}.
  */
 public static AsyncEventQueueDescription getAsyncEventQueueDescription(
     String asyncEventQueueConfig) {
   if (asyncEventQueueConfig == null) {
     throw new IllegalArgumentException("asyncEventQueueConfig cannot be null");
   }
   log.info("Looking up async event queue config: " + asyncEventQueueConfig);
   AsyncEventQueueDescription aeqd =
       TestConfig.getInstance().getAsyncEventQueueDescription(asyncEventQueueConfig);
   if (aeqd == null) {
     String s =
         asyncEventQueueConfig + " not found in " + BasePrms.nameForKey(AsyncEventQueuePrms.names);
     throw new HydraRuntimeException(s);
   }
   log.info("Looked up async event queue config:\n" + aeqd);
   return aeqd;
 }
  public void rollback() throws ResourceException {
    if (DEBUG) {
      try {
        throw new NullPointerException("Asif:JJCALocalTransaction:rollback");
      } catch (NullPointerException npe) {
        npe.printStackTrace();
      }
    }
    TXStateProxy tsp = this.gfTxMgr.getTXState();
    if (tsp != null && this.tid != tsp.getTransactionId()) {
      throw new IllegalStateException(
          "Local Transaction associated with Tid = "
              + this.tid
              + " attempting to commit a different transaction");
    }
    LogWriter logger = cache.getLogger();
    if (logger.fineEnabled()) {
      logger.fine("JCALocalTransaction:invoked rollback");
    }
    try {
      this.gfTxMgr.rollback();
    } catch (IllegalStateException ise) {
      // It is possible that the GFE transaction has already been rolled back.
      if (ise.getMessage()
          .equals(
              LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION
                  .toLocalizedString())) {
        // /ignore;
      } else {
        throw new ResourceException(ise);
      }
    } catch (Exception e) {
      throw new ResourceException(e);
    } finally {
      this.tid = null;
    }
    // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
    // ConnectionEvent ce = new ConnectionEvent(this,
    // ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
    // while (itr.hasNext()) {
    // itr.next().localTransactionRolledback(ce);
    // }

  }