use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class PersistenceRecord method topLevelPrepare.
/**
* topLevelPrepare attempts to save the object. It will either do this in
* the action intention list or directly in the object store by using the
* 'deactivate' function of the object depending upon the size of the state.
* To ensure that objects are correctly hidden while they are in an
* uncommitted state if we use the abbreviated protocol then we write an
* EMPTY object state as the shadow state - THIS MUST NOT BE COMMITTED.
* Instead we write_committed the one saved in the intention list. If the
* store cannot cope with being given an empty state we revert to the old
* protocol.
*/
public int topLevelPrepare() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("PersistenceRecord::topLevelPrepare() for " + order());
}
int result = TwoPhaseOutcome.PREPARE_NOTOK;
StateManager sm = super.objectAddr;
if ((sm != null) && (targetParticipantStore != null)) {
/*
* Get ready to create our state to be saved. At this stage we're not
* sure if the state will go into its own log or be written into the
* transaction log for improved performance.
*/
topLevelState = new OutputObjectState(sm.get_uid(), sm.type());
if (writeOptimisation && (!targetParticipantStore.fullCommitNeeded() && (sm.save_state(topLevelState, ObjectType.ANDPERSISTENT)) && (topLevelState.size() <= PersistenceRecord.MAX_OBJECT_SIZE))) {
if (PersistenceRecord.classicPrepare) {
OutputObjectState dummy = new OutputObjectState(Uid.nullUid(), null);
try {
if (targetParticipantStore.write_uncommitted(sm.get_uid(), sm.type(), dummy))
result = TwoPhaseOutcome.PREPARE_OK;
else {
result = TwoPhaseOutcome.PREPARE_NOTOK;
}
} catch (ObjectStoreException e) {
tsLogger.i18NLogger.warn_PersistenceRecord_21(e);
}
dummy = null;
} else {
/*
* Don't write anything as our state will go into the log.
*/
result = TwoPhaseOutcome.PREPARE_OK;
}
} else {
if (sm.deactivate(targetParticipantStore.getStoreName(), false)) {
shadowMade = true;
result = TwoPhaseOutcome.PREPARE_OK;
} else {
topLevelState = null;
tsLogger.i18NLogger.warn_PersistenceRecord_7();
}
}
} else {
tsLogger.i18NLogger.warn_PersistenceRecord_8();
}
return result;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class ObjStoreBrowser method getTypes.
private Collection<String> getTypes() {
Collection<String> allTypes = new ArrayList<String>();
InputObjectState types = new InputObjectState();
try {
if (StoreManager.getRecoveryStore().allTypes(types)) {
while (true) {
try {
String typeName = canonicalType(types.unpackString());
if (typeName.length() == 0)
break;
allTypes.add(typeName);
} catch (IOException e1) {
break;
}
}
}
} catch (ObjectStoreException e) {
if (tsLogger.logger.isTraceEnabled())
tsLogger.logger.trace(e.toString());
}
return allTypes;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class TransactionRecoveryModule method periodicWorkFirstPass.
/**
* This is called periodically by the RecoveryManager
*/
protected void periodicWorkFirstPass() {
jtsLogger.i18NLogger.info_recovery_transactions_TransactionRecoveryModule_11();
// Sanity check - make sure we know what type of transaction we're looking for
if (_transactionType == null) {
jtsLogger.i18NLogger.warn_recovery_transactions_TransactionRecoveryModule_2();
return;
}
// Build a Vector of transaction Uids found in the ObjectStore
_transactionUidVector = new Vector();
InputObjectState uids = new InputObjectState();
boolean anyTransactions = false;
try {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("TransactionRecoveryModule: scanning for " + _transactionType);
}
anyTransactions = _recoveryStore.allObjUids(_transactionType, uids);
} catch (ObjectStoreException e1) {
jtsLogger.i18NLogger.warn_recovery_transactions_TransactionRecoveryModule_4(e1);
}
if (anyTransactions) {
Uid theUid = null;
boolean moreUids = true;
while (moreUids) {
try {
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid())) {
moreUids = false;
} else {
Uid newUid = new Uid(theUid);
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("found transaction " + newUid);
}
_transactionUidVector.addElement(newUid);
}
} catch (Exception e2) {
moreUids = false;
}
}
}
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class WriteCachedTest method test.
@Test
public void test() throws ObjectStoreException {
boolean passed = true;
String cacheSize = "20480";
int threads = 10;
Thread[] t = new Thread[threads];
System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
ParticipantStore store = new CacheStore(new ObjectStoreEnvironmentBean());
long stime = Calendar.getInstance().getTime().getTime();
for (int i = 0; (i < threads) && passed; i++) {
try {
t[i] = new WriterThread(store);
t[i].start();
} catch (Exception ex) {
ex.printStackTrace();
passed = false;
}
}
for (int j = 0; j < threads; j++) {
try {
t[j].join();
passed = passed && ((WriterThread) t[j]).passed;
} catch (Exception ex) {
}
}
long ftime = Calendar.getInstance().getTime().getTime();
long timeTaken = ftime - stime;
System.out.println("time for " + threads + " users is " + timeTaken);
try {
store.sync();
} catch (Exception ex) {
}
assertTrue(passed);
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class AtomicActionRecoveryModule method periodicWorkFirstPass.
/**
* This is called periodically by the RecoveryManager
*/
public void periodicWorkFirstPass() {
// Transaction type
boolean AtomicActions = false;
// uids per transaction type
InputObjectState aa_uids = new InputObjectState();
try {
if (tsLogger.logger.isDebugEnabled()) {
tsLogger.logger.debug("AtomicActionRecoveryModule first pass");
}
AtomicActions = _recoveryStore.allObjUids(_transactionType, aa_uids);
} catch (ObjectStoreException ex) {
tsLogger.i18NLogger.warn_recovery_AtomicActionRecoveryModule_1(ex);
}
if (AtomicActions) {
_transactionUidVector = processTransactions(aa_uids);
}
}
Aggregations