@Override public Region putIfAbsent(Fqn f, Region r) { Region rV = super.putIfAbsent(f, r); if (rV == null) largestFqnLength = Math.max(largestFqnLength, f.size()); return rV; }
@Override public Region put(Fqn f, Region r) { largestFqnLength = Math.max(largestFqnLength, f.size()); return super.put(f, r); }
/** * 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); }
@Override public Region replace(Fqn f, Region r) { Region rV = super.replace(f, r); if (rV != null) largestFqnLength = Math.max(largestFqnLength, f.size()); return rV; }
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(); }
/** * Adds a depth number to the start of the FQN. */ private Fqn withDepth(Fqn name) { return withDepth(name, name.size()); }
/** * Converts an Fqn to a database entry. */ private DatabaseEntry makeKeyEntry(Fqn name) { return makeKeyEntry(name, name.size()); }
@Override public boolean replace(Fqn f, Region oldR, Region newR) { boolean rV = super.replace(f, oldR, newR); if (rV) largestFqnLength = Math.max(largestFqnLength, f.size()); return rV; }
private String key(Fqn fqn) { return key(fqn.size(), fqn).toString(); }
private String children(Fqn fqn) { return key(fqn.size() + 1, fqn).append(SEP).toString(); }
public boolean removeChild(Fqn f) { if (f.size() > 1) throw new UnsupportedOperationException("Workspace nodes can only remove direct children!"); Object key = f.getLastElement(); return removeChild(key); }
@Override public NodeSPI<K, V> getChildDirect(Fqn f) { if (f.size() > 1) { throw new UnsupportedOperationException("Workspace node does not support fetching indirect children"); } return getChildDirect(f.getLastElement()); }
private Node getInternalNode(Node parentNode, Fqn internalFqn) { Fqn parentFqn = parentNode.getFqn(); Object name = internalFqn.get(parentFqn.size()); prepareContextOptions(); Node result = parentNode.getChild(name); if (result != null && internalFqn.size() < result.getFqn().size()) { // need to recursively walk down the tree result = getInternalNode(result, internalFqn); } return result; }
private Node getInternalNode(Node parent, Fqn internalFqn) { Object name = internalFqn.get(parent.getFqn().size()); cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true); Node result = parent.getChild(name); if (result != null && internalFqn.size() < result.getFqn().size()) { // need to recursively walk down the tree result = getInternalNode(result, internalFqn); } return result; }
@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."); } }
protected void marshallFqn(Fqn fqn, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception { boolean isRoot = fqn.isRoot(); out.writeBoolean(isRoot); if (!isRoot) { out.writeShort(fqn.size()); for (Object o : fqn.peekElements()) { marshallObject(o, out, refMap); } } }
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); }
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()); } }
@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 boolean removeChild(Fqn f) { if (f.size() == 1) { return removeChild(f.getLastElement()); } else { NodeSPI<K, V> child = getChildDirect(f); return child != null && child.getParentDirect().removeChildDirect(f.getLastElement()); } }