Refine search
/** * Overloads Object.equals. */ public final boolean equals (ActionHierarchy other) { boolean same = true; if (currentDepth == other.depth()) { for (int i = 0; i < currentDepth; i++) { if (hierarchy[i].notEquals(other.getActionInfo(i))) { same = false; break; } } } else same = false; return same; }
/** * @return the identity of the lock's current owner (the transaction id). */ public final Uid getCurrentOwner () { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::getCurrentOwner()"); } return owners.getDeepestActionUid(); }
/** * Create a new lock. */ public Lock() { super(ObjectType.NEITHER); currentStatus = LockStatus.LOCKFREE; nextLock = null; lMode = LockMode.WRITE; owners = new ActionHierarchy(0); }
nextLock = null; lMode = lm; owners = new ActionHierarchy(0); BasicAction curr = BasicAction.Current(); ActionHierarchy ah = new ActionHierarchy(1); /* max depth of 1 */ applicUid = new Uid(); applicUid = new Uid(); ah.add(applicUid); owners.copy(ah); owners.copy(curr.getHierarchy());
final int depth = txHier.depth() ; _identifierValues = new String[depth] ; _expiresValues = new int[depth] ; _identifierValues[0] = txHier.getDeepestActionUid().stringForm() ; _expiresValues[0] = hier.activity(hier.size()-1).getTimeout() ; _identifierValues[count] = txHier.getActionUid(index).stringForm() ; _expiresValues[count] = hier.activity(index).getTimeout() ;
/** * Find common prefix in two hierarchies. * * @return the index of the first common ancestor. */ public final int findCommonPrefix (ActionHierarchy oldHierarchy) { if (tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("ActionHierarchy::findCommonPrefix()"); } int common = 0; int max = oldHierarchy.depth(); while ((common < currentDepth) && (common < max) && (hierarchy[common].equals(oldHierarchy.getActionInfo(common)))) { common++; } if (tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("ActionHierarchy::::findCommonPrefix(): prefix is " + common); } return common; }
/** * @return the depth of the current transaction hierarchy. */ public final int hierarchyDepth () { if (currentHierarchy != null) return currentHierarchy.depth(); else return 0; /* should never happen */ }
/** * Insert new entry growing table as needed. * Transaction id will be added as a top-level transaction. * * @return <code>true</code> if successful, <code>false</code> * otherwise. */ public final boolean add (Uid actionId) { return add(actionId, ActionType.TOP_LEVEL); }
/** * Propagate the lock. */ public final void propagate () { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::propagate()"); } owners.forgetDeepest(); currentStatus = LockStatus.LOCKRETAINED; }
/** * Change the transaction hierarchy associated with the lock to that * provided. */ public final void changeHierarchy (ActionHierarchy newOwner) { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::getCurrentOwner()"); } owners.copy(newOwner); if (currentStatus == LockStatus.LOCKFREE) currentStatus = LockStatus.LOCKHELD; }
/** * Overrides Object.toString() */ public String toString () { StringWriter strm = new StringWriter(); strm.write("Lock object : \n"); strm.write("\tunique id is : " + get_uid() + "\n"); strm.write("\tcurrent_status : " + LockStatus.printString(currentStatus)); strm.write("\n\tMode : " + LockMode.stringForm(lMode)); strm.write("\n\tOwner List : \n"); owners.print(new PrintWriter(strm)); return strm.toString(); }
/** * Are the two locks equal? * * @return <code>true</code> if the locks are equal, <code>false</code> * otherwise. */ public boolean equals (Lock otherLock) { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::equals(" + otherLock + ")\n" + "\tLock 1:\n" + this + "\n" + "\tLock 2:\n" + otherLock); } if (this == otherLock) return true; if ((lMode == otherLock.lMode) && (owners.equals(otherLock.owners)) && (currentStatus == otherLock.currentStatus)) { return true; } return false; }
/** * Save the state of a lock object. * * @return <code>true</code> if successful, <code>false</code> otherwise. */ public boolean save_state (OutputObjectState os, int ot) { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::save_state(" + os + ", " + ot + ")"); } try { os.packInt(currentStatus); os.packInt(lMode); owners.pack(os); return os.valid(); } catch (IOException e) { return false; } }
nextLock = null; lMode = lm; owners = new ActionHierarchy(0); BasicAction curr = BasicAction.Current(); ActionHierarchy ah = new ActionHierarchy(1); /* max depth of 1 */ applicUid = new Uid(); applicUid = new Uid(); ah.add(applicUid); owners.copy(ah); owners.copy(curr.getHierarchy());
/** * Find common prefix in two hierarchies. * * @return the index of the first common ancestor. */ public final int findCommonPrefix (ActionHierarchy oldHierarchy) { if (tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("ActionHierarchy::findCommonPrefix()"); } int common = 0; int max = oldHierarchy.depth(); while ((common < currentDepth) && (common < max) && (hierarchy[common].equals(oldHierarchy.getActionInfo(common)))) { common++; } if (tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("ActionHierarchy::::findCommonPrefix(): prefix is " + common); } return common; }
/** * @return the depth of the current transaction hierarchy. */ public final int hierarchyDepth () { if (currentHierarchy != null) return currentHierarchy.depth(); else return 0; /* should never happen */ }
/** * Insert new entry growing table as needed. * Transaction id will be added as a top-level transaction. * * @return <code>true</code> if successful, <code>false</code> * otherwise. */ public final boolean add (Uid actionId) { return add(actionId, ActionType.TOP_LEVEL); }
/** * Propagate the lock. */ public final void propagate () { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::propagate()"); } owners.forgetDeepest(); currentStatus = LockStatus.LOCKRETAINED; }
/** * Change the transaction hierarchy associated with the lock to that * provided. */ public final void changeHierarchy (ActionHierarchy newOwner) { if (txojLogger.logger.isTraceEnabled()) { txojLogger.logger.trace("Lock::getCurrentOwner()"); } owners.copy(newOwner); if (currentStatus == LockStatus.LOCKFREE) currentStatus = LockStatus.LOCKHELD; }
/** * Overrides Object.toString() */ public String toString () { StringWriter strm = new StringWriter(); strm.write("Lock object : \n"); strm.write("\tunique id is : " + get_uid() + "\n"); strm.write("\tcurrent_status : " + LockStatus.printString(currentStatus)); strm.write("\n\tMode : " + LockMode.stringForm(lMode)); strm.write("\n\tOwner List : \n"); owners.print(new PrintWriter(strm)); return strm.toString(); }