本篇内容主要讲解“java操作zookeeper实例代码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“java操作zookeeper实例代码”吧!package com.rxzx.demo;import java.io.IOException;import java.util.List;import org.apache.zookeeper.CreateMode;import org.apache.zookeeper.KeeperException;import org.apache.zookeeper.WatchedEvent;import org.apache.zookeeper.Watcher;import org.apache.zookeeper.ZooDefs.Ids;import org.apache.zookeeper.ZooKeeper;import org.apache.zookeeper.data.Stat;public class ZKDemo { //连接zookeeper的超时时长(毫秒)privat免费主机域名e static final int OUT_TIME=60000;//zookeeper集群连接对象private ZooKeeper zk;//自定义监听事件对象private Watcher wc=new Watcher(){@Overridepublic void process(WatchedEvent event) {// TODO Auto-generated method stubif(event.getType()==Event.EventType.NodeDataChanged){System.out.println(event.getPath()+” “+event.getType());}else{System.out.println(event.getPath()+” “+event.getType());}}};//获取监控对象public Watcher getWatcher(){return this.wc;}//获取zookeeper集群连接对象public ZooKeeper getZooKeeper(){if(zk==null){try {zk=new ZooKeeper(“192.168.2.100:2181,192.168.2.101:2181,192.168.2.102:2181”,OUT_TIME,null);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}return zk;}//关闭zookeeper连接对象public void close(){if(zk!=null){try {zk.close();} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}public static void main(String[] args) {// TODO Auto-generated method stubZKDemo zd=new ZKDemo();try {//获取zookeeper连接对象ZooKeeper zk=zd.getZooKeeper();//遍历node节点的子节点List
这篇文章将为大家详细讲解有关如何查看锁定的session信息脚本,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。 查看当前被阻塞的对象和锁信息SELECT DISTINCT s1.inst_id BlockingInst, s…