@SuppressWarnings("unchecked") private void initialiseChildMap() { Map<Object, Node<K, V>> childrenMap = node.getChildrenMapDirect(); this.optimisticChildNodeMap = new HashMap(childrenMap); }
/** * Retrieves the names of children for a specific Fqn. * * @param ctx invocation context * @return a Set<Object> of child names, for a given Fqn, or null if the Fqn refers to a node that does not exist. */ @SuppressWarnings("unchecked") @Override public Object perform(InvocationContext ctx) { NodeSPI<?, ?> n = fqn == null ? null : ctx.lookUpNode(fqn); if (n == null || n.isDeleted()) return null; Map<Object, ? extends Node<?, ?>> childrenMap = n.getChildrenMapDirect(); Collection<NodeSPI<?, ?>> children = (Collection<NodeSPI<?, ?>>) (childrenMap.isEmpty() ? Collections.emptySet() : childrenMap.values()); return getCorrectedChildNames(children); }
public Object[] createNodes(Fqn fqn) { List<NodeSPI> result = new ArrayList<NodeSPI>(fqn.size()); Fqn tmpFqn = Fqn.ROOT; int size = fqn.size(); // root node NodeSPI n = root; for (int i = 0; i < size; i++) { Object childName = fqn.get(i); tmpFqn = Fqn.fromRelativeElements(tmpFqn, childName); NodeSPI childNode; Map children = n.getChildrenMapDirect(); childNode = (NodeSPI) children.get(childName); if (childNode == null) { childNode = n.addChildDirect(Fqn.fromElements(childName)); result.add(childNode); } n = childNode; } return new Object[]{result, n}; }
/** * Acquires write locks on the node and all child nodes, adding children to the list of removed nodes in the context. * * @param node node to inspect * @param ctx invocation context * @param transactionContext transaction entry * @throws InterruptedException in the event of interruption */ @SuppressWarnings("unchecked") public void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionContext transactionContext) throws InterruptedException { if (node == null) return; // lock node lockManager.lockAndRecord(node, WRITE, ctx); // add to deleted list if (transactionContext != null) transactionContext.addRemovedNode(node.getFqn()); // now children. Map<Object, NodeSPI> children = node.getChildrenMapDirect(); for (NodeSPI child : children.values()) { // lock child. lockAllForRemoval(child, ctx, transactionContext); } }
Map childNode = underlyingNode.getChildrenMapDirect(); for (Object o : childNode.values())