@Service public class ZookeeperServiceImpl extends Object implements ZookeeperService
构造器和说明 |
---|
ZookeeperServiceImpl() |
限定符和类型 | 方法和说明 |
---|---|
void |
addWatch(String path,
boolean flag)
对节点增加监听
|
void |
addWatch(String path,
boolean flag,
org.apache.curator.framework.api.CuratorWatcher watcher)
对节点增加监听
|
boolean |
checkExists(String path)
判断节点是否存在
|
String |
createEphemeralNode(String path,
String value)
创建临时节点
session链接断开就没了;
不能创建子节点;
不能同名;
|
String |
createEphemeralSequentialNode(String path,
String value)
创建临时有序节点
session链接断开就没了;
不能创建子节点;
同名节点会在后面添加上序号(分布式锁使用的好处);
|
String |
createNode(String path,
String value)
创建持久节点
session断联、服务端重启还在;
可以创建子节点,子节点可以临时也可以持久;
不能同名;
|
String |
createSequentialNode(String path,
String value)
创建持久有序节点
session断联、服务端重启还在;
可以创建子节点,子节点可以临时也可以持久;
同名节点会在后面添加上序号;
|
boolean |
deleteNode(String path)
删除节点
|
String |
getNodeData(String path)
获取节点数据
|
List<String> |
showChildren(String path)
列出节点下所有的子节点,但是不带子节点的数据
|
Map<String,String> |
showChildrenDetail(String path)
获取指定节点下的所有子节点的名称与值
|
boolean |
updateNode(String path,
String value)
更新节点
|
boolean |
updateNodeAsync(String path,
String value)
异步更新节点
|
public String createNode(String path, String value) throws Exception
ZookeeperService
createNode
在接口中 ZookeeperService
path
- 节点路径value
- 节点数据Exception
public String createSequentialNode(String path, String value) throws Exception
ZookeeperService
createSequentialNode
在接口中 ZookeeperService
path
- 节点路径value
- 节点数据Exception
public String createEphemeralNode(String path, String value) throws Exception
ZookeeperService
createEphemeralNode
在接口中 ZookeeperService
path
- 节点路径value
- 节点数据Exception
public String createEphemeralSequentialNode(String path, String value) throws Exception
ZookeeperService
createEphemeralSequentialNode
在接口中 ZookeeperService
path
- 节点路径value
- 节点数据Exception
public boolean updateNode(String path, String value) throws Exception
ZookeeperService
updateNode
在接口中 ZookeeperService
Exception
public boolean updateNodeAsync(String path, String value) throws Exception
ZookeeperService
updateNodeAsync
在接口中 ZookeeperService
Exception
public boolean deleteNode(String path) throws Exception
ZookeeperService
deleteNode
在接口中 ZookeeperService
Exception
public String getNodeData(String path) throws Exception
ZookeeperService
getNodeData
在接口中 ZookeeperService
Exception
public boolean checkExists(String path) throws Exception
ZookeeperService
checkExists
在接口中 ZookeeperService
Exception
public Map<String,String> showChildrenDetail(String path)
ZookeeperService
showChildrenDetail
在接口中 ZookeeperService
public List<String> showChildren(String path)
ZookeeperService
showChildren
在接口中 ZookeeperService
public void addWatch(String path, boolean flag) throws Exception
ZookeeperService
addWatch
在接口中 ZookeeperService
flag
- 如果是true,就对节点本身监听,如果是false,就对该节点的子节点增加监听Exception
public void addWatch(String path, boolean flag, org.apache.curator.framework.api.CuratorWatcher watcher) throws Exception
ZookeeperService
addWatch
在接口中 ZookeeperService
flag
- 如果是true,就对节点本身监听,如果是false,就对该节点的子节点增加监听watcher
- 监视器Exception