public void removeSipApplicationSessionAttributeLocal( String sipApplicationSessionKey, String key) { Fqn<String> fqn = delegate.getSipApplicationSessionFqn(combinedPath_, sipApplicationSessionKey); if (log_.isTraceEnabled()) { log_.trace("Remove attribute from distributed store. Fqn: " + Fqn.fromString(fqn.toString() + "/" + AbstractJBossCacheService.ATTRIBUTE_KEY) + " key: " + key); } cacheWrapper_.removeLocal(Fqn.fromString(fqn.toString() + "/" + AbstractJBossCacheService.ATTRIBUTE_KEY), key); }
/** * Retrieves an Fqn that represents the absolute Fqn of the relative Fqn passed in. * * @param base base Fqn * @param relative relative Fqn * @return an Fqn * @since 2.2.0 */ @SuppressWarnings("unchecked") public static <T> Fqn<T> fromRelativeFqn(Fqn<? extends T> base, Fqn<? extends T> relative) { return new Fqn<T>(base, (T[]) relative.elements); }
String getFullPath(Fqn fqn) { StringBuilder sb = new StringBuilder(rootPath); for (int i = 0; i < fqn.size(); i++) { Object tmp = fqn.get(i); // This is where we convert from Object to String! String tmp_dir = tmp.toString(); // returns tmp.this if it's a String sb.append(tmp_dir).append(".").append(DIR_SUFFIX).append(File.separator); } return sb.toString(); }
/** * Returns true if this Fqn is a <i>direct</i> child of a given Fqn. * * @param parentFqn parentFqn to compare with * @return true if this is a direct child, false otherwise. */ public boolean isDirectChildOf(Fqn<? super E> parentFqn) { return elements.length == parentFqn.size() + 1 && isChildOf(parentFqn); }
/** * Adds a depth number to the start of the FQN. */ private Fqn withDepth(Fqn name, int depth) { Fqn n = Fqn.fromElements(depth); return Fqn.fromRelativeList(n, name.peekElements()); }
/** * 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); }
/** * Monitors cache events and updates the local cache * * @param event */ @NodeRemoved public void nodeRemoved(NodeRemovedEvent event) { if (event.isPre()) return; Fqn fqn = event.getFqn(); Fqn regFqn = getRegionFqn(); if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) { Object key = fqn.get(regFqn.size()); localCache.remove(key); } else if (fqn.equals(regFqn)) { localCache.clear(); } }
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}; }
/** * Monitors cache events and updates the local cache * * @param event */ @NodeModified public void nodeModified(NodeModifiedEvent event) { if (event.isPre()) return; Fqn fqn = event.getFqn(); Fqn regFqn = getRegionFqn(); if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) { Object key = fqn.get(regFqn.size()); localCache.put(key, event.getData().get(ITEM)); } }
/** * 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); } } }
public void nodeRemoved(Fqn fqn) { if (clusteredSipStack.getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG) && fqn.toString().indexOf(SipStackImpl.DIALOG_ROOT) != -1) { clusteredSipStack.getStackLogger().logDebug("sipStack " + clusteredSipStack + " Node removed : " + fqn); } // Fix for Issue 1418 jain sip ha does not removes dialog in local stack // http://code.google.com/p/mobicents/issues/detail?id=1418 if(fqn.size() > 1) { clusteredSipStack.remoteDialogRemoval(fqn.get(1).toString()); } }
public static Fqn<String> getTypeFirstRegionFqn(String regionName, String regionPrefix, String regionType) { Fqn<String> base = Fqn.fromString(regionType); Fqn<String> added = Fqn.fromString(escapeRegionName(regionName, regionPrefix)); return new Fqn<String>(base, added); }
Object childName = null; int currentIndex = -1; int targetFqnSize = fqn.size(); if (System.currentTimeMillis() > expiryTime) throw new TimeoutException("Unable to acquire lock on child node " + Fqn.fromRelativeElements(currentNode.getFqn(), childName) + " after " + timeout + " millis."); if (!fqn.isChildOrEquals(currentNode.getFqn())) // Does this ever happen? Perhaps with a move(), I suppose? - MS childName = fqn.get(currentIndex); currentNode = currentNode.getChildDirect(childName);
private Object handlePutCommand(InvocationContext ctx, DataCommand command, boolean zeroAcquisitionTimeout) throws Throwable { if ((ctx.isLockingSuppressed()) || configuration.getIsolationLevel() == IsolationLevel.NONE) { if (trace) log.trace("Suppressing locking, creating nodes if necessary"); int treeNodeSize = command.getFqn().size(); NodeSPI n = dataContainer.getRoot(); for (int i = 0; i < treeNodeSize; i++) { Object childName = command.getFqn().get(i); Fqn childFqn = Fqn.fromElements(childName); NodeSPI childNode = n.getChildDirect(childFqn); if (childNode == null) childNode = n.addChildDirect(childFqn); LockUtil.manageReverseRemove(ctx, childNode, true, null, commandsFactory); n = childNode; } } else { lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, true, zeroAcquisitionTimeout, false, true, null, false); } return invokeNextInterceptor(ctx, command); }
/** * Creates a new Fqn whose ancestor has been replaced with the new ancestor passed in. * * @param oldAncestor old ancestor to replace * @param newAncestor nw ancestor to replace with * @return a new Fqn with ancestors replaced. */ public Fqn<E> replaceAncestor(Fqn<E> oldAncestor, Fqn<E> newAncestor) { if (!isChildOf(oldAncestor)) throw new IllegalArgumentException("Old ancestor must be an ancestor of the current Fqn!"); Fqn<E> subFqn = this.getSubFqn(oldAncestor.size(), size()); return Fqn.fromRelativeFqn(newAncestor, subFqn); } }
@Override public Region put(Fqn f, Region r) { largestFqnLength = Math.max(largestFqnLength, f.size()); return super.put(f, r); }
@Override public void nodeCreated(Fqn fqn) { boolean local = ConvergedSessionReplicationContext.isSipLocallyActive(); boolean isBuddy = isBuddyFqn(fqn); int size = fqn.size(); if(isFqnSessionRootSized(size, isBuddy) && isFqnForOurSipapp(fqn, isBuddy)) { logger.debug("following node created " + fqn.toString() + " with name " +fqn.getName()); } if (!fieldBased_ && local) return; }
public void evictDialog(String dialogId) { cache.evict(Fqn.fromElements(dialogRootNode.getFqn(), Fqn.fromString(dialogId))); }
public Fqn getActualFqn(Fqn fqn) { if (!isBackupFqn(fqn)) return fqn; if (fqn.equals(BUDDY_BACKUP_SUBTREE_FQN)) return Fqn.ROOT; // remove the first 2 (or 3 in the case of a dead backup region) elements boolean isDead = isDeadBackupFqn(fqn); int fqnSz = fqn.size(); if (isDead && fqnSz == 2) return Fqn.ROOT; return fqn.getSubFqn(isDead ? 3 : 2, fqnSz); }