コード例 #1
0
        public virtual void TestZookeeperCanWriteUnderSystem()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();
            RegistryOperations          operations           = rmRegistryOperations;

            operations.Mknode(PathSystemServices + "hdfs", false);
            ZKPathDumper pathDumper = rmRegistryOperations.DumpPath(true);

            Log.Info(pathDumper.ToString());
        }
コード例 #2
0
        public virtual void TestDigestAccess()
        {
            RMRegistryOperationsService registryAdmin = StartRMRegistryOperations();
            string id   = "username";
            string pass = "******";

            registryAdmin.AddWriteAccessor(id, pass);
            IList <ACL> clientAcls = registryAdmin.GetClientAcls();

            Log.Info("Client ACLS=\n{}", RegistrySecurity.AclsToString(clientAcls));
            string @base = "/digested";

            registryAdmin.Mknode(@base, false);
            IList <ACL> baseACLs = registryAdmin.ZkGetACLS(@base);
            string      aclset   = RegistrySecurity.AclsToString(baseACLs);

            Log.Info("Base ACLs=\n{}", aclset);
            ACL found = null;

            foreach (ACL acl in baseACLs)
            {
                if (ZookeeperConfigOptions.SchemeDigest.Equals(acl.GetId().GetScheme()))
                {
                    found = acl;
                    break;
                }
            }
            NUnit.Framework.Assert.IsNotNull("Did not find digest entry in ACLs " + aclset, found
                                             );
            zkClientConf.Set(KeyRegistryUserAccounts, "sasl:[email protected], sasl:other"
                             );
            RegistryOperations operations = RegistryOperationsFactory.CreateAuthenticatedInstance
                                                (zkClientConf, id, pass);

            AddToTeardown(operations);
            operations.Start();
            RegistryOperationsClient operationsClient = (RegistryOperationsClient)operations;
            IList <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());
        }
コード例 #3
0
        /// <summary>have the ZK user create the root dir.</summary>
        /// <remarks>
        /// have the ZK user create the root dir.
        /// This logs out the ZK user after and stops its curator instance,
        /// to avoid contamination
        /// </remarks>
        /// <exception cref="System.Exception"/>
        public virtual void UserZookeeperToCreateRoot()
        {
            Runtime.SetProperty("curator-log-events", "true");
            CuratorService curator = null;
            LoginContext   login   = Login(ZookeeperLocalhost, ZookeeperClientContext, keytab_zk);

            try
            {
                LogLoginDetails(Zookeeper, login);
                RegistrySecurity.SetZKSaslClientProperties(Zookeeper, ZookeeperClientContext);
                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);
            }
        }
