Exemple #1
0
        //added by Yang Li at Feb.29th, 2016
        public byte[] GetRemark(string path, IWatcher watcher, Stat stat)
        {
            string clientPath = path;

            PathUtils.ValidatePath(clientPath);

            // the watch contains the un-chroot path
            WatchRegistration wcb = null;

            if (watcher != null)
            {
                wcb = new DataWatchRegistration(watchManager, watcher, clientPath);
            }

            string serverPath = PrependChroot(clientPath);

            RequestHeader h = new RequestHeader();

#warning code here
            //h.Type = (int)OpCode.GetRemark;
            h.Type = (int)OpCode.GetData;
            GetRemarkRequest  request  = new GetRemarkRequest(serverPath, watcher != null);
            GetRemarkResponse response = new GetRemarkResponse();
            ReplyHeader       r        = cnxn.SubmitRequest(h, request, response, wcb);
            if (r.Err != 0)
            {
                throw KeeperException.Create((KeeperException.Code)Enum.ToObject(typeof(KeeperException.Code), r.Err), clientPath);
            }
            if (stat != null)
            {
                DataTree.CopyStat(response.Stat, stat);
            }
            return(response.Remark);
        }
Exemple #2
0
        private async Task <byte[]> GetDataAsyncInternal(string path, IWatcher watcher, Stat stat, bool sync)
        {
            string clientPath = path;

            PathUtils.ValidatePath(clientPath);

            // the watch contains the un-chroot path
            WatchRegistration wcb = null;

            if (watcher != null)
            {
                wcb = new DataWatchRegistration(watchManager, watcher, clientPath);
            }

            string serverPath = PrependChroot(clientPath);

            RequestHeader h = new RequestHeader();

            h.Type = (int)OpCode.GetData;
            GetDataRequest  request  = new GetDataRequest(serverPath, watcher != null);
            GetDataResponse response = new GetDataResponse();
            ReplyHeader     r        = sync ? cnxn.SubmitRequest(h, request, response, wcb)
                : await cnxn.SubmitRequestAsync(h, request, response, wcb).ConfigureAwait(false);

            if (r.Err != 0)
            {
                throw KeeperException.Create((KeeperException.Code)Enum.ToObject(typeof(KeeperException.Code), r.Err), clientPath);
            }
            if (stat != null)
            {
                DataTree.CopyStat(response.Stat, stat);
            }
            return(response.Data);
        }