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); }
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)); }
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)); } }