Exemple #1
0
        /// <summary>
        /// Return the data and the stat of the node of the given path.
        /// </summary>
        /// <param name="path">the given path</param>
        /// <param name="watcher">explicit watcher</param>
        /// <returns></returns>
        public Task <Data.GetDataResponse> GetData(string path, IWatcher watcher)
        {
            var clientPath = path;

            Utils.PathUtils.ValidatePath(clientPath);
            var serverPath = Utils.PathUtils.PrependChroot(this._chrootPath, clientPath);

            return(this.ExecuteAsync <Data.GetDataResponse>(base.NextRequestSeqID(), Data.OpCode.GetData,
                                                            new Data.GetDataRequest(serverPath, watcher != null),
                                                            (src, response) =>
            {
                if (response.HasError())
                {
                    src.TrySetException(response.Error(clientPath)); return;
                }

                if (watcher != null)
                {
                    this._watcherManager.RegisterDataWatcher(watcher, clientPath);                     //register watcher
                }
                if (response.Payload == null || response.Payload.Length == 0)
                {
                    src.TrySetResult(null); return;
                }

                Data.GetDataResponse result = null;
                try { result = Utils.Marshaller.Deserialize <Data.GetDataResponse>(response.Payload); }
                catch (Exception ex) { src.TrySetException(ex); return; }

                src.TrySetResult(result);
            }));
        }
        public LongNodeRepresentation(
                GetDataResponse data,
                ZookeeperPsDriverInfo driverInfo,
                string path )
        {
            this.path = path;
            this.data = data;

            this.Name = ZookeeperPath.GetItemName( path );
            this.FullName = PsPath.FromZookeeperPath( driverInfo, path );
        }