public class CuratorClient extends Object
| 构造器和说明 |
|---|
CuratorClient(org.apache.curator.framework.CuratorFrameworkFactory.Builder builder) |
CuratorClient(org.apache.curator.framework.CuratorFrameworkFactory.Builder builder,
String charset) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
acquire(org.apache.curator.framework.recipes.locks.InterProcessLock lock)
加锁
|
void |
acquire(org.apache.curator.framework.recipes.locks.InterProcessLock lock,
long time,
TimeUnit unit)
加锁
|
void |
createNode(org.apache.zookeeper.CreateMode mode,
String path)
创建节点
|
void |
createNode(org.apache.zookeeper.CreateMode mode,
String path,
String nodeData)
创建节点
|
void |
deleteNode(String path)
删除节点数据
|
void |
deleteNode(String path,
Boolean deleteChildre)
删除节点数据
|
List<String> |
getChildren(String path)
获取节点的子节点
|
org.apache.curator.framework.recipes.locks.InterProcessMultiLock |
getMultiLock(List<org.apache.curator.framework.recipes.locks.InterProcessLock> locks)
创建一组任意类型的锁
|
org.apache.curator.framework.recipes.locks.InterProcessMultiLock |
getMultiMutexLock(List<String> paths)
创建一组可重入排他锁
|
org.apache.curator.framework.recipes.locks.InterProcessMutex |
getMutexLock(String path)
创建可重入排他锁
|
String |
getNodeData(String path)
获取指定节点的数据
|
org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock |
getReadWriteLock(String path)
获取读写锁
|
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex |
getSemaphoreMutexLock(String path)
创建排他锁
|
void |
init() |
boolean |
isAcquiredInThisProcess(org.apache.curator.framework.recipes.locks.InterProcessLock lock)
检查是否当前jvm的线程获取了锁
|
boolean |
isExistNode(String path)
判断节点是否存在
|
void |
release(org.apache.curator.framework.recipes.locks.InterProcessLock lock)
释放锁
|
void |
setNodeData(String path,
String data)
设置指定节点的数据
|
void |
stop() |
String |
synNodeData(String path)
获取数据时先同步
|
void |
unwatch(org.apache.curator.framework.recipes.cache.TreeCache cache,
org.apache.curator.framework.recipes.cache.TreeCacheListener listener)
取消监听节点
|
org.apache.curator.framework.recipes.cache.TreeCache |
watch(String path,
org.apache.curator.framework.recipes.cache.TreeCacheListener listener)
监听数据节点的变化情况
|
org.apache.curator.framework.recipes.cache.TreeCache |
watch(String path,
org.apache.curator.framework.recipes.cache.TreeCacheListener listener,
Executor pool)
监听数据节点的变化情况
|
public CuratorClient(org.apache.curator.framework.CuratorFrameworkFactory.Builder builder)
public CuratorClient(org.apache.curator.framework.CuratorFrameworkFactory.Builder builder,
String charset)
public void init()
public void stop()
public void createNode(org.apache.zookeeper.CreateMode mode,
String path,
String nodeData)
mode - 节点类型
1、PERSISTENT 持久化目录节点,存储的数据不会丢失。
2、PERSISTENT_SEQUENTIAL顺序自动编号的持久化目录节点,存储的数据不会丢失
3、EPHEMERAL临时目录节点,一旦创建这个节点的客户端与服务器端口也就是session 超时,这种节点会被自动删除
4、EPHEMERAL_SEQUENTIAL临时自动编号节点,一旦创建这个节点的客户端与服务器端口也就是session 超时,这种节点会被自动删除,并且根据当前已经存在的节点数自动加 1,然后返回给客户端已经成功创建的目录节点名。path - 节点名称nodeData - 节点数据public void createNode(org.apache.zookeeper.CreateMode mode,
String path)
mode - 节点类型
1、PERSISTENT 持久化目录节点,存储的数据不会丢失。
2、PERSISTENT_SEQUENTIAL顺序自动编号的持久化目录节点,存储的数据不会丢失
3、EPHEMERAL临时目录节点,一旦创建这个节点的客户端与服务器端口也就是session 超时,这种节点会被自动删除
4、EPHEMERAL_SEQUENTIAL临时自动编号节点,一旦创建这个节点的客户端与服务器端口也就是session 超时,这种节点会被自动删除,并且根据当前已经存在的节点数自动加 1,然后返回给客户端已经成功创建的目录节点名。path - 节点名称public void deleteNode(String path)
path - 节点名称public void deleteNode(String path, Boolean deleteChildre)
path - 节点名称deleteChildre - 是否删除子节点public boolean isExistNode(String path)
path - 节点名称public org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex getSemaphoreMutexLock(String path)
path - 节点名称public org.apache.curator.framework.recipes.locks.InterProcessMutex getMutexLock(String path)
path - 节点名称public org.apache.curator.framework.recipes.locks.InterProcessMultiLock getMultiMutexLock(List<String> paths)
paths - 节点名称集合public org.apache.curator.framework.recipes.locks.InterProcessMultiLock getMultiLock(List<org.apache.curator.framework.recipes.locks.InterProcessLock> locks)
locks - 锁集合public void acquire(org.apache.curator.framework.recipes.locks.InterProcessLock lock)
lock - 分布式锁对象public void acquire(org.apache.curator.framework.recipes.locks.InterProcessLock lock,
long time,
TimeUnit unit)
lock - 分布式锁对象time - 等待时间unit - 时间单位public void release(org.apache.curator.framework.recipes.locks.InterProcessLock lock)
lock - 分布式锁对象public boolean isAcquiredInThisProcess(org.apache.curator.framework.recipes.locks.InterProcessLock lock)
lock - 分布式锁对象public org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock getReadWriteLock(String path)
path - 节点名称public org.apache.curator.framework.recipes.cache.TreeCache watch(String path, org.apache.curator.framework.recipes.cache.TreeCacheListener listener, Executor pool)
path - 节点名称listener - 监听器pool - 线程池public org.apache.curator.framework.recipes.cache.TreeCache watch(String path, org.apache.curator.framework.recipes.cache.TreeCacheListener listener)
path - 节点名称listener - 监听器public void unwatch(org.apache.curator.framework.recipes.cache.TreeCache cache,
org.apache.curator.framework.recipes.cache.TreeCacheListener listener)
cache - 监听节点的TreeCache实例listener - 监听器Copyright © 2019. All rights reserved.