Search in sources :

Example 1 with CuratorService

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);
    }
}
Also used : LoginContext(javax.security.auth.login.LoginContext) CuratorService(org.apache.hadoop.registry.client.impl.zk.CuratorService) Test(org.junit.Test)

Example 2 with CuratorService

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;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) CuratorService(org.apache.hadoop.registry.client.impl.zk.CuratorService)

Example 3 with 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);
    }
}
Also used : LoginContext(javax.security.auth.login.LoginContext) ZKPathDumper(org.apache.hadoop.registry.client.impl.zk.ZKPathDumper) CuratorService(org.apache.hadoop.registry.client.impl.zk.CuratorService)

Example 4 with CuratorService

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);
}
Also used : CuratorService(org.apache.hadoop.registry.client.impl.zk.CuratorService)

Example 5 with CuratorService

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();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) CuratorService(org.apache.hadoop.registry.client.impl.zk.CuratorService) Test(org.junit.Test) AbstractZKRegistryTest(org.apache.hadoop.registry.AbstractZKRegistryTest)

Aggregations

CuratorService (org.apache.hadoop.registry.client.impl.zk.CuratorService)6 Test (org.junit.Test)3 LoginContext (javax.security.auth.login.LoginContext)2 Configuration (org.apache.hadoop.conf.Configuration)2 AbstractZKRegistryTest (org.apache.hadoop.registry.AbstractZKRegistryTest)1 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)1