private int numNodes(NodeSPI n) { int count = 1;// for n if (n != null) { for (Object child : n.getChildrenDirect()) { count += numNodes((NodeSPI) child); } } return count; }
public String printLockInfo(NodeSPI node) { StringBuilder sb = new StringBuilder("\n"); int indent = 0; for (Object n : node.getChildrenDirect()) { ((NodeSPI) n).getLock().printLockInfo(sb, indent); sb.append("\n"); } return sb.toString(); }
private int numAttributes(NodeSPI n) { int count = 0; for (Object child : n.getChildrenDirect()) { count += numAttributes((NodeSPI) child); } count += n.getDataDirect().size(); return count; }
for (Object n : root.getChildrenDirect())
@Deprecated private List<NodeData> buildNodeDataLegacy(List<NodeData> list, NodeSPI node, boolean mapSafe) { NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect(), mapSafe); list.add(data); for (Object childNode : node.getChildrenDirect()) { buildNodeData(list, (NodeSPI) childNode, true); } return list; }
private int numLocks(NodeSPI n) { if (!started) return 0; int num = 0; if (n != null) { if (lockManager.isLocked(n)) { num++; if (trace) log.trace(n.getFqn() + " locked"); } for (Object cn : n.getChildrenDirect(true)) { num += numLocks((NodeSPI) cn); } } return num; }
private void recursiveAddEvictionNodes(NodeSPI<?, ?> node, List<Fqn> result) { for (NodeSPI<?, ?> child : node.getChildrenDirect()) { recursiveAddEvictionNodes(child, result); } Fqn fqn = node.getFqn(); if (!fqn.isRoot() && !node.isResident()) { result.add(fqn); } }
public void releaseAll(Object owner) { for (NodeSPI n : node.getChildrenDirect()) { n.getLock().releaseAll(owner); } release(owner); }
/** * Adds the Fqn of the node as well as all children and childrens children to the list. */ protected void greedyGetFqns(List<Fqn> list, NodeSPI<?, ?> n, Fqn newBase) { list.add(n.getFqn()); Fqn newFqn = Fqn.fromRelativeElements(newBase, n.getFqn().getLastElement()); list.add(newFqn); for (NodeSPI child : n.getChildrenDirect()) { greedyGetFqns(list, child, newFqn); } }
public void printLockInfo(StringBuilder sb, int indent) { boolean locked = isLocked(); printIndent(sb, indent); sb.append(Fqn.SEPARATOR).append(node.getFqn().getLastElement()); if (locked) { sb.append("\t("); toString(sb); sb.append(")"); } for (NodeSPI n : node.getChildrenDirect()) { sb.append("\n"); n.getLock().printLockInfo(sb, indent + 4); } }
public Set<NodeLock> acquireAll(Object caller, long timeout, LockType lock_type, boolean excludeInternalFqns) throws LockingException, TimeoutException, InterruptedException { boolean acquired; if (lock_type == LockType.NONE || (excludeInternalFqns && node.getCache().getInternalFqns().contains(getFqn()))) { return Collections.emptySet(); } Set<NodeLock> retval = new HashSet<NodeLock>(); acquired = acquire(caller, timeout, lock_type); if (acquired) { retval.add(this); } for (NodeSPI n : node.getChildrenDirect()) { retval.addAll(n.getLock().acquireAll(caller, timeout, lock_type, excludeInternalFqns)); } return retval; }
@Deprecated private void removeLocksForDeadMembers(NodeSPI node, List deadMembers) { Set<GlobalTransaction> deadOwners = new HashSet<GlobalTransaction>(); Object owner = lockManager.getWriteOwner(node); if (isLockOwnerDead(owner, deadMembers)) deadOwners.add((GlobalTransaction) owner); for (Object readOwner : lockManager.getReadOwners(node)) { if (isLockOwnerDead(readOwner, deadMembers)) deadOwners.add((GlobalTransaction) readOwner); } for (GlobalTransaction deadOwner : deadOwners) { boolean localTx = deadOwner.getAddress().equals(getLocalAddress()); boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager); if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner); } // Recursively unlock children for (Object child : node.getChildrenDirect()) { removeLocksForDeadMembers((NodeSPI) child, deadMembers); } }
private boolean childrenLoaded(NodeSPI<?, ?> node) throws Exception { if (!node.isChildrenLoaded() && loader.getChildrenNames(node.getFqn()) != null) return false; for (NodeSPI child : node.getChildrenDirect()) { if (!child.isDataLoaded()) { return false; } if (child.getChildrenDirect().size() > 0) { if (!childrenLoaded(child)) { return false; } } else if (!loaderNoChildren(child.getFqn())) { return false; } } return true; }
for (NodeSPI child : node.getChildrenDirect()) generateNodeDataList(child, list);
if (!n.getChildrenDirect().isEmpty())
/** * Generates NodeAdded notifications for all nodes of the tree. This is * called whenever the tree is initially retrieved (state transfer) */ private void notifyAllNodesCreated(InvocationContext ctx, NodeSPI curr) { if (curr == null) return; ctx.setOriginLocal(false); cache.getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx); cache.getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx); // AND notify that they have been modified!! if (!curr.getKeysDirect().isEmpty()) { cache.getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx); cache.getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getDataDirect(), ctx); } ctx.setOriginLocal(true); Set<NodeSPI> children = curr.getChildrenDirect(); for (NodeSPI n : children) { notifyAllNodesCreated(ctx, n); } }