In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "Zookeeper Znode case analysis", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Zookeeper Znode case analysis" bar!
Import java.io.IOException;import java.util.List;import org.apache.zookeeper.CreateMode;import org.apache.zookeeper.ZooDefs.Ids;import org.apache.zookeeper.KeeperException;import org.apache.zookeeper.ZooKeeper / * the current creation mode of Zookeeper is: * PPERSISTENT: it persists as long as it is not deleted after creation: EPHEMERAL: the end of the session node is deleted automatically, and EPHEMERAL nodes are not allowed to have child nodes * SEQUENTIAL: a monotonously increasing sequence number of 10 digits is automatically appended at the end of the node name. The sequence numbers of all child nodes of the same node are monotonously increasing * PERSISTENT_SEQUENTIAL: combined with PERSISTENT and SEQUENTIAL * EPHEMERAL_SEQUENTIAL: combined with EPHEMERAL and SEQUENTIAL * * @ author Yin Shuai * / public class SequenceZnode {public static final int TIMEOUT = 3000 Public static void main (String [] args) throws IOException, InterruptedException {ZooKeeper zkp = new ZooKeeper ("127.0.0.1 args 2181", TIMEOUT, null) Try {zkp.create ("/ node1", "data1" .getBytes (), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT) If (zkp.exists ("/ node1", false)! = null) {System.out.println ("node1 exists now") } try {zkp.create ("/ node1", "data1" .getBytes (), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT) } catch (KeeperException e) {System.out.println ("keeperException caught:" + e.getMessage ());} zkp.close () / / zookeeper's session is re-established here zkp = new ZooKeeper ("127.0.0.1 new ZooKeeper 2181", TIMEOUT, null) / / created a series of persistence-sequential nodes zkp.create ("/ node-", "same data" .getBytes (), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL) Zkp.create ("/ node-", "same data" .getBytes (), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL) Zkp.create ("/ node-", "same data" .getBytes (), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL) Zkp.create ("/ node-", "same data" .getBytes (), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL); List children = zkp.getChildren ("/", null) For (String child: children) {System.out.println (child);} zkp.close () } catch (KeeperException e) {System.err.println ("KeeperException have been caught:" + e.getMessage ());}
For each type of node, pay attention to the distinction, especially in the process of repeating create Sequenal nodes. Numbering does not necessarily remain continuous.
Generally speaking, you need to write more than one connection address for 1:Zookeeper.
2:ACL permission is not recursive, it only aims at the current node and has no effect on the child node.
3: by default, log files and data files are placed in the same directory.
4:
By default, log files and data files are placed in the same directory, and to reduce latency and improve responsiveness, you can put log files in a separate directory.
To avoid swaping, it is best to make the available physical internals larger when running java. For example, for 4G internals, you can switch it to 3G. Java has the following two operating parameters:
-Xms
Set the initial size of the available memory heap for the virtual machine, in bytes by default, which is an integral multiple of 1024 and greater than 1MB. You can set a large amount of memory in k (K) or m (M) units. The initial heap size is 2MB.
For example:-Xms6400K,-Xms256M
-Xmx
Sets the maximum available size of the virtual machine memory heap in bytes by default. The value must be an integer multiple of 1024 and greater than 2MB. You can set a large amount of memory in k (K) or m (M) units. The default maximum heap is 64MB.
For example:-Xmx81920K,-Xmx80M
Thank you for your reading, the above is the content of "Zookeeper Znode case analysis", after the study of this article, I believe you have a deeper understanding of the problem of Zookeeper Znode case analysis, and the specific use needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.