/** * Create a path if it does not exist. * The check is poll + create; there's a risk that another process * may create the same path before the create() operation is executed/ * propagated to the ZK node polled. * * @param path path to create * @param acl ACL for path -used when creating a new entry * @param createParents flag to trigger parent creation * @return true iff the path was created * @throws IOException */ @VisibleForTesting public boolean maybeCreate(String path, CreateMode mode, List<ACL> acl, boolean createParents) throws IOException { return zkMkPath(path, mode, createParents, acl); }
/** * Create a path if it does not exist. * The check is poll + create; there's a risk that another process * may create the same path before the create() operation is executed/ * propagated to the ZK node polled. * * @param path path to create * @param acl ACL for path -used when creating a new entry * @param createParents flag to trigger parent creation * @return true iff the path was created * @throws IOException */ @VisibleForTesting public boolean maybeCreate(String path, CreateMode mode, List<ACL> acl, boolean createParents) throws IOException { return zkMkPath(path, mode, createParents, acl); }
private void mkPath(String path, CreateMode mode) throws IOException { curatorService.zkMkPath(path, mode, false, RegistrySecurity.WorldReadWriteACL); }
private void mkPath(String path, CreateMode mode) throws IOException { curatorService.zkMkPath(path, mode, false, RegistrySecurity.WorldReadWriteACL); }
/** * Recursively make a path. * * @param path path to create * @param acl ACL for path * @throws IOException any problem */ public void zkMkParentPath(String path, List<ACL> acl) throws IOException { // split path into elements zkMkPath(RegistryPathUtils.parentOf(path), CreateMode.PERSISTENT, true, acl); }
/** * Recursively make a path * @param path path to create * @param acl ACL for path * @throws IOException any problem */ public void zkMkParentPath(String path, List<ACL> acl) throws IOException { // split path into elements zkMkPath(RegistryPathUtils.parentOf(path), CreateMode.PERSISTENT, true, acl); }
/** * test that ZK can write as itself * @throws Throwable */ @Test public void testZookeeperCanWrite() throws Throwable { System.setProperty("curator-log-events", "true"); startSecureZK(); CuratorService curator = null; LoginContext login = login(ZOOKEEPER_LOCALHOST, ZOOKEEPER_CLIENT_CONTEXT, keytab_zk); try { logLoginDetails(ZOOKEEPER, login); RegistrySecurity.setZKSaslClientProperties(ZOOKEEPER, ZOOKEEPER_CLIENT_CONTEXT); curator = startCuratorServiceInstance("ZK", true); LOG.info(curator.toString()); addToTeardown(curator); curator.zkMkPath("/", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); curator.zkList("/"); curator.zkMkPath("/zookeeper", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); } finally { logout(login); ServiceOperations.stop(curator); } }
@Test public void testInsecureClientToZK() throws Throwable { startSecureZK(); userZookeeperToCreateRoot(); RegistrySecurity.clearZKSaslClientProperties(); CuratorService curatorService = startCuratorServiceInstance("insecure client", false); curatorService.zkList("/"); curatorService.zkMkPath("", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); }
@Test public void testInsecureClientToZK() throws Throwable { startSecureZK(); userZookeeperToCreateRoot(); RegistrySecurity.clearZKSaslClientProperties(); CuratorService curatorService = startCuratorServiceInstance("insecure client", false); curatorService.zkList("/"); curatorService.zkMkPath("", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); }
/** * test that ZK can write as itself * @throws Throwable */ @Test public void testZookeeperCanWrite() throws Throwable { System.setProperty("curator-log-events", "true"); startSecureZK(); CuratorService curator = null; LoginContext login = login(ZOOKEEPER_LOCALHOST, ZOOKEEPER_CLIENT_CONTEXT, keytab_zk); try { logLoginDetails(ZOOKEEPER, login); RegistrySecurity.setZKSaslClientProperties(ZOOKEEPER, ZOOKEEPER_CLIENT_CONTEXT); curator = startCuratorServiceInstance("ZK", true); LOG.info(curator.toString()); addToTeardown(curator); curator.zkMkPath("/", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); curator.zkList("/"); curator.zkMkPath("/zookeeper", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); } finally { logout(login); ServiceOperations.stop(curator); } }
curator.zkMkPath("/", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); ZKPathDumper pathDumper = curator.dumpPath(true);
curator.zkMkPath("/", CreateMode.PERSISTENT, false, RegistrySecurity.WorldReadWriteACL); ZKPathDumper pathDumper = curator.dumpPath(true);