public final void addChild(InternalNode<K, V> child) { delegate.addChild(child); }
public void addChild(Object nodeName, Node<K, V> nodeToAdd) { node.addChildDirect(nodeName, nodeToAdd); }
public void clearDataDirect() { if (node != null) node.clear(); }
private boolean childrenLoaded(InternalNode<?, ?> node) throws Exception { if (!node.isChildrenLoaded() && loader.getChildrenNames(node.getFqn()) != null) return false; for (InternalNode child : node.getChildren()) { if (!child.isDataLoaded()) { return false; } if (child.hasChildren()) { if (!childrenLoaded(child)) { return false; } } else if (!loaderNoChildren(child.getFqn())) { return false; } } return true; }
/** * 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, InternalNode 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.getKeys().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.getData(), ctx); } ctx.setOriginLocal(true); Set<InternalNode> children = curr.getChildren(); for (InternalNode n : children) notifyAllNodesCreated(ctx, n); }
private void recursiveAddEvictionNodes(InternalNode<?, ?> node, List<Fqn> result) { for (InternalNode child : node.getChildren()) { recursiveAddEvictionNodes(child, result); } Fqn fqn = node.getFqn(); if (!fqn.isRoot() && !node.isResident()) { result.add(fqn); } }
protected void generateNodeDataList(InternalNode<?, ?> node, List<NodeData> list) throws Exception { if (internalFqns.contains(node.getFqn())) { return; } Map attrs; NodeData nd; // first handle the current node attrs = node.getInternalState(false); if (attrs.size() == 0) { nd = new NodeData(node.getFqn()); } else { nd = new NodeData(node.getFqn(), attrs, true); } list.add(nd); // then visit the children for (InternalNode child : node.getChildren()) generateNodeDataList(child, list); } }
integrateTransientState(target.getFqn(), in); target.clear(); target.removeChildren();
InternalNode ancestor = cache.getNode(ancFqn).getDelegationTarget(); Object name = descFqn.get(ancFqn.size()); InternalNode child = ancestor.getChild(name); if (ancFqn.size() == descFqn.size() + 1) InternalNode descendant = cache.getNode(descFqn).getDelegationTarget(); prepareContextOptions(); ancestor.addChild(name, descendant); integrateRetainedNode(child.getFqn(), descFqn);
parentNode.removeChild(fqn.getLastElement()); parentNode.setChildrenLoaded(false); node.getDelegationTarget().clear(); return true;
parent.getDelegationTarget().addChild(ref); Map<Object, InternalNode<?, ?>> childMap = node.getDelegationTarget().getChildrenMap(); List<Fqn> fqnsToBeRemoved = new LinkedList<Fqn>(); fqnsToBeRemoved.add(fqn); for (InternalNode n : childMap.values()) lockForWritingRecursive(n.getFqn(), ctx, fqnsToBeRemoved);
private int numAttributes(InternalNode n) { int count = 0; for (Object child : n.getChildren()) { count += numAttributes((NodeSPI) child); } count += n.getData().size(); return count; }
public InternalNode peekInternalNode(Fqn fqn, boolean includeInvalidNodes) { if (fqn == null || fqn.size() == 0) return rootInternal; InternalNode n = rootInternal; int fqnSize = fqn.size(); for (int i = 0; i < fqnSize; i++) { Object obj = fqn.get(i); n = n.getChild(obj); if (n == null) { return null; } else if (!includeInvalidNodes && !n.isValid()) { return null; } } return n; }
private void removeData(Fqn fqn) { InternalNode n = peekInternalNode(fqn, false); if (n == null) { log.warn("node " + fqn + " not found"); return; } n.clear(); n.setDataLoaded(false); }
/** * Only used with MVCC. */ private void removeLocksForDeadMembers(InternalNode<?, ?> node, List deadMembers) { Set<GlobalTransaction> deadOwners = new HashSet<GlobalTransaction>(); Object owner = lockManager.getWriteOwner(node.getFqn()); if (isLockOwnerDead(owner, deadMembers)) deadOwners.add((GlobalTransaction) owner); // MVCC won't have any read locks. 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 (InternalNode child : node.getChildren()) removeLocksForDeadMembers(child, deadMembers); }
@Stop(priority = 100) public void stop() { started = false; // empty in-memory state if (root != null) { root.clearDataDirect(); root.removeChildrenDirect(); } else if (rootInternal != null) { rootInternal.clear(); rootInternal.removeChildren(); } }
parent.removeChild(fqn.getLastElement()); setValid(false, false); updateNode(fqn, ctx, container); parent.addChild(node, true); // we know this is safe since we calculated the parent from the child. No need to have the parent re-do checks when adding the child again.
public NodeSPI<K, V> getChildDirect(Object childName) { return node.getChildDirect(childName); }
private InternalNode copyNode(InternalNode nodeToCopy) { return nodeToCopy == null ? null : nodeToCopy.copy(); }
public final Set<InternalNode<K, V>> getChildren() { return delegate.getChildren(); }