public virtual Future <int> PurgeRecordsAsync(string path, string id, string persistencePolicyMatch , RegistryAdminService.PurgePolicy purgePolicy, BackgroundCallback callback) { Log.Info(" records under {} with ID {} and policy {}: {}", path, id, persistencePolicyMatch ); return(Submit(new RegistryAdminService.AsyncPurge(this, path, new SelectByYarnPersistence (id, persistencePolicyMatch), purgePolicy, callback))); }
public AsyncPurge(RegistryAdminService _enclosing, string path, RegistryAdminService.NodeSelector selector, RegistryAdminService.PurgePolicy purgePolicy, BackgroundCallback callback ) { this._enclosing = _enclosing; this.callback = callback; this.selector = selector; this.path = path; this.purgePolicy = purgePolicy; }
/// <summary>trigger a purge operation</summary> /// <param name="path">pathn</param> /// <param name="id">yarn ID</param> /// <param name="policyMatch">policy to match ID on</param> /// <param name="purgePolicy">policy when there are children under a match</param> /// <param name="callback">optional callback</param> /// <returns>the number purged</returns> /// <exception cref="System.IO.IOException"/> /// <exception cref="Sharpen.ExecutionException"/> /// <exception cref="System.Exception"/> public virtual int Purge(string path, string id, string policyMatch, RegistryAdminService.PurgePolicy purgePolicy, BackgroundCallback callback) { Future <int> future = registry.PurgeRecordsAsync(path, id, policyMatch, purgePolicy , callback); try { return(future.Get()); } catch (ExecutionException e) { if (e.InnerException is IOException) { throw (IOException)e.InnerException; } else { throw; } } }
public virtual int Purge(string path, RegistryAdminService.NodeSelector selector, RegistryAdminService.PurgePolicy purgePolicy, BackgroundCallback callback) { bool toDelete = false; // look at self to see if it has a service record IDictionary <string, RegistryPathStatus> childEntries; ICollection <RegistryPathStatus> entries; try { // list this path's children childEntries = RegistryUtils.StatChildren(this, path); entries = childEntries.Values; } catch (PathNotFoundException) { // there's no record here, it may have been deleted already. // exit return(0); } try { RegistryPathStatus registryPathStatus = Stat(path); ServiceRecord serviceRecord = Resolve(path); // there is now an entry here. toDelete = selector.ShouldSelect(path, registryPathStatus, serviceRecord); } catch (EOFException) { } catch (InvalidRecordException) { } catch (NoRecordException) { } catch (PathNotFoundException) { // ignore // ignore // ignore // there's no record here, it may have been deleted already. // exit return(0); } if (toDelete && !entries.IsEmpty()) { if (Log.IsDebugEnabled()) { Log.Debug("Match on record @ {} with children ", path); } switch (purgePolicy) { case RegistryAdminService.PurgePolicy.SkipOnChildren: { // there's children // don't do the deletion... continue to next record if (Log.IsDebugEnabled()) { Log.Debug("Skipping deletion"); } toDelete = false; break; } case RegistryAdminService.PurgePolicy.PurgeAll: { // mark for deletion if (Log.IsDebugEnabled()) { Log.Debug("Scheduling for deletion with children"); } toDelete = true; entries = new AList <RegistryPathStatus>(0); break; } case RegistryAdminService.PurgePolicy.FailOnChildren: { if (Log.IsDebugEnabled()) { Log.Debug("Failing deletion operation"); } throw new PathIsNotEmptyDirectoryException(path); } } } int deleteOps = 0; if (toDelete) { try { ZkDelete(path, true, callback); } catch (PathNotFoundException) { // sign that the path was deleted during the operation. // this is a no-op, and all children can be skipped return(deleteOps); } deleteOps++; } // now go through the children foreach (RegistryPathStatus status in entries) { string childname = status.path; string childpath = RegistryPathUtils.Join(path, childname); deleteOps += Purge(childpath, selector, purgePolicy, callback); } return(deleteOps); }
/// <summary>trigger a purge operation</summary> /// <param name="path">path</param> /// <param name="id">yarn ID</param> /// <param name="policyMatch">policy to match ID on</param> /// <param name="purgePolicy">policy when there are children under a match</param> /// <returns>the number purged</returns> /// <exception cref="System.IO.IOException"/> /// <exception cref="Sharpen.ExecutionException"/> /// <exception cref="System.Exception"/> public virtual int Purge(string path, string id, string policyMatch, RegistryAdminService.PurgePolicy purgePolicy) { return(Purge(path, id, policyMatch, purgePolicy, null)); }
public virtual void SetPurgeOnCompletionPolicy(RegistryAdminService.PurgePolicy purgeOnCompletionPolicy ) { this.purgeOnCompletionPolicy = purgeOnCompletionPolicy; }