use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class AtomicAction method suspend.
/**
* Suspend all transaction association from the invoking thread. When this
* operation returns, the thread will be associated with no transactions.
*
* If the current transaction is not an AtomicAction then this method will
* not suspend.
*
* @return a handle on the current AtomicAction (if any) so that the thread
* can later resume association if required.
*/
public static final AtomicAction suspend() {
BasicAction curr = ThreadActionData.currentAction();
if (curr != null) {
if (curr instanceof AtomicAction)
ThreadActionData.purgeActions();
else {
tsLogger.i18NLogger.warn_ats_atomicaction_1(curr.toString());
curr = null;
}
}
return (AtomicAction) curr;
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class TransactionMonitor method main.
public static void main(String[] args) {
String root = null;
for (int i = 0; i < args.length; i++) {
if (args[i].compareTo("-help") == 0) {
usage();
System.exit(0);
} else {
if (args[i].compareTo("-root") == 0) {
root = args[i + 1];
i++;
} else {
System.out.println("Unknown option " + args[i]);
usage();
System.exit(0);
}
}
}
/* Determine transaction (BasicAction) type name */
BasicAction ba = new BasicAction();
String baType = ba.type();
if (baType.charAt(0) == '/')
baType = baType.substring(1);
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState types = new InputObjectState();
if (recoveryStore.allTypes(types)) {
String theName = null;
int count = 0;
try {
boolean endOfList = false;
while (!endOfList) {
theName = types.unpackString();
if (theName.compareTo("") == 0)
endOfList = true;
else if (theName.startsWith(baType)) {
count++;
System.out.println(count + ": " + theName);
InputObjectState uids = new InputObjectState();
if (recoveryStore.allObjUids(theName, uids)) {
Uid theUid = new Uid(Uid.nullUid());
try {
boolean endOfUids = false;
while (!endOfUids) {
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid()))
endOfUids = true;
else {
System.out.print("\t" + theUid + " state is ");
System.out.print(StateStatus.stateStatusString(recoveryStore.currentState(theUid, theName)));
System.out.println();
}
}
} catch (Exception e) {
// end of uids!
}
}
System.out.println();
}
}
} catch (Exception e) {
System.err.println(e);
// end of list!
}
}
} catch (Exception e) {
System.err.println("Caught unexpected exception: " + e);
}
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class BadAction method test.
@Test
public void test() {
AtomicAction A = new AtomicAction();
AtomicAction B = new AtomicAction();
A.begin();
B.begin();
A.commit();
B.commit();
BasicAction current = BasicAction.Current();
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class LockManager method doRelease.
/*
* doRelease: Does all the hard work of lock release. Either releases all
* locks for a given tx uid, or simply one lock with a given uid as
* appropriate.
*/
protected boolean doRelease(Uid u, boolean all) {
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace("LockManager::doRelease(" + u + ", " + all + ")");
}
if (!lockMutex())
return false;
Lock previous = null;
Lock current = null;
boolean deleted = false;
boolean result = false;
int retryCount = 10;
boolean loaded = false;
boolean releasedOK = false;
BasicAction currAct = BasicAction.Current();
try {
synchronized (locksHeldLockObject) {
do {
if (loadState()) {
loaded = true;
/*
* Must declare iterator after loadstate or it sees an empty
* list!
*/
LockListIterator next = new LockListIterator(locksHeld);
/*
* Now scan through held lock list to find which locks to
* release u is either the unique id of the lock owner
* (oneOrAll = ALL_LOCKS) or the uid of the actual lock
* itself (oneOrAll = SINGLE_LOCK).
*/
previous = null;
while ((current = next.iterate()) != null) {
Uid checkUid = null;
if (all)
checkUid = current.getCurrentOwner();
else
checkUid = current.get_uid();
if (u.equals(checkUid)) {
locksHeld.forgetNext(previous);
current = null;
deleted = true;
if (!all) {
break;
}
} else
previous = current;
}
result = true;
} else {
/*
* Free state while we still have the lock.
*/
freeState();
result = false;
}
if (!result) {
try {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LockManager.doRelease() Dozing");
}
Thread.sleep(LockManager.DOZE_TIME);
} catch (InterruptedException e) {
}
} else {
// if (!stateLoaded)
if (!loaded) {
txojLogger.i18NLogger.warn_LockManager_7();
/*
* No need to freeState since we will have done that by now.
*/
} else {
if (!deleted) {
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace(" *** CANNOT locate locks ***");
}
}
int unloadRetryCount = 10;
do {
if (!unloadState()) {
txojLogger.i18NLogger.warn_LockManager_8();
} else
releasedOK = true;
} while ((--unloadRetryCount > 0) && (!releasedOK));
}
}
} while ((!result) && (--retryCount > 0));
}
/*
* Now signal to any waiting threads that they may try to acquire the
* lock.
*/
conflictManager.signal();
} finally {
unlockMutex();
}
return releasedOK;
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class TransactionImple method getTransaction.
public static final TransactionImple getTransaction() {
TransactionImple tx = null;
final BasicAction current = BasicAction.Current();
if (current != null) {
final Uid txid = current.get_uid();
tx = (TransactionImple) _transactions.get(txid);
if (tx == null)
tx = new TransactionImple(current);
}
return tx;
}
Aggregations