use of org.apache.hadoop.registry.client.impl.zk.CuratorService in project hadoop by apache.
the class TestSecureRegistry method testZookeeperCanWrite.
/**
* 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);
}
}
use of org.apache.hadoop.registry.client.impl.zk.CuratorService in project hadoop by apache.
the class TestSecureRegistry method startCuratorServiceInstance.
/**
* Start a curator service instance
* @param name name
* @param secure flag to indicate the cluster is secure
* @return an inited and started curator service
*/
protected CuratorService startCuratorServiceInstance(String name, boolean secure) {
Configuration clientConf = new Configuration();
clientConf.set(KEY_REGISTRY_ZK_ROOT, "/");
clientConf.setBoolean(KEY_REGISTRY_SECURE, secure);
describe(LOG, "Starting Curator service");
CuratorService curatorService = new CuratorService(name, secureZK);
curatorService.init(clientConf);
curatorService.start();
LOG.info("Curator Binding {}", curatorService.bindingDiagnosticDetails());
return curatorService;
}
use of org.apache.hadoop.registry.client.impl.zk.CuratorService in project hadoop by apache.
the class TestSecureRegistry method userZookeeperToCreateRoot.
/**
* have the ZK user create the root dir.
* This logs out the ZK user after and stops its curator instance,
* to avoid contamination
* @throws Throwable
*/
public void userZookeeperToCreateRoot() throws Throwable {
System.setProperty("curator-log-events", "true");
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);
ZKPathDumper pathDumper = curator.dumpPath(true);
LOG.info(pathDumper.toString());
} finally {
logout(login);
ServiceOperations.stop(curator);
}
}
use of org.apache.hadoop.registry.client.impl.zk.CuratorService in project hadoop by apache.
the class TestCuratorService method createCuratorService.
/**
* Create an instance
*/
protected void createCuratorService() throws IOException {
curatorService = new CuratorService("curatorService");
curatorService.init(createRegistryConfiguration());
curatorService.start();
rootACL = RegistrySecurity.WorldReadWriteACL;
curatorService.maybeCreate("", CreateMode.PERSISTENT, rootACL, true);
}
use of org.apache.hadoop.registry.client.impl.zk.CuratorService in project hadoop by apache.
the class TestCuratorService method testUseZKServiceForBinding.
@Test
public void testUseZKServiceForBinding() throws Throwable {
CuratorService cs2 = new CuratorService("curator", zookeeper);
cs2.init(new Configuration());
cs2.start();
}
Aggregations