Create persistent and temporary nodes

ZooKeeper zk=new ZooKeeper(HOST,CLIENT_SESSION_TIMEOUT,new Watcher(){
@Override
public void process(WatchedEvent event) {
logger.info("---watcher--eventtype=="+event.getType());
}
}); // Create persistent nodes
if(zk.exists(LEADER_PATH,false)==null){
zk.create(LEADER_PATH, null,Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
// Create temporary nodes
path=zk.create(LEADER_PATH+"/lock-", null,Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

zookeeper More articles on application examples

  1. python codis Cluster clients ( Two ) - be based on zookeeper Create and extract instances

    In this article, we realized that we didn't pass zk To write the codis colony proxys Of api,http://www.cnblogs.com/kangoroo/p/7481567.html If codis Cluster exposure zk For you ...

  2. IDEA To create a Maven SpringBoot + zookeeper +dubbo example

    summary First statement , This article is a learning summary type of blog content , If they are the same, they are learning . The standard is the main combination zookeeper and dubbo Take a simple example . For the moment , General website architecture with the development of business , Logic is getting more and more complicated , More and more data , Interaction is becoming more and more important ...

  3. Zookeeper Using examples —— Service node management

    In distributed processing , There will always be multiple service nodes working at the same time , And the number of nodes will increase or decrease with the change of network size , Service nodes may also have downtime and recovery . Facing the dynamic increase and decrease of service nodes , How can we ensure that the client's request is handled correctly by the server . We can go through z ...

  4. How to be in Centos7 Installation on zookeeper Multiple instances

    One . How to be in Centos7 Installation on zookeeper Multiple instances cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zoo ...

  5. dubbo+zookeeper+spring example

    The development of Internet , The scale of web applications continues to grow , Conventional vertical application architectures can no longer cope , Distributed service architecture and flow computing architecture are imperative ,Dubbo Is a distributed services framework , Born in this situation . Now the core business is extracted , As an independent service , send ...

  6. maven+dubbo+zookeeper Basis for instance

    1.maven  Introduce dependencies <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ ...

  7. Zookeeper Using examples —— Distributed shared locks

    In the previous lecture, we know that ,Zookeeper By maintaining a distributed directory data structure , Implementing distributed coordination services . This paper mainly introduces the use of Zookeeper Creation and deletion of ordered directories , Implement distributed shared lock . for instance , Performance management system , The alarm rule is only ...

  8. zookeeper Introductory example

    package org.merit.test.zookeepertest; import java.io.IOException;import java.util.List;import java.u ...

  9. Zookeeper Application example

    Configuration Management The program always needs to be configured , If the program is distributed across multiple machines , It's difficult to change the configuration one by one . ok , Now put all these configurations in zookeeper Up , Save in Zookeeper In a directory node of , And then all the related applications ...

Random recommendation

  1. jQuery+HTML5 Pop up the creative search box layer

    Effect experience :http://hovertree.com/texiao/jquery/26/ This effect applies to mobile devices , You can use mobile phones and other browsing effects . The code download :http://hovertree.com/h/bjaf ...

  2. iOS And initialize And load

    initialize and load When are these two methods called ? What kind of function does it have , Let's take a look at it ! initialize +(void)initialize{ } When to call : When using this class for the first time ...

  3. HTML The parent window opens the child window , And returns the value... From the subwindow

    The parent window :windowdemo.html <html> <head> <title> Receive the content returned by the subwindow </title> <script lan ...

  4. js The rigorous model of

    One . How to use it? <script type="text/javascript"> "use strict";     // On the first line of the script file , The whole script will be written in ...

  5. [Javascript] Creating an Immutable Object Graph with Immutable.js Map()

    Learn how to create an Immutable.Map() through plain Javascript object construction and also via arr ...

  6. RHEL7 and RHEL6 The main changes

    RHEL7 and RHEL6 The main changes   RHEL7 RHEL6 file system XFS EXT4 Kernel version 3.10.x-x series 2.6.x-x series Kernel name Maipo Santiago Release time 2014 ...

  7. UESTC_ Mr. Fang bought a watch CDOJ 885

    The teacher bought a watch Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Stat ...

  8. Redis Optimize query performance

    One time use Redis Practice of optimizing query performance   Application background There's an app that needs to upload a set of ID Go to the server to query these ID Corresponding data , The amount of data stored in the database is 7 Ten million , Every time I upload ID The quantity is usually hundreds to thousands . before ...

  9. Python operation MYSQL

    This paper introduces Python operation MYSQL. perform SQL sentence . Get the result set . Traversal result set . Get a word paragraph . Get the table field name . Insert the picture into the database . Implementation of transactions and other code examples and detailed introduction , Most codes , It's a rich and beautiful generation ...

  10. python3+ Regular expression crawling The cat's eye film

    '''Request+ Regular expressions grab cat's eye movies TOP100 Content ''' import requests from requests.exceptions import RequestException i ...