protected internal override void RemoveStoredMasterKey(DelegationKey key)
        {
            string nodeRemovePath = GetNodePath(ZkDtsmMasterKeyRoot, DelegationKeyPrefix + key
                                                .GetKeyId());

            if (Log.IsDebugEnabled())
            {
                Log.Debug("Removing ZKDTSMDelegationKey_" + key.GetKeyId());
            }
            try
            {
                if (zkClient.CheckExists().ForPath(nodeRemovePath) != null)
                {
                    while (zkClient.CheckExists().ForPath(nodeRemovePath) != null)
                    {
                        zkClient.Delete().Guaranteed().ForPath(nodeRemovePath);
                    }
                }
                else
                {
                    Log.Debug("Attempted to delete a non-existing znode " + nodeRemovePath);
                }
            }
            catch (Exception)
            {
                Log.Debug(nodeRemovePath + " znode could not be removed!!");
            }
        }
Exemplo n.º 2
0
        /// <summary>Delete a directory/directory tree.</summary>
        /// <remarks>
        /// Delete a directory/directory tree.
        /// It is not an error to delete a path that does not exist
        /// </remarks>
        /// <param name="path">path of operation</param>
        /// <param name="recursive">flag to trigger recursive deletion</param>
        /// <param name="backgroundCallback">
        /// callback; this being set converts the operation
        /// into an async/background operation.
        /// task
        /// </param>
        /// <exception cref="System.IO.IOException">on problems other than no-such-path</exception>
        public virtual void ZkDelete(string path, bool recursive, BackgroundCallback backgroundCallback
                                     )
        {
            CheckServiceLive();
            string fullpath = CreateFullPath(path);

            try
            {
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("Deleting {}", fullpath);
                }
                DeleteBuilder delete = curator.Delete();
                if (recursive)
                {
                    delete.DeletingChildrenIfNeeded();
                }
                if (backgroundCallback != null)
                {
                    delete.InBackground(backgroundCallback);
                }
                delete.ForPath(fullpath);
            }
            catch (KeeperException.NoNodeException)
            {
            }
            catch (Exception e)
            {
                // not an error
                throw OperationFailure(fullpath, "delete()", e);
            }
        }