Codota Logo
PathTrie
Code IndexAdd Codota to your IDE (free)

How to use
PathTrie
in
org.apache.zookeeper.common

Best Java code snippets using org.apache.zookeeper.common.PathTrie (Showing top 15 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: apache/zookeeper

/**
 * If there is a quota set, return the appropriate prefix for that quota
 * Else return null
 * @param path The ZK path to check for quota
 * @return Max quota prefix, or null if none
 */
public String getMaxPrefixWithQuota(String path) {
  // do nothing for the root.
  // we are not keeping a quota on the zookeeper
  // root node for now.
  String lastPrefix = pTrie.findMaxPrefix(path);
  if (rootZookeeper.equals(lastPrefix) || "".equals(lastPrefix)) {
    return null;
  }
  else {
    return lastPrefix;
  }
}
origin: apache/zookeeper

    .length(), path.indexOf(endString));
updateQuotaForPath(realPath);
this.pTrie.addPath(realPath);
origin: apache/zookeeper

public void deserialize(InputArchive ia, String tag) throws IOException {
  aclCache.deserialize(ia);
  nodes.clear();
  pTrie.clear();
  nodeDataSize.set(0);
  String path = ia.readString("path");
origin: org.apache.hadoop/zookeeper

    pTrie.deletePath(parentName.substring(quotaZookeeper.length()));
String lastPrefix = pTrie.findMaxPrefix(path);
if (!rootZookeeper.equals(lastPrefix) && !("".equals(lastPrefix))) {
origin: org.apache.hadoop/zookeeper

    pTrie.addPath(parentName.substring(quotaZookeeper.length()));
String lastPrefix = pTrie.findMaxPrefix(path);
if (!rootZookeeper.equals(lastPrefix) && !("".equals(lastPrefix))) {
origin: apache/zookeeper

pTrie.deletePath(parentName.substring(quotaZookeeper.length()));
origin: org.apache.zookeeper/zookeeper

pTrie.deletePath(parentName.substring(quotaZookeeper.length()));
origin: org.apache.zookeeper/zookeeper

/**
 * If there is a quota set, return the appropriate prefix for that quota
 * Else return null
 * @param path The ZK path to check for quota
 * @return Max quota prefix, or null if none
 */
public String getMaxPrefixWithQuota(String path) {
  // do nothing for the root.
  // we are not keeping a quota on the zookeeper
  // root node for now.
  String lastPrefix = pTrie.findMaxPrefix(path);
  if (!rootZookeeper.equals(lastPrefix) && !("".equals(lastPrefix))) {
    return lastPrefix;
  }
  else {
    return null;
  }
}
origin: org.apache.zookeeper/zookeeper

    .length(), path.indexOf(endString));
updateQuotaForPath(realPath);
this.pTrie.addPath(realPath);
origin: org.apache.zookeeper/zookeeper

public void deserialize(InputArchive ia, String tag) throws IOException {
  aclCache.deserialize(ia);
  nodes.clear();
  pTrie.clear();
  String path = ia.readString("path");
  while (!path.equals("/")) {
origin: apache/zookeeper

@Test(timeout = 60000)
public void testPathTrieClearOnDeserialize() throws Exception {
  //Create a DataTree with quota nodes so PathTrie get updated
  DataTree dserTree = new DataTree();
  dserTree.createNode("/bug", new byte[20], null, -1, 1, 1, 1);
  dserTree.createNode(Quotas.quotaZookeeper+"/bug", null, null, -1, 1, 1, 1);
  dserTree.createNode(Quotas.quotaPath("/bug"), new byte[20], null, -1, 1, 1, 1);
  dserTree.createNode(Quotas.statPath("/bug"), new byte[20], null, -1, 1, 1, 1);
  //deserialize a DataTree; this should clear the old /bug nodes and pathTrie
  DataTree tree = new DataTree();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
  tree.serialize(oa, "test");
  baos.flush();
  ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  BinaryInputArchive ia = BinaryInputArchive.getArchive(bais);
  dserTree.deserialize(ia, "test");
  Field pfield = DataTree.class.getDeclaredField("pTrie");
  pfield.setAccessible(true);
  PathTrie pTrie = (PathTrie)pfield.get(dserTree);
  //Check that the node path is removed from pTrie
  Assert.assertEquals("/bug is still in pTrie", "", pTrie.findMaxPrefix("/bug"));
}
origin: apache/zookeeper

pTrie.addPath(parentName.substring(quotaZookeeper.length()));
origin: org.apache.hadoop/zookeeper

public Stat setData(String path, byte data[], int version, long zxid,
    long time) throws KeeperException.NoNodeException {
  Stat s = new Stat();
  DataNode n = nodes.get(path);
  if (n == null) {
    throw new KeeperException.NoNodeException();
  }
  byte lastdata[] = null;
  synchronized (n) {
    lastdata = n.data;
    n.data = data;
    n.stat.setMtime(time);
    n.stat.setMzxid(zxid);
    n.stat.setVersion(version);
    n.copyStat(s);
  }
  // now update if the path is in a quota subtree.
  String lastPrefix = pTrie.findMaxPrefix(path);
  // do nothing for the root.
  // we are not keeping a quota on the zookeeper
  // root node for now.
  if (!rootZookeeper.equals(lastPrefix) && !("".equals(lastPrefix))) {
    this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
        - (lastdata == null ? 0 : lastdata.length));
  }
  dataWatches.triggerWatch(path, EventType.NodeDataChanged);
  return s;
}
origin: org.apache.zookeeper/zookeeper

pTrie.addPath(parentName.substring(quotaZookeeper.length()));
origin: org.apache.hadoop/zookeeper

    .length(), path.indexOf(endString));
updateQuotaForPath(realPath);
this.pTrie.addPath(realPath);
org.apache.zookeeper.commonPathTrie

Javadoc

a class that implements prefix matching for components of a filesystem path. the trie looks like a tree with edges mapping to the component of a path. example /ab/bc/cf would map to a trie / ab/ (ab) bc/ / (bc) cf/ (cf)

Most used methods

  • findMaxPrefix
    return the largest prefix for the input path.
  • addPath
    add a path to the path trie
  • deletePath
    delete a path from the trie
  • clear
    clear all nodes

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • getSystemService (Context)
  • setContentView (Activity)
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now