Java Code Examples for org.apache.hadoop.registry.client.api.RegistryOperationsFactory

The following examples show how to use org.apache.hadoop.registry.client.api.RegistryOperationsFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: PoseidonX   Source File: YarnZkRegistryBusiness.java    License: Apache License 2.0 6 votes vote down vote up
private static void initAndStart(){
    try{
        Configuration conf  = new YarnConfiguration();
        conf.set(RegistryConstants.KEY_REGISTRY_ZK_ROOT, YarnZkContant.ZK_AM_REGISTRY_ROOT);
        registryOperations = RegistryOperationsFactory.createInstance(YarnZkContant.ZK_AM_REGISTRY_JSTORM_YARN, conf);
        if (registryOperations instanceof RMRegistryOperationsService) {
            RMRegistryOperationsService rmRegOperations = (RMRegistryOperationsService) registryOperations;
            rmRegOperations.initUserRegistryAsync(StreamContant.HADOOP_USER_NAME);
        }
    }catch(Exception e){
    }
    if(registryOperations==null){
        throw new IllegalArgumentException("YarnZkClientBusiness registryOperations start is error,cann't connect yarn zk!!");
    }
    registryOperations.start();
}
 
Example 2
Source Project: jstorm   Source File: Executor.java    License: Apache License 2.0 6 votes vote down vote up
public Executor(String instancName, String shellCommand, STARTType startType, String runningContainer,
                String localDir, String deployPath,
                String hadoopHome, String javaHome, String pythonHome, String dstPath, String portList, String shellArgs,
                String ExecShellStringPath, String applicationId, String supervisorLogviewPort, String nimbusThriftPort) {
    executorMeta = new ExecutorMeta(instancName, shellCommand, startType, runningContainer,
            localDir, deployPath, hadoopHome, javaHome, pythonHome, dstPath, portList, shellArgs,
            ExecShellStringPath, applicationId, supervisorLogviewPort, nimbusThriftPort);

    conf = new YarnConfiguration();
    Path yarnSite = new Path(hadoopHome + JOYConstants.YARN_SITE_PATH);
    conf.addResource(yarnSite);

    //get first log dir
    logDir = conf.get(JOYConstants.YARN_NM_LOG, JOYConstants.YARN_NM_LOG_DIR).split(JOYConstants.COMMA)[0] + JOYConstants.BACKLASH + applicationId + JOYConstants.BACKLASH + runningContainer;
    //Setup RegistryOperations
    registryOperations = RegistryOperationsFactory.createInstance(JOYConstants.YARN_REGISTRY, conf);
    try {
        setupInitialRegistryPaths();
    } catch (IOException e) {
        e.printStackTrace();
    }
    registryOperations.start();
}
 
Example 3
Source Project: PoseidonX   Source File: RegistryClient.java    License: Apache License 2.0 5 votes vote down vote up
public static RegistryClient init(String name,String serviceUserName,Configuration conf) throws IOException {
    registryClient = new RegistryClient();
    conf.set(KEY_REGISTRY_ZK_ROOT,REGISTRY_ROOT);
    registryClient.registryOperations = RegistryOperationsFactory.createInstance(name , conf);
    registryClient.setupInitialRegistryPaths(serviceUserName);
    registryClient.registryOperations.start();
    return registryClient;
}
 
Example 4
Source Project: hadoop   Source File: RegistryCli.java    License: Apache License 2.0 5 votes vote down vote up
public RegistryCli(PrintStream sysout, PrintStream syserr) {
  Configuration conf = new Configuration();
  super.setConf(conf);
  registry = RegistryOperationsFactory.createInstance(conf);
  registry.start();
  this.sysout = sysout;
  this.syserr = syserr;
}
 
Example 5
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAnonReadAccess() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  describe(LOG, "testAnonReadAccess");
  RegistryOperations operations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(operations);
  operations.start();

  assertFalse("RegistrySecurity.isClientSASLEnabled()==true",
      RegistrySecurity.isClientSASLEnabled());
  operations.list(PATH_SYSTEM_SERVICES);
}
 
Example 6
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAnonNoWriteAccess() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  describe(LOG, "testAnonNoWriteAccess");
  RegistryOperations operations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(operations);
  operations.start();

  String servicePath = PATH_SYSTEM_SERVICES + "hdfs";
  expectMkNodeFailure(operations, servicePath);
}
 
