use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.
the class Interposition method setupHierarchy.
/*
* Assume that all actions in the imported hierarchy are of the same
* type, i.e., all JBoss transactions.
*
* Because of the way garbage collection works in the ORB we have to
* run an explicit garbage collection phase for finished hierarchies.
*/
public synchronized ControlImple setupHierarchy(PropagationContext context) throws SystemException {
ControlImple controlPtr = null;
Uid theUid = null;
ServerTopLevelAction proxyAction = null;
if (context.parents.length == 0)
theUid = Utility.otidToUid(context.current.otid);
else
theUid = Utility.otidToUid(context.parents[context.parents.length - 1].otid);
proxyAction = present(theUid);
if (proxyAction == null) {
/*
* Create a new proxyAction element and return the
* "current" transaction.
*/
controlPtr = createHierarchy(context, theUid);
} else {
/*
* Check hierarchy of existing element.
*/
controlPtr = checkHierarchy(proxyAction, context);
proxyAction = null;
}
return controlPtr;
}
use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.
the class RestrictedInterposition method createHierarchy.
protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid tlUid) throws SystemException {
/*
* Start at the parent and work our way down to "current". The current
* transaction is not in the IDL sequence, but sent as separate field of
* the propagation context. This tends to make the code more complex
* than it would be if the entire hierarchy was represented in one
* place.
*/
int depth = ctx.parents.length;
ServerTopLevelAction tlAction = null;
Coordinator tmpCoord = null;
Terminator tmpTerm = null;
if (depth == 0) {
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
} else {
tmpCoord = ctx.parents[depth - 1].coord;
tmpTerm = ctx.parents[depth - 1].term;
}
ServerControl control = ServerFactory.create_transaction(tlUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
tlAction = new ServerRestrictedTopLevelAction(control);
if (!tlAction.valid()) {
try {
tlAction.rollback();
tlAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
ServerTopLevelAction newElement = tlAction;
super._head.add(newElement);
if (// current is a nested transaction
depth > 0) {
/*
* Now deal with any nested transactions. As we create, register
* with the original transactions.
*/
ServerRestrictedNestedAction nestedAction = null;
for (int i = depth - 2; i >= 0; i--) {
tmpCoord = ctx.parents[i].coord;
tmpTerm = ctx.parents[i].term;
control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
nestedAction = new ServerRestrictedNestedAction(control);
if (!nestedAction.valid()) {
try {
nestedAction.rollback();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
/*
* Add transaction resource to list.
*/
tlAction.addChild(nestedAction);
}
/*
* Now deal with current transaction. If there is only one
* transaction we do nothing.
*/
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.current.otid), tmpCoord, tmpTerm, control);
nestedAction = new ServerRestrictedNestedAction(control);
if (!nestedAction.valid()) {
try {
nestedAction.rollback();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
tlAction.addChild(nestedAction);
}
return control;
}
use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.
the class StrictInterposition method createHierarchy.
protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid currentUid) throws SystemException {
/*
* Start at the parent and work our way down to "current". The current
* transaction is not in the IDL sequence, but sent as separate field
* of the propagation context. This tends to make the code more
* complex than it would be if the entire hierarchy was represented in
* one place.
*/
/*
* We only ever register the current transaction with its parent, and
* as each transaction commits, it registers its parent with the
* "real" parent.
*/
int depth = ctx.parents.length;
ServerResource action = null;
Coordinator tmpCoord = null;
Terminator tmpTerm = null;
if (depth == 0) {
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
} else {
tmpCoord = ctx.parents[depth - 1].coord;
tmpTerm = ctx.parents[depth - 1].term;
}
if (// terminator my correctory be null
tmpCoord == null)
return null;
ServerControl control = ServerFactory.create_transaction(currentUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
action = new ServerStrictTopLevelAction(control, ((depth == 0) ? true : false));
if (!action.valid()) {
try {
// does dispose as well!
((ServerStrictTopLevelAction) action).rollback();
action = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
ServerTopLevelAction newElement = (ServerStrictTopLevelAction) action;
_head.add(newElement);
if (// current is a nested transaction
depth > 0) {
/*
* Now deal with any nested transactions.
* As we create, register with the original transactions.
*/
ServerResource nestedAction = null;
for (int i = depth - 2; i >= 0; i--) {
tmpCoord = ctx.parents[i].coord;
tmpTerm = ctx.parents[i].term;
control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
// not current, so don't register
nestedAction = new ServerStrictNestedAction(control, false);
if (!nestedAction.valid()) {
try {
// does dispose as well!
((ServerStrictNestedAction) nestedAction).rollback_subtransaction();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
/*
* Add transaction resource to list.
*/
action.addChild((ServerStrictNestedAction) nestedAction);
action = nestedAction;
}
/*
* Now deal with current transaction. If there is
* only one transaction we do nothing.
*/
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.current.otid), tmpCoord, tmpTerm, control);
// current, so register
nestedAction = new ServerStrictNestedAction(control, true);
if (!nestedAction.valid()) {
try {
// does dispose as well!
((ServerStrictNestedAction) nestedAction).rollback_subtransaction();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
action.addChild((ServerStrictNestedAction) nestedAction);
}
if (jtsLogger.logger.isTraceEnabled())
compareHierarchies(ctx, newElement);
return control;
}
use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.
the class ServerTopLevelActionUnitTest method testCommit.
@Test
public void testCommit() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerTopLevelAction act = new ServerTopLevelAction(sc);
assertEquals(act.prepare(), Vote.VoteReadOnly);
try {
act.commit();
fail();
} catch (final INVALID_TRANSACTION ex) {
}
assertTrue(act.getReference() != null);
}
use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.
the class ServerTopLevelActionUnitTest method testCommitOnePhase.
@Test
public void testCommitOnePhase() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerTopLevelAction act = new ServerTopLevelAction(sc);
act.commit_one_phase();
assertTrue(act.type() != null);
}
Aggregations