use of com.arjuna.ats.arjuna.state.InputObjectState 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.state.InputObjectState in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testPackUnpack.
@Test
public void testPackUnpack() throws Exception {
XAResourceRecord xares;
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
OutputObjectState os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class OnePhaseUnitTest method test.
@Test
public void test() throws Exception {
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] obj = new Object[1];
SampleOnePhaseResource res = new SampleOnePhaseResource();
obj[XAResourceRecord.XACONNECTION] = rc;
XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), obj);
OutputObjectState os = new OutputObjectState();
xares.pack(os);
InputObjectState is = new InputObjectState(os);
xares.unpack(is);
}
use of com.arjuna.ats.arjuna.state.InputObjectState 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.state.InputObjectState in project narayana by jbosstm.
the class ExpiredContactScanner method scan.
/**
* This is called periodically by the RecoveryManager
*/
public void scan() {
// calculate the time before which items will be removed
Date oldestSurviving = new Date(new Date().getTime() - _expiryTime * 1000);
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("ExpiredContactScanner - scanning to remove items from before " + _timeFormat.format(oldestSurviving));
}
try {
InputObjectState uids = new InputObjectState();
// find the uids of all the contact items
if (_recoveryStore.allObjUids(_itemTypeName, uids)) {
Uid theUid = null;
boolean endOfUids = false;
while (!endOfUids) {
// extract a uid
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid()))
endOfUids = true;
else {
Uid newUid = new Uid(theUid);
FactoryContactItem anItem = FactoryContactItem.recreate(newUid);
if (anItem != null) {
Date timeOfDeath = anItem.getDeadTime();
if (timeOfDeath != null && timeOfDeath.before(oldestSurviving)) {
jtsLogger.i18NLogger.info_recovery_ExpiredContactScanner_3(newUid);
_recoveryStore.remove_committed(newUid, _itemTypeName);
}
}
}
}
}
} catch (Exception e) {
// end of uids!
}
}
Aggregations