Search in sources :

Example 1 with RegistryOperationsClient

use of org.apache.hadoop.registry.client.impl.RegistryOperationsClient in project hadoop by apache.

the class RegistryOperationsFactory method createInstance.

/**
   * Create and initialize a registry operations instance.
   * Access rights will be determined from the configuration
   * @param name name of the instance
   * @param conf configuration
   * @return a registry operations instance
   * @throws ServiceStateException on any failure to initialize
   */
public static RegistryOperations createInstance(String name, Configuration conf) {
    Preconditions.checkArgument(conf != null, "Null configuration");
    RegistryOperationsClient operations = new RegistryOperationsClient(name);
    operations.init(conf);
    return operations;
}
Also used : RegistryOperationsClient(org.apache.hadoop.registry.client.impl.RegistryOperationsClient)

Example 2 with RegistryOperationsClient

use of org.apache.hadoop.registry.client.impl.RegistryOperationsClient in project hadoop by apache.

the class TestSecureRMRegistryOperations method testDigestAccess.

@Test
public void testDigestAccess() throws Throwable {
    RMRegistryOperationsService registryAdmin = startRMRegistryOperations();
    String id = "username";
    String pass = "password";
    registryAdmin.addWriteAccessor(id, pass);
    List<ACL> clientAcls = registryAdmin.getClientAcls();
    LOG.info("Client ACLS=\n{}", RegistrySecurity.aclsToString(clientAcls));
    String base = "/digested";
    registryAdmin.mknode(base, false);
    List<ACL> baseACLs = registryAdmin.zkGetACLS(base);
    String aclset = RegistrySecurity.aclsToString(baseACLs);
    LOG.info("Base ACLs=\n{}", aclset);
    ACL found = null;
    for (ACL acl : baseACLs) {
        if (ZookeeperConfigOptions.SCHEME_DIGEST.equals(acl.getId().getScheme())) {
            found = acl;
            break;
        }
    }
    assertNotNull("Did not find digest entry in ACLs " + aclset, found);
    zkClientConf.set(KEY_REGISTRY_USER_ACCOUNTS, "sasl:somebody@EXAMPLE.COM, sasl:other");
    RegistryOperations operations = RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf, id, pass);
    addToTeardown(operations);
    operations.start();
    RegistryOperationsClient operationsClient = (RegistryOperationsClient) operations;
    List<ACL> digestClientACLs = operationsClient.getClientAcls();
    LOG.info("digest client ACLs=\n{}", RegistrySecurity.aclsToString(digestClientACLs));
    operations.stat(base);
    operations.mknode(base + "/subdir", false);
    ZKPathDumper pathDumper = registryAdmin.dumpPath(true);
    LOG.info(pathDumper.toString());
}
Also used : ZKPathDumper(org.apache.hadoop.registry.client.impl.zk.ZKPathDumper) RegistryOperationsClient(org.apache.hadoop.registry.client.impl.RegistryOperationsClient) ACL(org.apache.zookeeper.data.ACL) RegistryOperations(org.apache.hadoop.registry.client.api.RegistryOperations) RMRegistryOperationsService(org.apache.hadoop.registry.server.integration.RMRegistryOperationsService) Test(org.junit.Test)

Aggregations

RegistryOperationsClient (org.apache.hadoop.registry.client.impl.RegistryOperationsClient)2 RegistryOperations (org.apache.hadoop.registry.client.api.RegistryOperations)1 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)1 RMRegistryOperationsService (org.apache.hadoop.registry.server.integration.RMRegistryOperationsService)1 ACL (org.apache.zookeeper.data.ACL)1 Test (org.junit.Test)1