Example 7
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAnonNoWriteAccessOffRoot() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  describe(LOG, "testAnonNoWriteAccessOffRoot");
  RegistryOperations operations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(operations);
  operations.start();
  assertFalse("mknode(/)", operations.mknode("/", false));
  expectMkNodeFailure(operations, "/sub");
  expectDeleteFailure(operations, PATH_SYSTEM_SERVICES, true);
}
 
Example 8
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAlicePathRestrictedAnonAccess() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  String aliceHome = rmRegistryOperations.initUserRegistry(ALICE);
  describe(LOG, "Creating anonymous accessor");
  RegistryOperations anonOperations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(anonOperations);
  anonOperations.start();
  anonOperations.list(aliceHome);
  expectMkNodeFailure(anonOperations, aliceHome + "/anon");
  expectDeleteFailure(anonOperations, aliceHome, true);
}
 
Example 9
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = ServiceStateException.class)
public void testNoDigestAuthMissingId2() throws Throwable {
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_DIGEST);
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "");
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "pass");
  RegistryOperationsFactory.createInstance("DigestRegistryOperations",
      zkClientConf);
}
 
Example 10
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = ServiceStateException.class)
public void testNoDigestAuthMissingPass2() throws Throwable {
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_DIGEST);
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "id");
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "");
  RegistryOperationsFactory.createInstance("DigestRegistryOperations",
      zkClientConf);
}
 
Example 11
Source Project: big-c   Source File: RegistryCli.java    License: Apache License 2.0 5 votes vote down vote up
public RegistryCli(PrintStream sysout, PrintStream syserr) {
  Configuration conf = new Configuration();
  super.setConf(conf);
  registry = RegistryOperationsFactory.createInstance(conf);
  registry.start();
  this.sysout = sysout;
  this.syserr = syserr;
}
 
Example 12
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAnonReadAccess() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  describe(LOG, "testAnonReadAccess");
  RegistryOperations operations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(operations);
  operations.start();

  assertFalse("RegistrySecurity.isClientSASLEnabled()==true",
      RegistrySecurity.isClientSASLEnabled());
  operations.list(PATH_SYSTEM_SERVICES);
}
 
Example 13
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAnonNoWriteAccess() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  describe(LOG, "testAnonNoWriteAccess");
  RegistryOperations operations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(operations);
  operations.start();

  String servicePath = PATH_SYSTEM_SERVICES + "hdfs";
  expectMkNodeFailure(operations, servicePath);
}
 
Example 14
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAnonNoWriteAccessOffRoot() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  describe(LOG, "testAnonNoWriteAccessOffRoot");
  RegistryOperations operations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(operations);
  operations.start();
  assertFalse("mknode(/)", operations.mknode("/", false));
  expectMkNodeFailure(operations, "/sub");
  expectDeleteFailure(operations, PATH_SYSTEM_SERVICES, true);
}
 
Example 15
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAlicePathRestrictedAnonAccess() throws Throwable {
  RMRegistryOperationsService rmRegistryOperations =
      startRMRegistryOperations();
  String aliceHome = rmRegistryOperations.initUserRegistry(ALICE);
  describe(LOG, "Creating anonymous accessor");
  RegistryOperations anonOperations =
      RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
  addToTeardown(anonOperations);
  anonOperations.start();
  anonOperations.list(aliceHome);
  expectMkNodeFailure(anonOperations, aliceHome + "/anon");
  expectDeleteFailure(anonOperations, aliceHome, true);
}
 
Example 16
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = ServiceStateException.class)
public void testNoDigestAuthMissingId2() throws Throwable {
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_DIGEST);
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "");
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "pass");
  RegistryOperationsFactory.createInstance("DigestRegistryOperations",
      zkClientConf);
}
 
Example 17
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = ServiceStateException.class)
public void testNoDigestAuthMissingPass2() throws Throwable {
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_DIGEST);
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "id");
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "");
  RegistryOperationsFactory.createInstance("DigestRegistryOperations",
      zkClientConf);
}
 
Example 18
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 4 votes vote down vote up
@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:[email protected], 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());
}
 
Example 19
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNoDigestAuthMissingId() throws Throwable {
  RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf,
      "",
      "pass");
}
 
Example 20
Source Project: hadoop   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNoDigestAuthMissingPass() throws Throwable {
  RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf,
      "id",
      "");
}
 
Example 21
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 4 votes vote down vote up
@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:[email protected], 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());
}
 
Example 22
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNoDigestAuthMissingId() throws Throwable {
  RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf,
      "",
      "pass");
}
 
Example 23
Source Project: big-c   Source File: TestSecureRMRegistryOperations.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNoDigestAuthMissingPass() throws Throwable {
  RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf,
      "id",
      "");
}