@Override @SuppressWarnings(value = "unchecked") public boolean isChildOrEquals(Fqn parentFqn) { if (parentFqn.getClass().equals(StringFqn.class)) { StringFqn stringParentFqn = (StringFqn) parentFqn; return stringRepresentation.startsWith(stringParentFqn.stringRepresentation); } else { return super.isChildOrEquals(parentFqn); } }
/** * Returns true if this Fqn is child of parentFqn. Example usage: * <pre> * Fqn<String> f1 = Fqn.fromString("/a/b"); * Fqn<String> f2 = Fqn.fromString("/a/b/c"); * assertTrue(f1.isChildOf(f2)); * assertFalse(f1.isChildOf(f1)); * assertFalse(f2.isChildOf(f1)); * </pre> * * @param parentFqn candidate parent to test against * @return true if the target is a child of parentFqn */ public boolean isChildOf(Fqn<? super E> parentFqn) { return parentFqn.size() != elements.length && isChildOrEquals(parentFqn); }
/** * Returns true if the FQN or parent was removed during the current * transaction. * This is O(N) WRT to the number of modifications so far. */ private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx) { TransactionContext transactionContext = ctx.getTransactionContext(); if (transactionContext == null) return false; for (WriteCommand txCacheCommand : transactionContext.getModifications()) { if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(txCacheCommand.getFqn())) return true; } return false; }
if (!fqn.isChildOrEquals(name))
/** * Monitors cache events and updates the local cache * * @param event */ @NodeRemoved public void nodeRemoved(NodeRemovedEvent event) { if (event.isOriginLocal() || event.isPre()) return; Fqn fqn = event.getFqn(); Fqn regFqn = getRegionFqn(); if (fqn.isChildOrEquals(regFqn)) { if (fqn.size() == regFqn.size()) { localCache.clear(); } else { Object key = fqn.get(regFqn.size()); localCache.remove(key); } } }
/** * Monitors cache events and updates the local cache * * @param event */ @NodeRemoved public void nodeRemoved(NodeRemovedEvent event) { if (event.isOriginLocal() || event.isPre()) return; Fqn fqn = event.getFqn(); Fqn regFqn = getRegionFqn(); if (fqn.isChildOrEquals(regFqn)) { if (fqn.size() == regFqn.size()) { localCache.clear(); } else { Object key = fqn.get(regFqn.size()); localCache.remove(key); } } }
boolean move = target.isChildOrEquals(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && !tferFqn.isChildOrEquals(target);
if (!fqn.isChildOrEquals(currentNode.getFqn())) // Does this ever happen? Perhaps with a move(), I suppose? - MS
boolean move = tgtFqn.isChildOrEquals(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && !tferFqn.isChildOrEquals(tgtFqn);
private boolean removeNode(TransactionWorkspace workspace, WorkspaceNode workspaceNode, boolean notify, InvocationContext ctx) throws CacheException { // it is already removed - we can ignore it if (workspaceNode == null) return false; Fqn parentFqn = workspaceNode.getFqn().getParent(); WorkspaceNode parentNode = fetchWorkspaceNode(ctx, parentFqn, workspace, false, true); if (parentNode == null) throw new NodeNotExistsException("Unable to find parent node with fqn " + parentFqn); // pre-notify if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), true, workspaceNode.getData(), ctx); Fqn nodeFqn = workspaceNode.getFqn(); parentNode.removeChild(nodeFqn.getLastElement()); SortedMap<Fqn, WorkspaceNode> tailMap = workspace.getNodesAfter(workspaceNode.getFqn()); for (WorkspaceNode toDelete : tailMap.values()) { if (toDelete.getFqn().isChildOrEquals(nodeFqn)) { if (trace) log.trace("marking node " + toDelete.getFqn() + " as deleted"); toDelete.setRemoved(true); } else { break;// no more children, we came to the end } } // post-notify if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), false, null, ctx); return workspaceNode.getNode().isValid(); }