/** * Retrieve host/port pair from the Object Store. */ private boolean restore_state ( InputObjectState objstate ) { boolean ret_status = false ; try { _host = objstate.unpackString() ; _port = objstate.unpackInt() ; _markedDead = objstate.unpackBoolean() ; if ( _markedDead ) { long deadtime = objstate.unpackLong() ; _deadTime = new Date( deadtime ) ; } ret_status = true ; } catch ( IOException ex ) { tsLogger.i18NLogger.warn_recovery_TransactionStatusManagerItem_3(ex); } return ret_status ; }
private static Set<Uid> getUids(Set<Uid> uids, String type) { try { RecoveryStore recoveryStore = StoreManager.getRecoveryStore(); InputObjectState states = new InputObjectState(); if (recoveryStore.allObjUids(type, states) && states.notempty()) { boolean finished = false; do { Uid uid = UidHelper.unpackFrom(states); if (uid.notEquals(Uid.nullUid())) { uids.add(uid); } else { finished = true; } } while (!finished); } } catch (Exception e) { e.printStackTrace(); } return uids; }
void unpackHeader(InputObjectState os) throws IOException { if (os != null) { state = os.unpackString(); byte[] txIdBytes = os.unpackBytes(); txId = new Uid(txIdBytes); if (state.equals("#ARJUNA#")) { if (!txId.equals(Uid.nullUid())) { byte[] pUidBytes = os.unpackBytes(); processUid = new Uid(pUidBytes); } birthDate = os.unpackLong(); } } }
protected HeaderState unpackHeader(InputObjectState os) throws IOException { boolean haveRecCoord = os.unpackBoolean(); if (haveRecCoord) os.unpackString(); // read ior return super.unpackHeader(os); } }
public final InputObjectState allObjUids () throws ObjectStoreException { OutputObjectState state = new OutputObjectState(); Iterator<Uid> iter = _ids.keySet().iterator(); try { while (iter.hasNext()) { UidHelper.packInto(iter.next(), state); } // don't forget to null terminate UidHelper.packInto(Uid.nullUid(), state); } catch (final IOException ex) { throw new ObjectStoreException(ex); } return new InputObjectState(state); }
private int getUidsCountInStore() throws Exception { final InputObjectState uids = new InputObjectState(); recoveryStore.allObjUids(ATOMIC_ACTION_TYPE, uids); int counter = 0; for (Uid uid = UidHelper.unpackFrom(uids); !uid.equals(Uid.nullUid()); uid = UidHelper.unpackFrom(uids)) { counter++; } return counter; }
public Durable2PCParticipant recreate(String id, byte[] recoveryState) throws Exception { if (id.startsWith(SubordinateATCoordinator.PARTICIPANT_PREFIX)) { InputObjectState ios = new InputObjectState(); ios.setBuffer(recoveryState); String className = ios.unpackString(); Class participantClass = this.getClass().getClassLoader().loadClass(className); Durable2PCParticipant participant = (Durable2PCParticipant)participantClass.newInstance(); ((PersistableParticipant)participant).restoreState(ios); return participant; } return null; }
public boolean restore_state(InputObjectState os, int t) { InputObjectState copy = new InputObjectState(os); try { heuristic = copy.unpackInt(); } catch (IOException e) { } return super.restore_state(os, t); }
public InputObjectState getIOS() { if (getBuff() == null || getBuff().length == 0) return null; Uid u = getNewUid() == null ? Uid.nullUid() : getNewUid(); String t = gettName() == null ? "" : gettName(); byte[] b = getBuff() == null ? new byte[0] : getBuff(); return new InputObjectState(u, t, b); }
public boolean restore_state (InputObjectState os, int ot) { boolean res = true; try { objectUid = UidHelper.unpackFrom(os); typeName = os.unpackString(); res = (res && super.restore_state(os, ot)); } catch (final Exception e) { res = false; } return res; }
public RecoverConnectableAtomicAction(String type, Uid rcvUid, InputObjectState os) throws ObjectStoreException, IOException { super(rcvUid); this.recoveringAs = type; // Unpack BasicAction::save_state preamble Header hdr = new Header(); unpackHeader(os, hdr); os.unpackBoolean(); // FYI pastFirstParticipant // Take a look at the first record type int record_type = os.unpackInt(); if (record_type == RecordType.COMMITMARKABLERESOURCE) { // Its one we are interested in jndiName = os.unpackString(); xid = XidImple.unpack(os); hasCompleted = os.unpackBoolean(); } }
public boolean restoreState(InputObjectState os) { InputObjectState copy = new InputObjectState(os); try { heuristic = copy.unpackInt(); committed = copy.unpackBoolean(); xidImple = new XidImple(XidImple.unpack(copy)); return super.restoreState(os); } catch (IOException e) { return false; } }
public final boolean unpackFrom(InputObjectState os) { boolean result = false; try { if (_theXid == null) _theXid = new XID(); _theXid.formatID = os.unpackInt(); _theXid.gtrid_length = os.unpackInt(); _theXid.bqual_length = os.unpackInt(); _theXid.data = os.unpackBytes(); hashCode = getHash(_theXid); result = true; } catch (Exception e) { result = false; } return result; }
public ObjectStateWrapper allTypes() throws ObjectStoreException { InputObjectState ios = new InputObjectState(); boolean ok = rs.allTypes(ios); return new ObjectStateWrapper(ios, ok); }
/** * 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 ) ; } }
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 ObjectStateWrapper allObjUids(String type) throws ObjectStoreException { InputObjectState ios = new InputObjectState(); boolean ok = rs.allObjUids (type, ios); return new ObjectStateWrapper(ios, ok); }
@Test public void testPackUnpack () throws Exception { DummyXA res = new DummyXA(false); XidImple xid = new XidImple(new Uid()); XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null); OutputObjectState os = new OutputObjectState(); xares.pack(os); InputObjectState is = new InputObjectState(os); xares.unpack(is); } }
/** * restore the endpoint reference to the coordinator for this participant */ protected void restoreEndpointReference(InputObjectState ios) throws IOException { String endpointString = ios.unpackString(); Source source = new StreamSource(new StringReader(endpointString)); endpoint = new W3CEndpointReference(source); }