当前位置: 首页>>代码示例>>Java>>正文


Java ZooKeeper.setACL方法代码示例

本文整理汇总了Java中org.apache.zookeeper.ZooKeeper.setACL方法的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeper.setACL方法的具体用法?Java ZooKeeper.setACL怎么用?Java ZooKeeper.setACL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.ZooKeeper的用法示例。


在下文中一共展示了ZooKeeper.setACL方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSuperACL

import org.apache.zookeeper.ZooKeeper; //导入方法依赖的package包/类
@Test
public void testSuperACL() throws Exception {
	 ZooKeeper zk = createClient();
     try {
         zk.addAuthInfo("digest", "pat:pass".getBytes());
         zk.create("/path1", null, Ids.CREATOR_ALL_ACL,
                 CreateMode.PERSISTENT);
         zk.close();
         // verify super can do anything and ignores ACLs
         zk = createClient();
         zk.addAuthInfo("digest", "super:test".getBytes());
         zk.getData("/path1", false, null);
         
         zk.setACL("/path1", Ids.READ_ACL_UNSAFE, -1);
         zk.create("/path1/foo", null, Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
       
         
         zk.setACL("/path1", Ids.OPEN_ACL_UNSAFE, -1);
    	 
     } finally {
         zk.close();
     }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:AuthTest.java

示例2: preAuth

import org.apache.zookeeper.ZooKeeper; //导入方法依赖的package包/类
public void preAuth() throws Exception {
    ZooKeeper zk = createClient();
    zk.addAuthInfo("key", "25".getBytes());
    try {
        createNodePrintAcl(zk, "/pre", "testPreAuth");
        zk.setACL("/", Ids.CREATOR_ALL_ACL, -1);
        zk.getChildren("/", false);
        zk.create("/abc", null, Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
        zk.setData("/abc", "testData1".getBytes(), -1);
        zk.create("/key", null, Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
        zk.setData("/key", "5".getBytes(), -1);
        Thread.sleep(1000);
    } catch (KeeperException e) {
        Assert.fail("test failed :" + e);
    } finally {
        zk.close();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:19,代码来源:KeyAuthClientTest.java

示例3: resetAcls

import org.apache.zookeeper.ZooKeeper; //导入方法依赖的package包/类
private static void resetAcls(final ZooKeeperWatcher zkw, final String znode,
    final boolean eraseAcls) throws Exception {
  List<String> children = ZKUtil.listChildrenNoWatch(zkw, znode);
  if (children != null) {
    for (String child: children) {
      resetAcls(zkw, ZKUtil.joinZNode(znode, child), eraseAcls);
    }
  }

  ZooKeeper zk = zkw.getRecoverableZooKeeper().getZooKeeper();
  if (eraseAcls) {
    LOG.info(" - erase ACLs for " + znode);
    zk.setACL(znode, ZooDefs.Ids.OPEN_ACL_UNSAFE, -1);
  } else {
    LOG.info(" - set ACLs for " + znode);
    zk.setACL(znode, ZKUtil.createACL(zkw, znode, true), -1);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:ZkAclReset.java

示例4: testDisconnectedAddAuth

import org.apache.zookeeper.ZooKeeper; //导入方法依赖的package包/类
@Test
public void testDisconnectedAddAuth() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    try {
        LOG.info("starting up the zookeeper server .. waiting");
        Assert.assertTrue("waiting for server being up",
                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
        try {
            zk.addAuthInfo("digest", "pat:test".getBytes());
            zk.setACL("/", Ids.CREATOR_ALL_ACL, -1);
        } finally {
            zk.close();
        }
    } finally {
        f.shutdown();
        zks.shutdown();
        Assert.assertTrue("waiting for server down",
                ClientBase.waitForServerDown(HOSTPORT,
                        ClientBase.CONNECTION_TIMEOUT));
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:29,代码来源:ACLTest.java

示例5: testDisconnectedAddAuth

import org.apache.zookeeper.ZooKeeper; //导入方法依赖的package包/类
@Test
public void testDisconnectedAddAuth() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    try {
        LOG.info("starting up the zookeeper server .. waiting");
        Assert.assertTrue("waiting for server being up",
                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
        ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
        try {
            zk.addAuthInfo("digest", "pat:test".getBytes());
            zk.setACL("/", Ids.CREATOR_ALL_ACL, -1);
        } finally {
            zk.close();
        }
    } finally {
        f.shutdown();
        zks.shutdown();
        Assert.assertTrue("waiting for server down",
                ClientBase.waitForServerDown(HOSTPORT,
                        ClientBase.CONNECTION_TIMEOUT));
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:29,代码来源:ACLTest.java


注:本文中的org.apache.zookeeper.ZooKeeper.setACL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。