congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
PathTrie.findMaxPrefix
Code IndexAdd Tabnine to your IDE (free)

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

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

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: 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: 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: 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.hadoop/zookeeper

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

String lastPrefix = pTrie.findMaxPrefix(path);
if (!rootZookeeper.equals(lastPrefix) && !("".equals(lastPrefix))) {
org.apache.zookeeper.commonPathTriefindMaxPrefix

Javadoc

return the largest prefix for the input path.

Popular methods of PathTrie

  • addPath
    add a path to the path trie
  • deletePath
    delete a path from the trie
  • clear
    clear all nodes

Popular in Java

  • Updating database using SQL prepared statement
  • getExternalFilesDir (Context)
  • getSupportFragmentManager (FragmentActivity)
  • setScale (BigDecimal)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JPanel (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now