Ejemplo n.º 1
0
        /// <summary>
        /// Queries the <see cref="Stat"/> of the node with the given path.
        /// </summary>
        /// <param name="ringMaster">Interface to ringmaster</param>
        /// <param name="path">Node path</param>
        /// <param name="watcher">Watcher interface that receives notifications for changes to this path or null</param>
        /// <param name="ignoreNonodeError">If set to <c>true</c> an exception is not thrown if no node is found at the given path</param>
        /// <returns>Task that will resolve on success to the <see cref="Stat"/> associated with the node</returns>
        public static async Task <IStat> Exists(this IRingMasterRequestHandler ringMaster, string path, IWatcher watcher, bool ignoreNonodeError)
        {
            RequestResponse response = await ringMaster.Request(
                new RequestExists(
                    path,
                    watcher));

            if (ignoreNonodeError &&
                (RingMasterException.GetCode(response.ResultCode) == RingMasterException.Code.Nonode))
            {
                return(response.Stat);
            }

            ThrowIfError(response);
            return((IStat)response.Content);
        }
Ejemplo n.º 2
0
        public static async Task <bool> Delete(this IRingMasterRequestHandler ringMaster, string path, int version, DeleteMode deletemode = DeleteMode.None)
        {
            RequestResponse response = await ringMaster.Request(
                new RequestDelete(
                    path,
                    version,
                    deletemode));

            switch (RingMasterException.GetCode(response.ResultCode))
            {
            case RingMasterException.Code.Ok: return(true);

            case RingMasterException.Code.Nonode: return(false);

            default:
                break;
            }

            ThrowIfError(response);
            return(false);
        }