コード例 #4
0
        public virtual void TestCreateComplexApplication()
        {
            string        appId   = "application_1408631738011_0001";
            string        cid     = "container_1408631738011_0001_01_";
            string        cid1    = cid + "000001";
            string        cid2    = cid + "000002";
            string        appPath = Userpath + "tomcat";
            ServiceRecord webapp  = CreateRecord(appId, PersistencePolicies.Application, "tomcat-based web application"
                                                 , null);

            webapp.AddExternalEndpoint(RegistryTypeUtils.RestEndpoint("www", new URI("http",
                                                                                     "//loadbalancer/", null)));
            ServiceRecord comp1 = CreateRecord(cid1, PersistencePolicies.Container, null, null
                                               );

            comp1.AddExternalEndpoint(RegistryTypeUtils.RestEndpoint("www", new URI("http", "//rack4server3:43572"
                                                                                    , null)));
            comp1.AddInternalEndpoint(RegistryTypeUtils.InetAddrEndpoint("jmx", "JMX", "rack4server3"
                                                                         , 43573));
            // Component 2 has a container lifespan
            ServiceRecord comp2 = CreateRecord(cid2, PersistencePolicies.Container, null, null
                                               );

            comp2.AddExternalEndpoint(RegistryTypeUtils.RestEndpoint("www", new URI("http", "//rack1server28:35881"
                                                                                    , null)));
            comp2.AddInternalEndpoint(RegistryTypeUtils.InetAddrEndpoint("jmx", "JMX", "rack1server28"
                                                                         , 35882));
            operations.Mknode(Userpath, false);
            operations.Bind(appPath, webapp, BindFlags.Overwrite);
            string componentsPath = appPath + RegistryConstants.SubpathComponents;

            operations.Mknode(componentsPath, false);
            string dns1     = RegistryPathUtils.EncodeYarnID(cid1);
            string dns1path = componentsPath + dns1;

            operations.Bind(dns1path, comp1, BindFlags.Create);
            string dns2     = RegistryPathUtils.EncodeYarnID(cid2);
            string dns2path = componentsPath + dns2;

            operations.Bind(dns2path, comp2, BindFlags.Create);
            ZKPathDumper pathDumper = registry.DumpPath(false);

            Log.Info(pathDumper.ToString());
            LogRecord("tomcat", webapp);
            LogRecord(dns1, comp1);
            LogRecord(dns2, comp2);
            ServiceRecord dns1resolved = operations.Resolve(dns1path);

            NUnit.Framework.Assert.AreEqual("Persistence policies on resolved entry", PersistencePolicies
                                            .Container, dns1resolved.Get(YarnRegistryAttributes.YarnPersistence, string.Empty
                                                                         ));
            IDictionary <string, RegistryPathStatus> children = RegistryUtils.StatChildren(operations
                                                                                           , componentsPath);

            NUnit.Framework.Assert.AreEqual(2, children.Count);
            ICollection <RegistryPathStatus>    componentStats = children.Values;
            IDictionary <string, ServiceRecord> records        = RegistryUtils.ExtractServiceRecords(
                operations, componentsPath, componentStats);

            NUnit.Framework.Assert.AreEqual(2, records.Count);
            ServiceRecord retrieved1 = records[dns1path];

            LogRecord(retrieved1.Get(YarnRegistryAttributes.YarnId, string.Empty), retrieved1
                      );
            AssertMatches(dns1resolved, retrieved1);
            NUnit.Framework.Assert.AreEqual(PersistencePolicies.Container, retrieved1.Get(YarnRegistryAttributes
                                                                                          .YarnPersistence, string.Empty));
            // create a listing under components/
            operations.Mknode(componentsPath + "subdir", false);
            // this shows up in the listing of child entries
            IDictionary <string, RegistryPathStatus> childrenUpdated = RegistryUtils.StatChildren
                                                                           (operations, componentsPath);

            NUnit.Framework.Assert.AreEqual(3, childrenUpdated.Count);
            // the non-record child this is not picked up in the record listing
            IDictionary <string, ServiceRecord> recordsUpdated = RegistryUtils.ExtractServiceRecords
                                                                     (operations, componentsPath, childrenUpdated);

            NUnit.Framework.Assert.AreEqual(2, recordsUpdated.Count);
            // now do some deletions.
            // synchronous delete container ID 2
            // fail if the app policy is chosen
            NUnit.Framework.Assert.AreEqual(0, Purge("/", cid2, PersistencePolicies.Application
                                                     , RegistryAdminService.PurgePolicy.FailOnChildren));
            // succeed for container
            NUnit.Framework.Assert.AreEqual(1, Purge("/", cid2, PersistencePolicies.Container
                                                     , RegistryAdminService.PurgePolicy.FailOnChildren));
            AssertPathNotFound(dns2path);
            AssertPathExists(dns1path);
            // expect a skip on children to skip
            NUnit.Framework.Assert.AreEqual(0, Purge("/", appId, PersistencePolicies.Application
                                                     , RegistryAdminService.PurgePolicy.SkipOnChildren));
            AssertPathExists(appPath);
            AssertPathExists(dns1path);
            // attempt to delete app with policy of fail on children
            try
            {
                int p = Purge("/", appId, PersistencePolicies.Application, RegistryAdminService.PurgePolicy
                              .FailOnChildren);
                NUnit.Framework.Assert.Fail("expected a failure, got a purge count of " + p);
            }
            catch (PathIsNotEmptyDirectoryException)
            {
            }
            // expected
            AssertPathExists(appPath);
            AssertPathExists(dns1path);
            // now trigger recursive delete
            NUnit.Framework.Assert.AreEqual(1, Purge("/", appId, PersistencePolicies.Application
                                                     , RegistryAdminService.PurgePolicy.PurgeAll));
            AssertPathNotFound(appPath);
            AssertPathNotFound(dns1path);
        }