use of com.arjuna.ats.arjuna.common.Uid in project wildfly by wildfly.
the class TransactionObjectStoreTestCase method testExposeAllLogs.
@Test
public void testExposeAllLogs() throws Exception {
String serviceUrl = managementClient.getRemoteJMXURL().toString();
try {
RecoveryStoreProxy prs = StoreManagerProxy.getRecoveryStore(serviceUrl, null);
// this immediately checks whether we really got a store manager proxy or not
assertNotNull(prs.getStoreName());
// write a log record to the object store
// create a record that by default the tooling does not expose
byte[] data = new byte[10240];
OutputObjectState state = new OutputObjectState();
Uid uid = new Uid();
state.packBytes(data);
assertTrue(prs.write_committed(uid, FOO_TYPE, state));
// probe the log store
cli.sendLine("/subsystem=transactions/log-store=log-store:write-attribute(name=expose-all-logs,value=false)");
cli.sendLine("/subsystem=transactions/log-store=log-store:probe()");
// check the log record is not listed
cli.sendLine("cd /subsystem=transactions/log-store=log-store/transactions");
cli.sendLine("ls");
String ls = cli.readOutput();
assertFalse("Unexpected uid in the log.", ls != null && ls.contains(uid.toString()));
// probe the log store again for all records
cli.sendLine("/subsystem=transactions/log-store=log-store:write-attribute(name=expose-all-logs,value=true)");
cli.sendLine("/subsystem=transactions/log-store=log-store:probe()");
// check the log record is listed
cli.sendLine("cd /subsystem=transactions/log-store=log-store/transactions");
cli.sendLine("ls");
ls = cli.readOutput();
assertTrue("Could not find the expected uid in the log.", ls != null && ls.contains(uid.toString()));
// remove the log record
cli.sendLine("/subsystem=transactions/log-store=log-store/transactions=" + escapeColons(uid.toString()) + ":delete()");
// probe the log store again
cli.sendLine("/subsystem=transactions/log-store=log-store:probe()");
// check the log record is not listed
cli.sendLine("cd /subsystem=transactions/log-store=log-store/transactions");
cli.sendLine("ls");
ls = cli.readOutput();
assertFalse("Unexpected uid in the log after its remove.", ls != null && ls.contains(uid.toString()));
// set back the expose-all-logs attribute
cli.sendLine("/subsystem=transactions/log-store=log-store:write-attribute(name=expose-all-logs,value=false)");
} finally {
StoreManagerProxy.releaseProxy(serviceUrl);
}
}
use of com.arjuna.ats.arjuna.common.Uid in project wildfly by wildfly.
the class BACoordinatorCompletionSuperService method saveData.
/**
* Add an item to a set and enroll a Participant if necessary then pass the call through to the business logic.
*
* @param value the value to add to the set.
* @throws AlreadyInSetException if value is already in the set
* @throws SetServiceException if an error occurred when attempting to add the item to the set.
*/
public void saveData(String value, ServiceCommand... serviceCommands) throws TestApplicationException {
log.trace("[BA COORDINATOR COMPL SERVICE] web method saveData('" + value + "')");
eventLog.foundEventLogName(value);
BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
// transaction context associated with this thread
String transactionId;
try {
transactionId = activityManager.currentTransaction().toString();
} catch (SystemException e) {
throw new RuntimeException("Unable to lookup existing business activity", e);
}
// Lookup existing participant or register new participant (
BACoordinationCompletionParticipant participantBA = BACoordinationCompletionParticipant.getSomeParticipant(transactionId);
if (participantBA != null && ServiceCommand.isPresent(REUSE_BA_PARTICIPANT, serviceCommands)) {
log.trace("[BA COORDINATOR COMPL SERVICE] Re-using the existing participant, already registered for this BA - command set to: " + REUSE_BA_PARTICIPANT);
} else {
try {
// enlist the Participant for this service:
participantBA = new BACoordinationCompletionParticipant(serviceCommands, eventLog, transactionId, value);
BACoordinationCompletionParticipant.recordParticipant(transactionId, participantBA);
log.trace("[BA COORDINATOR COMPL SERVICE] Enlisting a participant into the BA");
BAParticipantManager baParticipantManager = activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participantBA, "BACoordinatorCompletition:" + new Uid().toString());
if (ServiceCommand.isPresent(CANNOT_COMPLETE, serviceCommands)) {
baParticipantManager.cannotComplete();
return;
}
if (ServiceCommand.isPresent(DO_COMPLETE, serviceCommands)) {
throw new RuntimeException("Only ParticipantCompletion participants are supposed to call complete. " + "CoordinatorCompletion participants need to wait to be notified by the coordinator.");
}
} catch (Exception e) {
log.error("[BA COORDINATOR COMPL SERVICE] Participant enlistment failed", e);
throw new RuntimeException("Error enlisting participant", e);
}
}
if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
throw new TestApplicationException("Intentionally thrown Application Exception - service command set to: " + APPLICATION_EXCEPTION);
}
// invoke the back-end business logic
log.trace("[BA COORDINATOR COMPL SERVICE] Invoking the back-end business logic - saving value: " + value);
}
use of com.arjuna.ats.arjuna.common.Uid in project wildfly by wildfly.
the class AtomicTransactionExecutionService method enlistParticipant.
@Override
public void enlistParticipant() throws Exception {
assert currentTransaction != null : "No active transaction";
LOGGER.infof("trying to enlist participant to the transaction %s", currentTransaction);
TransactionManager.getTransactionManager().resume(currentTransaction);
String participantId = new Uid().stringForm();
TransactionParticipant transactionParticipant = new TransactionParticipant(participantId);
TransactionManager.getTransactionManager().enlistForVolatileTwoPhase(transactionParticipant, participantId);
currentTransaction = TransactionManager.getTransactionManager().suspend();
LOGGER.infof("enlisted participant %s", transactionParticipant);
}
Aggregations