/** * Used for failure recovery. * * @param actId * the transaction state to recover. */ public TransactionImple(Uid actId) { super(new SubordinateAtomicAction(actId)); // don't put it into list here: it may already be there! }
/** * The type of the class is used to locate the state of the transaction log * in the object store. * * Overloads BasicAction.type() * * @return a string representation of the hierarchy of the class for storing * logs in the transaction object store. */ public String type () { return getType(); }
/** * If this is an imported transaction (via JCA) then this will be the Xid we * are pretending to be. Otherwise, it will be null. * * @return null if we are a local transaction, a valid Xid if we have been * imported. */ public final Xid baseXid() { return ((SubordinateAtomicAction) _theTransaction).getXid(); }
private boolean isInStore(Xid xid) { final RecoveryStore recoveryStore = StoreManager.getRecoveryStore(); final InputObjectState states = new InputObjectState(); try { if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && states.notempty()) { boolean finished = false; do { final Uid uid = UidHelper.unpackFrom(states); if (uid.notEquals(Uid.nullUid())) { final SubordinateAtomicAction saa = new SubordinateAtomicAction(uid, true); if (saa.getXid().equals(xid)) { return true; } } else { finished = true; } } while (!finished); } } catch (ObjectStoreException e) { LOG.warn(e.getMessage(), e); } catch (IOException e) { LOG.warn(e.getMessage(), e); } return false; }
public SubordinateAtomicAction(Uid actId, boolean peekXidOnly) throws ObjectStoreException, IOException { super(actId); if (peekXidOnly) { InputObjectState os = StoreManager.getParticipantStore().read_committed(objectUid, type()); unpackHeader(os, new Header()); boolean haveXid = os.unpackBoolean(); if (haveXid) { _theXid = new XidImple(); ((XidImple) _theXid).unpackFrom(os); _parentNodeName = os.unpackString(); } } else { _activated = activate(); } }
public boolean restore_state (InputObjectState os, int t) { _theXid = null; try { unpackHeader(os, new Header()); boolean haveXid = os.unpackBoolean(); if (haveXid) { _theXid = new XidImple(); ((XidImple) _theXid).unpackFrom(os); _parentNodeName = os.unpackString(); } } catch (IOException ex) { return false; } return super.restore_state(os, t); }
@Test public void testAtomicAction () throws Exception { SubordinateAtomicAction saa1 = new SubordinateAtomicAction(); SubordinateAtomicAction saa2 = new SubordinateAtomicAction(new Uid()); OutputObjectState os = new OutputObjectState(); assertTrue(saa1.save_state(os, ObjectType.ANDPERSISTENT)); InputObjectState is = new InputObjectState(os); assertTrue(saa2.restore_state(is, ObjectType.ANDPERSISTENT)); }
@Test public void testSAA() throws Exception { SubordinateAtomicAction saa = new SubordinateAtomicAction(); saa.add(new XAResourceRecord(null, new XAResource() { @Override public void commit(Xid xid, boolean b) throws XAException { saa.doPrepare(); SubordinateAtomicAction saa2 = new SubordinateAtomicAction(saa.get_uid(), true); assertTrue(saa2.getXid() != null); saa.doCommit(); SubordinateAtomicAction saa3 = new SubordinateAtomicAction(saa.get_uid(), true); assertTrue(saa3.getXid() == null); // Since the SAA was committed the transaction log record will have been removed so the xid returned from getXid() should no longer be available and the intention is the SAA creator would disregard this instance
public boolean save_state (OutputObjectState os, int t) { try { // pack the header first for the benefit of the tooling packHeader(os, new Header(get_uid(), Utility.getProcessUid())); if (_theXid != null) { os.packBoolean(true); ((XidImple) _theXid).packInto(os); os.packString(_parentNodeName); } else os.packBoolean(false); } catch (IOException ex) { return false; } return super.save_state(os, t); }
/** * Has the transaction been activated successfully? If not, we wait and try * again later. */ public boolean activated() { return ((SubordinateAtomicAction) _theTransaction).activated(); } }
public String getParentNodeName() { return ((SubordinateAtomicAction)_theTransaction).getParentNodeName(); }
public SubordinateAtomicAction (Uid actId) { super(actId); _activated = activate(); // if this fails, we'll retry later. }
final RecoveryStore recoveryStore = StoreManager.getRecoveryStore(); final InputObjectState states = new InputObjectState(); if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && states.notempty()) { boolean finished = false; final Uid uid = UidHelper.unpackFrom(states); if (uid.notEquals(Uid.nullUid())) { final SubordinateAtomicAction saa = new SubordinateAtomicAction(uid, true); if (saa.getXid().getFormatId() == InboundBridge.XARESOURCE_FORMAT_ID) { uids.add(uid);
/** * Recovery SAA. If the record is removed and peekXidOnly is true then the Xid will be null. * * @param actId * @param peekXidOnly * @throws ObjectStoreException * @throws IOException */ public SubordinateAtomicAction(Uid actId, boolean peekXidOnly) throws ObjectStoreException, IOException { super(actId); if (peekXidOnly) { InputObjectState os = StoreManager.getParticipantStore().read_committed(objectUid, type()); if (os == null) { // This will have been logged by the ObjectStore during ShadowingStore::read_state as an INFO if there was no content return; } unpackHeader(os, new Header()); boolean haveXid = os.unpackBoolean(); if (haveXid) { _theXid = new XidImple(); ((XidImple) _theXid).unpackFrom(os); _parentNodeName = os.unpackString(); } } else { _activated = activate(); } }
public boolean restore_state (InputObjectState os, int t) { _theXid = null; try { unpackHeader(os, new Header()); boolean haveXid = os.unpackBoolean(); if (haveXid) { _theXid = new XidImple(); ((XidImple) _theXid).unpackFrom(os); _parentNodeName = os.unpackString(); } } catch (IOException ex) { return false; } return super.restore_state(os, t); }
public boolean save_state (OutputObjectState os, int t) { try { // pack the header first for the benefit of the tooling packHeader(os, new Header(get_uid(), Utility.getProcessUid())); if (_theXid != null) { os.packBoolean(true); ((XidImple) _theXid).packInto(os); os.packString(_parentNodeName); } else os.packBoolean(false); } catch (IOException ex) { return false; } return super.save_state(os, t); }
/** * Has the transaction been activated successfully? If not, we wait and try * again later. */ public boolean activated() { return ((SubordinateAtomicAction) _theTransaction).activated(); } }
public String getParentNodeName() { return ((SubordinateAtomicAction)_theTransaction).getParentNodeName(); }
public SubordinateAtomicAction (Uid actId) { super(actId); _activated = activate(); // if this fails, we'll retry later. }
RecoveryStore recoveryStore = StoreManager.getRecoveryStore(); InputObjectState states = new InputObjectState(); if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && (states.notempty())) { while (true) { uid = UidHelper.unpackFrom(states); if (uid.notEquals(Uid.nullUid())) { SubordinationManager .getTransactionImporter().recoverTransaction(