zookeeper权限控制

This commit is contained in:
luoxiang
2019-05-25 19:46:26 +08:00
parent 7d717f8a08
commit 2330ba1569
7 changed files with 594 additions and 161 deletions

View File

@ -33,7 +33,7 @@ public class AclOperation {
public void prepare() {
RetryPolicy retryPolicy = new RetryNTimes(3, 5000);
client = CuratorFrameworkFactory.builder()
.authorization("digest", "heibai:123456".getBytes())
.authorization("digest", "heibai:123456".getBytes()) //等价于addauth命令
.connectString(zkServerPath)
.sessionTimeoutMs(10000).retryPolicy(retryPolicy)
.namespace("workspace").build();

View File

@ -113,7 +113,7 @@ public class BasicOperation {
/**
* 判断节点是否存在
* 判断节点是否存在
*/
@Test
public void existNode() throws Exception {
@ -160,7 +160,7 @@ public class BasicOperation {
/**
* 针对子节点注册监听
* 监听子节点的操作
*/
@Test
public void permanentChildrenNodesWatch() throws Exception {
@ -181,7 +181,7 @@ public class BasicOperation {
childrenCache.getListenable().addListener(new PathChildrenCacheListener() {
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) {
switch (event.getType()) {
case INITIALIZED:
System.out.println("childrenCache初始化完成");