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

The following examples show how to use org.apache.hadoop.registry.client.api.RegistryOperationsFactory. 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 File: Executor.java    From jstorm with 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 #2
Source File: YarnZkRegistryBusiness.java    From PoseidonX with 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 #3
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 #4
Source File: TestSecureRMRegistryOperations.java    From big-c with 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 #5
Source File: TestSecureRMRegistryOperations.java    From big-c with 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 #6
Source File: TestSecureRMRegistryOperations.java    From big-c with 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 #7
Source File: TestSecureRMRegistryOperations.java    From big-c with 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 File: TestSecureRMRegistryOperations.java    From big-c with 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 #9
Source File: TestSecureRMRegistryOperations.java    From big-c with 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 #10
Source File: RegistryCli.java    From big-c with 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 #11
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 #12
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 #13
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 #14
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 #15
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 #16
Source File: RegistryCli.java    From hadoop with 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 #17
Source File: RegistryClient.java    From PoseidonX with 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 #18
Source File: TestSecureRMRegistryOperations.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNoDigestAuthMissingPass() throws Throwable {
  RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf,
      "id",
      "");
}
 
Example #19
Source File: TestSecureRMRegistryOperations.java    From hadoop with 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 File: TestSecureRMRegistryOperations.java    From hadoop with 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 #21
Source File: TestSecureRMRegistryOperations.java    From big-c with 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 File: TestSecureRMRegistryOperations.java    From big-c with 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 File: TestSecureRMRegistryOperations.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNoDigestAuthMissingPass() throws Throwable {
  RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf,
      "id",
      "");
}