zk中的节点配额,配额管理树和状态信息分别是什么
发表于:2025-12-01 作者:千家信息网编辑
千家信息网最后更新 2025年12月01日,本篇内容介绍了"zk中的节点配额,配额管理树和状态信息分别是什么"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够
千家信息网最后更新 2025年12月01日zk中的节点配额,配额管理树和状态信息分别是什么
本篇内容介绍了"zk中的节点配额,配额管理树和状态信息分别是什么"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
Qutas 主要完成配额目录的定义:
限制信息包含某个路径的要求大小
在zk中目录结构为/zookeeper/quota/xxx/zookeeper_limits
状态信息包含对某个路径实际大小
/zookeeper/quota/xxx/zookeeper_stats
以及提供path转换对应的限制path和状态path方法
为处理配额提供定义
Quotas类路径org.apache.zookeeper
属性
/** 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";方法/** * 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 字典树完成配额目录的增删查 路径查找内部类TrieNode属性final String value;final Mapchildren;boolean property;//节点设置了配额,属性为true,否则为falseTrieNode parent;方法//添加子节点void addChild(String childName, TrieNode node) { this.children.putIfAbsent(childName, node);}/** * Delete child from this 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; });} 构造方法:public PathTrie() { this.rootNode = new TrieNode(null, "/");}方法/** * 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 记录节点实际的count和bytes长度信息属性private int count;private long bytes;private String countStr = "count";private String byteStr = "bytes"; public String toString() { return countStr + "=" + count + "," + byteStr + "=" + bytes;}
"zk中的节点配额,配额管理树和状态信息分别是什么"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!
配额
节点
信息
方法
状态
属性
路径
实际
目录
管理
内容
大小
更多
知识
限制
实用
学有所成
接下来
困境
字典
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
数据库对象实体
神魔大陆 服务器间
日照软件开发学习
互联网科技消息观察
软件开发需要必备什么条件
北京品质软件开发设施价格优惠
科技安全和网络安全课
信贷经理抢单软件开发
主题公园下载软件开发
服务器存储管理总结
ios软件开发论坛
超贵服务器
数据库面试左连接右连接
物理服务器扩内存需要重启吗
帆软怎么把excel导入数据库
部分服务器无法通过堡垒机远程
家用服务器云南
外域服务器
现代网络技术期末试题
执法通记录仪软件开发
amesim数据库
自家住宅可以用作服务器机房吗
网络安全执法的公安论文
北京铁路网络安全知识答题答案
软件开发合同甲方反悔
互联网伪科技教学
ios软件开发论坛
浪潮服务器阵列挂了怎么办
四川爱创科技软件开发
电脑时不时无法访问服务器