Esempio n. 1
0
        public Stat WriteDataReturnStat(string path, byte[] data, int expectedVersion)
        {
            int newVersion = -1;

            lock (_lock)
            {
                CheckWatch(_dataWatches, path, EventType.NodeDataChanged);
                if (!Exists(path, false))
                {
                    throw new KeeperException.NoNodeException();
                }
                CheckACL(path, Perms.WRITE);
                newVersion  = _data[path].version + 1;
                _data[path] = new DataAndVersion(data, newVersion);
                string parentPath = GetParentPath(path);
                if (!string.IsNullOrEmpty(parentPath))
                {
                    CheckWatch(_nodeWatches, parentPath, EventType.NodeChildrenChanged);
                }
            }
            Stat stat = new Stat();

            stat.Version = newVersion;
            return(stat);
        }
Esempio n. 2
0
        public KeyValuePair <List <ACL>, Stat> GetACL(string path)
        {
            if (!Exists(path, false))
            {
                throw new KeeperException.NoNodeException();
            }

            DataAndVersion dataAndVersion = _data[path];

            Stat stat = new Stat();

            stat.Version = dataAndVersion.version;
            stat.Ctime   = _creationTime[path].Value;
            return(new KeyValuePair <List <ACL>, Stat>(dataAndVersion.acl, stat));
        }
Esempio n. 3
0
        public void SetACL(string path, List <ACL> acl, int version)
        {
            if (!Exists(path, false))
            {
                throw new KeeperException.NoNodeException();
            }

            DataAndVersion dataAndVersion = _data[path];

            if (version != dataAndVersion.version)
            {
                throw new KeeperException.BadVersionException();
            }

            CheckACL(path, Perms.ADMIN);

            lock (_lock)
            {
                _data.Add(path, new DataAndVersion(dataAndVersion.data, dataAndVersion.version + 1, acl));
            }
        }