/// <summary>Add a client.</summary> private void AddClient(DFSClient dfsc) { lock (this) { foreach (DFSClient c in dfsclients) { if (c == dfsc) { //client already exists, nothing to do. return; } } //client not found, add it dfsclients.AddItem(dfsc); //update renewal time if (dfsc.GetHdfsTimeout() > 0) { long half = dfsc.GetHdfsTimeout() / 2; if (half < renewal) { this.renewal = half; } } } }
/// <summary>Close the given client.</summary> internal virtual void CloseClient(DFSClient dfsc) { lock (this) { dfsclients.Remove(dfsc); if (dfsclients.IsEmpty()) { if (!IsRunning() || IsRenewerExpired()) { LeaseRenewer.Factory.Instance.Remove(this); return; } if (emptyTime == long.MaxValue) { //discover the first time that the client list is empty. emptyTime = Time.MonotonicNow(); } } //update renewal time if (renewal == dfsc.GetHdfsTimeout() / 2) { long min = HdfsConstants.LeaseSoftlimitPeriod; foreach (DFSClient c in dfsclients) { if (c.GetHdfsTimeout() > 0) { long timeout = c.GetHdfsTimeout(); if (timeout < min) { min = timeout; } } } renewal = min / 2; } } }