@Override protected UnversionedNode<K, V> createInternalNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data) { PessimisticUnversionedNode<K, V> internal = new PessimisticUnversionedNode<K, V>(childName, fqn, data, cache); internal.injectDependencies(cache, commandsFactory, this); internal.injectLockStrategyFactory(lockStrategyFactory); return internal; } }
@Override public NodeSPI<K, V> addChildDirect(Fqn f) { return addChildDirect(f, true); }
@Override public void setValid(boolean valid, boolean recursive) { setFlag(VALID, valid); if (trace) log.trace("Marking node " + getFqn() + " as " + (valid ? "" : "in") + "valid"); if (recursive) { for (Node<K, V> child : children().values()) { ((NodeSPI<K, V>) child).setValid(valid, recursive); } } }
@SuppressWarnings("unchecked") @Override public InternalNode<K, V> copy() { PessimisticUnversionedNode<K, V> n = new PessimisticUnversionedNode<K, V>(fqn.getLastElement(), fqn, data, cache); copyInternals(n); n.children = children; n.lockStrategyFactory = lockStrategyFactory; n.commandsFactory = commandsFactory; n.nodeFactory = nodeFactory; return n; }
@Override public void setFqn(Fqn fqn) { if (trace) { log.trace(getFqn() + " set FQN " + fqn); } this.fqn = fqn; if (children == null) { return; } // invoke children for (Map.Entry<Object, ? extends Node<K, V>> me : children().entrySet()) { NodeSPI<K, V> n = (NodeSPI<K, V>) me.getValue(); Fqn cfqn = Fqn.fromRelativeElements(fqn, me.getKey()); n.setFqn(cfqn); } }
@Override public Map<Object, Node<K, V>> getChildrenMapDirect() { return children(); }
/** * Adds details of the node into a map as strings. */ @Override protected void printDetailsInMap(StringBuilder sb, int indent) { printIndent(sb, indent); indent += 2;// increse it sb.append(Fqn.SEPARATOR); if (!fqn.isRoot()) sb.append(fqn.getLastElement()); sb.append(" "); sb.append(data); for (Node n : children().values()) { sb.append("\n"); ((NodeSPI) n).printDetails(sb, indent); } }
@Override public NodeSPI<K, V> getOrCreateChild(Object childName, GlobalTransaction gtx) { return getOrCreateChild(childName, gtx, true, true, null); }
@Override public Map getInternalState(boolean onlyInternalState) { Map state = super.getInternalState(onlyInternalState); state.put(DATA_VERSION_INTERNAL_KEY, version); return state; }
@SuppressWarnings("unchecked") @Override public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval) { if (includeMarkedForRemoval) { if (children != null && !children.isEmpty()) { return Immutables.immutableSetConvert(children.values()); } else { return Collections.emptySet(); } } else { return getChildrenDirect(); } }
@Override public NodeSPI<K, V> getChildDirect(Fqn fqn) { if (fqn.size() == 1) { return getChildDirect(fqn.getLastElement()); } else { NodeSPI<K, V> currentNode = delegate; for (int i = 0; i < fqn.size(); i++) { Object nextChildName = fqn.get(i); currentNode = currentNode.getChildDirect(nextChildName); if (currentNode == null) return null; } return currentNode; } }
currentNode = parentInternalNode.addChildAndAcquireLock(childName, !skipNotification, new LockAcquirer(ctx, WRITE, timeout, owner)); skipLockAcquire = true; if (!created)
@Override public void addChildDirect(NodeSPI<K, V> child) { Fqn childFqn = child.getFqn(); if (childFqn.isDirectChildOf(fqn)) { synchronized (this) { children().put(child.getFqn().getLastElement(), child); } } else throw new CacheException("Attempting to add a child [" + child.getFqn() + "] to [" + getFqn() + "]. Can only add direct children."); }
@Override public NodeSPI<K, V> getChildDirect(Object childName) { if (childName == null) return null; return (NodeSPI<K, V>) children().get(childName); }
@Override public NodeSPI<K, V> addChildDirect(Object o, boolean notify) { GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction(); return getOrCreateChild(o, gtx, true, notify, null); }
@Override public void addChildDirect(Object nodeName, Node<K, V> nodeToAdd) { if (nodeName != null) { children().put(nodeName, nodeToAdd); } }
public NodeSPI<K, V> addChildAndAcquireLock(Object o, boolean notify, PessimisticNodeBasedLockManager.LockAcquirer la) { GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction(); return getOrCreateChild(o, gtx, true, notify, la); }
@Override public void setChildrenMapDirect(Map<Object, Node<K, V>> children) { if (children == null) this.children = null; else { this.children.clear(); this.children().putAll(children); } }
@Override public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify) { if (f.size() == 1) { GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction(); return getOrCreateChild(f.getLastElement(), gtx, true, notify, null); } else { throw new UnsupportedOperationException("Cannot directly create children which aren't directly under the current node."); } }