public virtual int CompareTo(Delayed delayed) { DelegationTokenRenewer.RenewAction <object> that = (DelegationTokenRenewer.RenewAction <object>)delayed; return(this.renewalTime < that.renewalTime ? -1 : this.renewalTime == that.renewalTime ? 0 : 1); }
/// <summary>Remove the associated renew action from the queue</summary> /// <exception cref="System.IO.IOException"/> public virtual void RemoveRenewAction <T>(T fs) where T : FileSystem { DelegationTokenRenewer.RenewAction <T> action = new DelegationTokenRenewer.RenewAction <T>(fs); if (queue.Remove(action)) { try { action.Cancel(); } catch (Exception ie) { Log.Error("Interrupted while canceling token for " + fs.GetUri() + "filesystem"); if (Log.IsDebugEnabled()) { Log.Debug(ie.GetStackTrace()); } } } }
/// <summary>Add a renew action to the queue.</summary> public virtual DelegationTokenRenewer.RenewAction <T> AddRenewAction <T>(T fs) where T : FileSystem { lock (this) { if (!IsAlive()) { Start(); } } DelegationTokenRenewer.RenewAction <T> action = new DelegationTokenRenewer.RenewAction <T>(fs); if (action.token != null) { queue.AddItem(action); } else { fs.Log.Error("does not have a token for renewal"); } return(action); }
public override void Run() { for (; ;) { DelegationTokenRenewer.RenewAction <object> action = null; try { action = queue.Take(); if (action.Renew()) { queue.AddItem(action); } } catch (Exception) { return; } catch (Exception ie) { action.weakFs.Get().Log.Warn("Failed to renew token, action=" + action, ie); } } }