/// <summary>Make sure the client retries when the active NN is in safemode</summary> /// <exception cref="System.Exception"/> public virtual void TestClientRetrySafeMode() { IDictionary <Path, bool> results = Collections.SynchronizedMap(new Dictionary <Path , bool>()); Path test = new Path("/test"); // let nn0 enter safemode NameNodeAdapter.EnterSafeMode(nn0, false); FSNamesystem.SafeModeInfo safeMode = (FSNamesystem.SafeModeInfo)Whitebox.GetInternalState (nn0.GetNamesystem(), "safeMode"); Whitebox.SetInternalState(safeMode, "extension", Sharpen.Extensions.ValueOf(30000 )); Log.Info("enter safemode"); new _Thread_133(this, test, results).Start(); // make sure the client's call has actually been handled by the active NN NUnit.Framework.Assert.IsFalse("The directory should not be created while NN in safemode" , fs.Exists(test)); Sharpen.Thread.Sleep(1000); // let nn0 leave safemode NameNodeAdapter.LeaveSafeMode(nn0); Log.Info("leave safemode"); lock (this) { while (!results.Contains(test)) { Sharpen.Runtime.Wait(this); } NUnit.Framework.Assert.IsTrue(results[test]); } }
/// <returns> /// the number of blocks marked safe by safemode, or -1 /// if safemode is not running. /// </returns> public static int GetSafeModeSafeBlocks(NameNode nn) { FSNamesystem.SafeModeInfo smi = nn.GetNamesystem().GetSafeModeInfoForTests(); if (smi == null) { return(-1); } return(smi.blockSafe); }
public SafeModeException(string text, FSNamesystem.SafeModeInfo mode) : base(text + ". Name node is in safe mode.\n" + mode.GetTurnOffTip()) { }