/// <exception cref="System.IO.IOException"/>
        public virtual ServiceRecord Resolve(string path)
        {
            byte[]        bytes  = ZkRead(path);
            ServiceRecord record = serviceRecordMarshal.FromBytes(path, bytes, ServiceRecord.
                                                                  RecordType);

            RegistryTypeUtils.ValidateServiceRecord(path, record);
            return(record);
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void Bind(string path, ServiceRecord record, int flags)
        {
            Preconditions.CheckArgument(record != null, "null record");
            ValidatePath(path);
            // validate the record before putting it
            RegistryTypeUtils.ValidateServiceRecord(path, record);
            Log.Info("Bound at {} : {}", path, record);
            CreateMode mode = CreateMode.Persistent;

            byte[] bytes = serviceRecordMarshal.ToBytes(record);
            ZkSet(path, mode, bytes, GetClientAcls(), ((flags & BindFlags.Overwrite) != 0));
        }
Exemplo n.º 3
0
        public virtual void TestLsParent()
        {
            ServiceRecord      written  = PutExampleServiceEntry(EntryPath, 0);
            RegistryPathStatus stat     = operations.Stat(EntryPath);
            IList <string>     children = operations.List(ParentPath);

            NUnit.Framework.Assert.AreEqual(1, children.Count);
            NUnit.Framework.Assert.AreEqual(Name, children[0]);
            IDictionary <string, RegistryPathStatus> childStats = RegistryUtils.StatChildren(operations
                                                                                             , ParentPath);

            NUnit.Framework.Assert.AreEqual(1, childStats.Count);
            NUnit.Framework.Assert.AreEqual(stat, childStats[Name]);
            IDictionary <string, ServiceRecord> records = RegistryUtils.ExtractServiceRecords(
                operations, ParentPath, childStats.Values);

            NUnit.Framework.Assert.AreEqual(1, records.Count);
            ServiceRecord record = records[EntryPath];

            RegistryTypeUtils.ValidateServiceRecord(EntryPath, record);
            AssertMatches(written, record);
        }