Ejemplo n.º 1
0
        public virtual void TestPurgeEntryCuratorCallback()
        {
            string        path    = "/users/example/hbase/hbase1/";
            ServiceRecord written = BuildExampleServiceEntry(PersistencePolicies.ApplicationAttempt
                                                             );

            written.Set(YarnRegistryAttributes.YarnId, "testAsyncPurgeEntry_attempt_001");
            operations.Mknode(RegistryPathUtils.ParentOf(path), true);
            operations.Bind(path, written, 0);
            ZKPathDumper        dump   = registry.DumpPath(false);
            CuratorEventCatcher events = new CuratorEventCatcher();

            Log.Info("Initial state {}", dump);
            // container query
            string id      = written.Get(YarnRegistryAttributes.YarnId, string.Empty);
            int    opcount = Purge("/", id, PersistencePolicies.Container, RegistryAdminService.PurgePolicy
                                   .PurgeAll, events);

            AssertPathExists(path);
            NUnit.Framework.Assert.AreEqual(0, opcount);
            NUnit.Framework.Assert.AreEqual("Event counter", 0, events.GetCount());
            // now the application attempt
            opcount = Purge("/", id, PersistencePolicies.ApplicationAttempt, RegistryAdminService.PurgePolicy
                            .PurgeAll, events);
            Log.Info("Final state {}", dump);
            AssertPathNotFound(path);
            NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 1, opcount
                                            );
            // and validate the callback event
            NUnit.Framework.Assert.AreEqual("Event counter", 1, events.GetCount());
        }
Ejemplo n.º 2
0
        public virtual void TestAsyncPurgeEntry()
        {
            string        path    = "/users/example/hbase/hbase1/";
            ServiceRecord written = BuildExampleServiceEntry(PersistencePolicies.ApplicationAttempt
                                                             );

            written.Set(YarnRegistryAttributes.YarnId, "testAsyncPurgeEntry_attempt_001");
            operations.Mknode(RegistryPathUtils.ParentOf(path), true);
            operations.Bind(path, written, 0);
            ZKPathDumper dump = registry.DumpPath(false);

            Log.Info("Initial state {}", dump);
            DeleteCompletionCallback deletions = new DeleteCompletionCallback();
            int opcount = Purge("/", written.Get(YarnRegistryAttributes.YarnId, string.Empty)
                                , PersistencePolicies.Container, RegistryAdminService.PurgePolicy.PurgeAll, deletions
                                );

            AssertPathExists(path);
            dump = registry.DumpPath(false);
            NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 0, deletions
                                            .GetEventCount());
            NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 0, opcount
                                            );
            // now app attempt
            deletions = new DeleteCompletionCallback();
            opcount   = Purge("/", written.Get(YarnRegistryAttributes.YarnId, string.Empty), PersistencePolicies
                              .ApplicationAttempt, RegistryAdminService.PurgePolicy.PurgeAll, deletions);
            dump = registry.DumpPath(false);
            Log.Info("Final state {}", dump);
            AssertPathNotFound(path);
            NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 1, deletions
                                            .GetEventCount());
            NUnit.Framework.Assert.AreEqual("wrong no of delete operations in " + dump, 1, opcount
                                            );
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a service entry with the sample endpoints, and put it
        /// at the destination
        /// </summary>
        /// <param name="path">path</param>
        /// <param name="createFlags">flags</param>
        /// <returns>the record</returns>
        /// <exception cref="System.IO.IOException">on a failure</exception>
        /// <exception cref="Sharpen.URISyntaxException"/>
        protected internal virtual ServiceRecord PutExampleServiceEntry(string path, int
                                                                        createFlags, string persistence)
        {
            ServiceRecord record = BuildExampleServiceEntry(persistence);

            registry.Mknode(RegistryPathUtils.ParentOf(path), true);
            operations.Bind(path, record, createFlags);
            return(record);
        }
Ejemplo n.º 4
0
        public virtual void TestPutGetContainerPersistenceServiceEntry()
        {
            string        path    = EntryPath;
            ServiceRecord written = BuildExampleServiceEntry(PersistencePolicies.Container);

            operations.Mknode(RegistryPathUtils.ParentOf(path), true);
            operations.Bind(path, written, BindFlags.Create);
            ServiceRecord resolved = operations.Resolve(path);

            ValidateEntry(resolved);
            AssertMatches(written, resolved);
        }
Ejemplo n.º 5
0
 /// <summary>Recursively make a path</summary>
 /// <param name="path">path to create</param>
 /// <param name="acl">ACL for path</param>
 /// <exception cref="System.IO.IOException">any problem</exception>
 public virtual void ZkMkParentPath(string path, IList <ACL> acl)
 {
     // split path into elements
     ZkMkPath(RegistryPathUtils.ParentOf(path), CreateMode.Persistent, true, acl);
 }