use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class ParticipantsManagerImpl method enlistParticipant.
private String enlistParticipant(final String participantUrl, final String participantEnlistmentURL) {
TxSupport txSupport = new TxSupport();
String participantLinkHeader = txSupport.makeTwoPhaseAwareParticipantLinkHeader(participantUrl, participantUrl);
final String recoveryUrl;
try {
recoveryUrl = txSupport.enlistParticipant(participantEnlistmentURL, participantLinkHeader);
} catch (HttpResponseException e) {
throw new ParticipantException("Failed to enlist participant", e);
}
return recoveryUrl;
}
use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class ParticipantsManagerImpl method enlistVolatileParticipant.
private void enlistVolatileParticipant(final String participantUrl, final String volatileParticipantEnlistmentURL) {
final StringBuilder linkHeader = new StringBuilder();
linkHeader.append("<").append(participantUrl).append(">; rel=\"").append(TxLinkNames.VOLATILE_PARTICIPANT).append("\"");
final String participantLinkHeader = linkHeader.toString();
try {
new TxSupport().enlistVolatileParticipant(volatileParticipantEnlistmentURL, participantLinkHeader);
} catch (HttpResponseException e) {
throw new ParticipantException("Failed to enlist volatile participant", e);
}
}
use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class CoordinatorTest method test2PCRollbackWithoutResponse.
@Test
public void test2PCRollbackWithoutResponse() throws Exception {
TxSupport txn = new TxSupport();
String pUrl = PURL;
String[] pid = new String[2];
String[] pVal = new String[2];
for (int i = 0; i < pid.length; i++) {
pid[i] = modifyResource(txn, pUrl, null, "p1", "v1");
pVal[i] = getResourceProperty(txn, pUrl, pid[i], "p1");
Assert.assertEquals(pVal[i], "v1");
}
txn.startTx();
for (int i = 0; i < pid.length; i++) {
enlistResource(txn, PURL_NO_RESPONSE + "?pId=" + pid[i]);
modifyResource(txn, pUrl, pid[i], "p1", "v2");
pVal[i] = getResourceProperty(txn, pUrl, pid[i], "p1");
Assert.assertEquals(pVal[i], "v2");
}
String status = txn.rollbackTx();
for (int i = 0; i < pid.length; i++) {
pVal[i] = getResourceProperty(txn, pUrl, pid[i], "p1");
Assert.assertEquals(pVal[i], "v1");
}
}
use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class CoordinatorTest method test1PCCommitUnaware.
@Test
public void test1PCCommitUnaware() throws Exception {
TxSupport txn = new TxSupport();
String pUrl = PURL;
String pid = null;
String pVal;
pid = modifyResource(txn, pUrl, pid, "p1", "v1");
pVal = getResourceProperty(txn, pUrl, pid, "p1");
Assert.assertEquals("intial value for key " + pid + " was set now checking it", pVal, "v1");
txn.startTx();
pid = enlistResource(txn, pUrl + "?pId=" + pid + "&twoPhaseAware=false");
modifyResource(txn, pUrl, pid, "p1", "v2");
pVal = getResourceProperty(txn, pUrl, pid, "p1");
Assert.assertEquals("transaction in run for key " + pid + " we should see already a new value", pVal, "v2");
txn.commitTx();
pVal = getResourceProperty(txn, pUrl, pid, "p1");
Assert.assertEquals("transaction wrote for key " + pid + " but read value is different", pVal, "v2");
String commitCount = getResourceProperty(txn, pUrl, pid, "commitCnt");
Assert.assertEquals("one phase executed thus two-phase commit count expected being 0", "0", commitCount);
String onePhaseCommitCount = getResourceProperty(txn, pUrl, pid, "commitOnePhaseCnt");
Assert.assertEquals("one phase executed thus one-phase commit count expected being 1", "1", onePhaseCommitCount);
}
use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class CoordinatorTest method test1PCAbort.
// 1PC commit abort
@Test
public void test1PCAbort() throws Exception {
TxSupport txn = new TxSupport();
String pUrl = PURL;
String pid = null;
String pVal;
pid = modifyResource(txn, pUrl, pid, "p1", "v1");
pVal = getResourceProperty(txn, pUrl, pid, "p1");
Assert.assertEquals(pVal, "v1");
txn.startTx();
pid = enlistResource(txn, pUrl + "?pId=" + pid);
modifyResource(txn, pUrl, pid, "p1", "v2");
pVal = getResourceProperty(txn, pUrl, pid, "p1");
Assert.assertEquals(pVal, "v2");
txn.rollbackTx();
pVal = getResourceProperty(txn, pUrl, pid, "p1");
Assert.assertEquals(pVal, "v1");
}
Aggregations