/// <summary>Increments a counter a certain number of times.</summary> /// <param name="prog">StartupProgress to increment</param> /// <param name="phase">Phase to increment</param> /// <param name="step">Step to increment</param> /// <param name="delta">long number of times to increment</param> public static void IncrementCounter(StartupProgress prog, Phase phase, Step step, long delta) { StartupProgress.Counter counter = prog.GetCounter(phase, step); for (long i = 0; i < delta; ++i) { counter.Increment(); } }
/// <summary>Private helper method to load delegation keys from fsimage.</summary> /// <exception cref="System.IO.IOException">on error</exception> private void LoadAllKeys(DataInput @in) { lock (this) { StartupProgress prog = NameNode.GetStartupProgress(); Step step = new Step(StepType.DelegationKeys); prog.BeginStep(Phase.LoadingFsimage, step); int numberOfKeys = @in.ReadInt(); prog.SetTotal(Phase.LoadingFsimage, step, numberOfKeys); StartupProgress.Counter counter = prog.GetCounter(Phase.LoadingFsimage, step); for (int i = 0; i < numberOfKeys; i++) { DelegationKey value = new DelegationKey(); value.ReadFields(@in); this._enclosing.AddKey(value); counter.Increment(); } prog.EndStep(Phase.LoadingFsimage, step); } }
/* * Save the current state of allKeys */ /// <exception cref="System.IO.IOException"/> private void SaveAllKeys(DataOutputStream @out, string sdPath) { lock (this) { StartupProgress prog = NameNode.GetStartupProgress(); Step step = new Step(StepType.DelegationKeys, sdPath); prog.BeginStep(Phase.SavingCheckpoint, step); prog.SetTotal(Phase.SavingCheckpoint, step, this._enclosing.currentTokens.Count); StartupProgress.Counter counter = prog.GetCounter(Phase.SavingCheckpoint, step); @out.WriteInt(this._enclosing.allKeys.Count); IEnumerator <int> iter = this._enclosing.allKeys.Keys.GetEnumerator(); while (iter.HasNext()) { int key = iter.Next(); this._enclosing.allKeys[key].Write(@out); counter.Increment(); } prog.EndStep(Phase.SavingCheckpoint, step); } }
/// <summary>Private helper methods to load Delegation tokens from fsimage</summary> /// <exception cref="System.IO.IOException"/> private void LoadCurrentTokens(DataInput @in) { lock (this) { StartupProgress prog = NameNode.GetStartupProgress(); Step step = new Step(StepType.DelegationTokens); prog.BeginStep(Phase.LoadingFsimage, step); int numberOfTokens = @in.ReadInt(); prog.SetTotal(Phase.LoadingFsimage, step, numberOfTokens); StartupProgress.Counter counter = prog.GetCounter(Phase.LoadingFsimage, step); for (int i = 0; i < numberOfTokens; i++) { DelegationTokenIdentifier id = new DelegationTokenIdentifier(); id.ReadFields(@in); long expiryTime = @in.ReadLong(); this._enclosing.AddPersistedDelegationToken(id, expiryTime); counter.Increment(); } prog.EndStep(Phase.LoadingFsimage, step); } }
/// <summary>Private helper methods to save delegation keys and tokens in fsimage</summary> /// <exception cref="System.IO.IOException"/> private void SaveCurrentTokens(DataOutputStream @out, string sdPath) { lock (this) { StartupProgress prog = NameNode.GetStartupProgress(); Step step = new Step(StepType.DelegationTokens, sdPath); prog.BeginStep(Phase.SavingCheckpoint, step); prog.SetTotal(Phase.SavingCheckpoint, step, this._enclosing.currentTokens.Count); StartupProgress.Counter counter = prog.GetCounter(Phase.SavingCheckpoint, step); @out.WriteInt(this._enclosing.currentTokens.Count); IEnumerator <DelegationTokenIdentifier> iter = this._enclosing.currentTokens.Keys. GetEnumerator(); while (iter.HasNext()) { DelegationTokenIdentifier id = iter.Next(); id.Write(@out); AbstractDelegationTokenSecretManager.DelegationTokenInformation info = this._enclosing .currentTokens[id]; @out.WriteLong(info.GetRenewDate()); counter.Increment(); } prog.EndStep(Phase.SavingCheckpoint, step); } }