private static synchronized TransactionCacheItem get (Uid theUid, String theType) { TransactionCacheItem cacheItem = (TransactionCacheItem) _theCache.get(theUid); if (cacheItem == null) { // No entry in cache -> create it cacheItem = new TransactionCacheItem(theUid, theType); _theCache.put(theUid, cacheItem); } return cacheItem; }
/** * Get the status of a transaction */ public static Status get_status (Uid actionUid, String theType) throws SystemException { Status theStatus = Status.StatusUnknown; TransactionCacheItem cacheItem = get(actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if (theTransaction != null) { theStatus = theTransaction.get_status(); // remember the status in the cacheitem cacheItem.setStatus(theStatus); } } } return theStatus; }
/** * Get the status of a transaction that is already in the cache */ public static Status getCachedStatus (Uid actionUid) throws SystemException { TransactionCacheItem cacheItem = getKnown (actionUid); if (cacheItem != null) { return cacheItem.getStatus(); } return Status.StatusNoTransaction; // used to mean it isn't cached }
RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if ( cacheItem.getStatus() == Status.StatusCommitted ) int previousAttempts = cacheItem.countAttempts(); if (previousAttempts >= attemptsBeforeConversion) { converting = theTransaction.assumeComplete(); cacheItem.setStatus(theTransaction.get_status()); jtsLogger.i18NLogger.info_recovery_transactions_TransactionCache_4(actionUid); theTransaction.removeOldStoreEntry(); cacheItem.updateType(); returnStatus = ReplayPhaseReturnStatus.ASSUME_COMPLETED; cacheItem.clearTransaction(); // just force a reactivate later
/** * Add a new resource to a recovered transaction. This is * primarily to allow a new resource that has been provided * through a replay_completion to be added to the transaction and * thereby replacing the original resource that was passed in on * register_resource. */ public static void addResourceRecord (Uid actionUid, String theType, Uid rcUid, Resource r) { TransactionCacheItem cacheItem = get (actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if (theTransaction != null) { // As long as the transaction activated okay then try and add // the record. if (theTransaction.getRecoveryStatus() != RecoveryStatus.ACTIVATE_FAILED) { theTransaction.addResourceRecord(rcUid, r); } // with a new resource record, start counting attempts from zero cacheItem.resetAttemptCount(); } } } }
TransactionCacheItem(Uid uid,String type) { _uid = new Uid(uid); // copy as usual (I wonder ... ) _type = type; _attempts=0; // NoTransaction is used to mean that the status is not // actually known _knownStatus = Status.StatusNoTransaction; loadTransaction(true); }
public static int getRecoveryStatus (Uid actionUid, String theType) { int theRecoveryStatus = RecoveryStatus.NEW; TransactionCacheItem cacheItem = get (actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.transaction(); if (theTransaction != null) { theRecoveryStatus = theTransaction.getRecoveryStatus(); } } } return theRecoveryStatus; }
/** * Get the status of a transaction as it is in the original process * (so type is not needed) * NoTransaction means the original process has gone */ public static Status getOriginalStatus (Uid actionUid, String theType) throws SystemException { Status theStatus = Status.StatusUnknown; TransactionCacheItem cacheItem = get (actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if (theTransaction != null) { if (jtsLogger.logger.isDebugEnabled()) { jtsLogger.logger.debug("asking the tran for original status"); } theStatus = theTransaction.getOriginalStatus(); } else { if (jtsLogger.logger.isDebugEnabled()) { jtsLogger.logger.debug("no transaction in cache so not asking for original status"); } } } } return theStatus; }
RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if ( cacheItem.getStatus() == Status.StatusCommitted ) int previousAttempts = cacheItem.countAttempts(); if (previousAttempts >= attemptsBeforeConversion) { converting = theTransaction.assumeComplete(); cacheItem.setStatus(theTransaction.get_status()); cacheItem.updateType(); cacheItem.clearTransaction(); // just force a reactivate later
/** * Add a new resource to a recovered transaction. This is * primarily to allow a new resource that has been provided * through a replay_completion to be added to the transaction and * thereby replacing the original resource that was passed in on * register_resource. */ public static void addResourceRecord (Uid actionUid, String theType, Uid rcUid, Resource r) { TransactionCacheItem cacheItem = get (actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if (theTransaction != null) { // As long as the transaction activated okay then try and add // the record. if (theTransaction.getRecoveryStatus() != RecoveryStatus.ACTIVATE_FAILED) { theTransaction.addResourceRecord(rcUid, r); } // with a new resource record, start counting attempts from zero cacheItem.resetAttemptCount(); } } } }
TransactionCacheItem(Uid uid,String type) { _uid = new Uid(uid); // copy as usual (I wonder ... ) _type = type; _attempts=0; // NoTransaction is used to mean that the status is not // actually known _knownStatus = Status.StatusNoTransaction; loadTransaction(true); }
public static int getRecoveryStatus (Uid actionUid, String theType) { int theRecoveryStatus = RecoveryStatus.NEW; TransactionCacheItem cacheItem = get (actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.transaction(); if (theTransaction != null) { theRecoveryStatus = theTransaction.getRecoveryStatus(); } } } return theRecoveryStatus; }
RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if (theTransaction != null)
/** * Get the status of a transaction */ public static Status get_status (Uid actionUid, String theType) throws SystemException { Status theStatus = Status.StatusUnknown; TransactionCacheItem cacheItem = get(actionUid, theType); if (cacheItem != null) { synchronized (cacheItem) { RecoveringTransaction theTransaction = cacheItem.freshTransaction(); if (theTransaction != null) { theStatus = theTransaction.get_status(); // remember the status in the cacheitem cacheItem.setStatus(theStatus); } } } return theStatus; }
/** * Make sure the transaction is freshly activated and hasn't been replayed * assumed to be called from code synchronized on the TransactionCacheItem */ RecoveringTransaction freshTransaction() { if (_transaction == null || _transaction.getRecoveryStatus() == RecoveryStatus.REPLAYED) { /* * Not sure why we do a reload at all here. But if we do it * based on whether the transaction has really completed, things * stop working. Needs further investigation since there may * be a possible memory leak here. * * TO DO */ // if (!_transaction.allCompleted()) { // The transaction has been replayed, but they want a fresh one // Destroy this transaction and create a new // one thereby reactivating it. // Reactivate as the appropriate transaction class loadTransaction(false); } } return _transaction; }
/** * Get the status of a transaction that is already in the cache */ public static Status getCachedStatus (Uid actionUid) throws SystemException { TransactionCacheItem cacheItem = getKnown (actionUid); if (cacheItem != null) { return cacheItem.getStatus(); } return Status.StatusNoTransaction; // used to mean it isn't cached }
private static synchronized TransactionCacheItem get (Uid theUid, String theType) { TransactionCacheItem cacheItem = (TransactionCacheItem) _theCache.get(theUid); if (cacheItem == null) { // No entry in cache -> create it cacheItem = new TransactionCacheItem(theUid, theType); _theCache.put(theUid, cacheItem); } return cacheItem; }
/** * Make sure the transaction is freshly activated and hasn't been replayed * assumed to be called from code synchronized on the TransactionCacheItem */ RecoveringTransaction freshTransaction() { if (_transaction == null || _transaction.getRecoveryStatus() == RecoveryStatus.REPLAYED) { /* * Not sure why we do a reload at all here. But if we do it * based on whether the transaction has really completed, things * stop working. Needs further investigation since there may * be a possible memory leak here. * * TO DO */ // if (!_transaction.allCompleted()) { // The transaction has been replayed, but they want a fresh one // Destroy this transaction and create a new // one thereby reactivating it. // Reactivate as the appropriate transaction class loadTransaction(false); } } return _transaction; }