本文整理汇总了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();
}
}
示例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();
}
}
示例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);
}
}
示例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));
}
}
示例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));
}
}