@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("Entry("); sb.append(getProcId()); sb.append(", parentId="); sb.append(getParentId()); sb.append(", class="); sb.append(proto.getClassName()); sb.append(")"); return sb.toString(); } }
private boolean checkReadyToRun(Entry rootEntry) { assert !rootEntry.hasParent() : "expected root procedure, got " + rootEntry; if (rootEntry.isFinished()) {
public void mergeTail(WalProcedureMap other) { for (Entry p = other.replayOrderHead; p != null; p = p.replayNext) { int slotIndex = getMapSlot(p.getProcId()); p.hashNext = procedureMap[slotIndex]; procedureMap[slotIndex] = p;
public void mergeTail(WalProcedureMap other) { for (Entry p = other.replayOrderHead; p != null; p = p.replayNext) { int slotIndex = getMapSlot(p.getProcId()); p.hashNext = procedureMap[slotIndex]; procedureMap[slotIndex] = p;
public EntryIterator fetchReady() { buildGraph(); Entry readyHead = null; Entry readyTail = null; Entry p = replayOrderHead; while (p != null) { Entry next = p.replayNext; if (p.isReady()) { unlinkFromReplayList(p); if (readyTail != null) { readyTail.replayNext = p; p.replayPrev = readyTail; } else { p.replayPrev = null; readyHead = p; } readyTail = p; p.replayNext = null; } p = next; } // we need the hash-table lookups for parents, so this must be done // out of the loop where we check isReadyToRun() for (p = readyHead; p != null; p = p.replayNext) { removeFromMap(p.getProcId()); unlinkFromLinkList(p); } return readyHead != null ? new EntryIterator(readyHead) : null; }
public EntryIterator fetchReady() { buildGraph(); Entry readyHead = null; Entry readyTail = null; Entry p = replayOrderHead; while (p != null) { Entry next = p.replayNext; if (p.isReady()) { unlinkFromReplayList(p); if (readyTail != null) { readyTail.replayNext = p; p.replayPrev = readyTail; } else { p.replayPrev = null; readyHead = p; } readyTail = p; p.replayNext = null; } p = next; } // we need the hash-table lookups for parents, so this must be done // out of the loop where we check isReadyToRun() for (p = readyHead; p != null; p = p.replayNext) { removeFromMap(p.getProcId()); unlinkFromLinkList(p); } return readyHead != null ? new EntryIterator(readyHead) : null; }
private Entry removeFromMap(final long procId) { int slotIndex = getMapSlot(procId); Entry prev = null; Entry entry = procedureMap[slotIndex]; while (entry != null) { if (procId == entry.getProcId()) { if (prev != null) { prev.hashNext = entry.hashNext; } else { procedureMap[slotIndex] = entry.hashNext; } entry.hashNext = null; return entry; } prev = entry; entry = entry.hashNext; } return null; }
private Entry removeFromMap(final long procId) { int slotIndex = getMapSlot(procId); Entry prev = null; Entry entry = procedureMap[slotIndex]; while (entry != null) { if (procId == entry.getProcId()) { if (prev != null) { prev.hashNext = entry.hashNext; } else { procedureMap[slotIndex] = entry.hashNext; } entry.hashNext = null; return entry; } prev = entry; entry = entry.hashNext; } return null; }
public EntryIterator fetchAll() { Entry head = replayOrderHead; for (Entry p = head; p != null; p = p.replayNext) { removeFromMap(p.getProcId()); } for (int i = 0; i < procedureMap.length; ++i) { assert procedureMap[i] == null : "map not empty i=" + i; } replayOrderHead = null; replayOrderTail = null; childUnlinkedHead = null; rootHead = null; return head != null ? new EntryIterator(head) : null; }
public EntryIterator fetchAll() { Entry head = replayOrderHead; for (Entry p = head; p != null; p = p.replayNext) { removeFromMap(p.getProcId()); } for (int i = 0; i < procedureMap.length; ++i) { assert procedureMap[i] == null : "map not empty i=" + i; } replayOrderHead = null; replayOrderTail = null; childUnlinkedHead = null; rootHead = null; return head != null ? new EntryIterator(head) : null; }
@Override public boolean isNextCompleted() { return current != null && current.isCompleted(); }
@Override public boolean isNextFinished() { return current != null && current.isFinished(); }
public boolean isFinished() { if (!hasParent()) { // we only consider 'root' procedures. because for the user 'finished' // means when everything up to the 'root' is finished. switch (proto.getState()) { case ROLLEDBACK: case SUCCESS: return true; default: break; } } return false; }
public boolean isCompleted() { if (!hasParent()) { switch (proto.getState()) { case ROLLEDBACK: return true; case FINISHED: return !proto.hasException(); default: break; } } return false; }
private Entry addToMap(final long procId, final boolean hasParent) { int slotIndex = getMapSlot(procId); Entry entry = getProcedure(slotIndex, procId); if (entry != null) return entry; entry = new Entry(procedureMap[slotIndex]); procedureMap[slotIndex] = entry; return entry; }
@Override public ProcedureInfo nextAsProcedureInfo() { try { return current.convertToInfo(); } finally { current = current.replayNext; } } }
@Override public String toString() { return "Entry(" + getProcId() + ", parentId=" + getParentId() + ")"; } }
@Override public Procedure nextAsProcedure() throws IOException { try { return current.convert(); } finally { current = current.replayNext; } }
private Entry getProcedure(final int slotIndex, final long procId) { Entry entry = procedureMap[slotIndex]; while (entry != null) { if (procId == entry.getProcId()) { return entry; } entry = entry.hashNext; } return null; }
private Entry getRootProcedure(Entry entry) { while (entry != null && entry.hasParent()) { entry = getProcedure(entry.getParentId()); } return entry; }