Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the node quota, quota management tree and status information in zk?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "what are the node quota, quota management tree and status information in zk". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Qutas mainly completes the definition of quota directory:

Limit the required size of the information that contains a path

The directory structure in zk is / zookeeper/quota/xxx/zookeeper_limits

The status information contains the actual size of a path

/ zookeeper/quota/xxx/zookeeper_stats

And provide restricted path and state path methods corresponding to path transition

Provide a definition for processing quotas

Quotas classpath org.apache.zookeeper

Attribute

/ * * the zookeeper nodes that acts as the management and status node * * / public static final String procZookeeper = "/ zookeeper"; / * * the zookeeper quota node that acts as the quota * management node for zookeeper * / public static final String quotaZookeeper = "/ zookeeper/quota"; / * * the limit node that has the limit of * a subtree * / public static final String limitNode = "zookeeper_limits"; / * * the stat node that monitors the limit of * a subtree. * / public static final String statNode = "zookeeper_stats"; method / * * return the quota path associated with this * prefix * @ param path the actual path in zookeeper. * @ return the limit quota path * / public static String quotaPath (String path) {return quotaZookeeper + path + "/" + limitNode;} / * * return the stat quota path associated with this * prefix. * @ param path the actual path in zookeeper * @ return the stat quota path * / public static String statPath (String path) {return quotaZookeeper + path + "/" + statNode;} PathTrie dictionary tree completes quota directory addition, deletion and lookup path lookup internal class TrieNode attribute final String value;final Map children;boolean property;// node sets quota, attribute is true, otherwise it is falseTrieNode parent Method / / add child node void addChild (String childName, TrieNode node) {this.children.putIfAbsent (childName, node);} / * Delete child from this node. * delete child node * @ param childName the name of the child to be deleted * / void deleteChild (String childName) {this.children.computeIfPresent (childName, (key, childNode)-> {/ / Node no longer has an external property associated childNode.setProperty (false); / / Delete it if it has no children (is a leaf node) if (childNode.isLeafNode ()) {childNode.setParent (null); return null } return childNode;});} Construction method: public PathTrie () {this.rootNode = new TrieNode (null, "/");} method / * Add a path to the path trie. All paths are relative to the root node. * * @ param path the path to add to the trie * / public void addPath (final String path) {Objects.requireNonNull (path, "Path cannot be null"); final String [] pathComponents = StringUtils.split (path,'/'); if (pathComponents.length = = 0) {throw new IllegalArgumentException ("Invalid path:" + path);} writeLock.lock (); try {TrieNode parent = rootNode For (final String part: pathComponents) {TrieNode child = parent.getChild (part); if (child = = null) {child = new TrieNode (parent, part); parent.addChild (part, child);} parent = child;} parent.setProperty (true);} finally {writeLock.unlock () }} / * * Return true if the given path exists in the trie, otherwise return false; * All paths are relative to the root node. * * @ param path the input path * @ return the largest prefix for the * / public boolean existsNode (final String path) {Objects.requireNonNull (path, "Path cannot be null"); final String [] pathComponents = StringUtils.split (path,'/'); if (pathComponents.length = = 0) {throw new IllegalArgumentException ("Invalid path:" + path);} readLock.lock (); try {TrieNode parent = rootNode For (final String part: pathComponents) {if (parent.getChild (part) = = null) {/ / the path does not exist return false;} parent = parent.getChild (part); LOG.debug ("{}", parent);}} finally {readLock.unlock ();} return true } StatsTrack records the actual count and bytes length information attributes of the node private int count;private long bytes;private String countStr = "count"; private String byteStr = "bytes"; public String toString () {return countStr + "=" + count + "," + byteStr + "=" + bytes;} "what the node quota, quota management tree and status information are respectively". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report