private bool IsTrashRootPresent() { // Trash is disabled; trash root does not exist BlockPoolSliceStorage bps = dn0.GetStorage().GetBPStorage(blockPoolId); return(bps.TrashEnabled()); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="Sharpen.TimeoutException"/> /// <exception cref="System.Exception"/> /// <exception cref="Org.Apache.Hadoop.Conf.ReconfigurationException"/> public virtual void TestAddBackRemovedVolume() { StartDFSCluster(1, 2); // Create some data on every volume. CreateFile(new Path("/test"), 32); DataNode dn = cluster.GetDataNodes()[0]; Configuration conf = dn.GetConf(); string oldDataDir = conf.Get(DFSConfigKeys.DfsDatanodeDataDirKey); string keepDataDir = oldDataDir.Split(",")[0]; string removeDataDir = oldDataDir.Split(",")[1]; dn.ReconfigurePropertyImpl(DFSConfigKeys.DfsDatanodeDataDirKey, keepDataDir); for (int i = 0; i < cluster.GetNumNameNodes(); i++) { string bpid = cluster.GetNamesystem(i).GetBlockPoolId(); BlockPoolSliceStorage bpsStorage = dn.GetStorage().GetBPStorage(bpid); // Make sure that there is no block pool level storage under removeDataDir. for (int j = 0; j < bpsStorage.GetNumStorageDirs(); j++) { Storage.StorageDirectory sd = bpsStorage.GetStorageDir(j); NUnit.Framework.Assert.IsFalse(sd.GetRoot().GetAbsolutePath().StartsWith(new FilePath (removeDataDir).GetAbsolutePath())); } NUnit.Framework.Assert.AreEqual(dn.GetStorage().GetBPStorage(bpid).GetNumStorageDirs (), 1); } // Bring the removed directory back. It only successes if all metadata about // this directory were removed from the previous step. dn.ReconfigurePropertyImpl(DFSConfigKeys.DfsDatanodeDataDirKey, oldDataDir); }
/// <exception cref="System.Exception"/> private void FinalizeRollingUpgrade() { Log.Info("Finalizing rolling upgrade"); DFSAdmin dfsadmin = new DFSAdmin(conf); TestRollingUpgrade.RunCmd(dfsadmin, true, "-rollingUpgrade", "finalize"); TriggerHeartBeats(); // Ensure datanode rolling upgrade is started NUnit.Framework.Assert.IsFalse(dn0.GetFSDataset().TrashEnabled(blockPoolId)); BlockPoolSliceStorage bps = dn0.GetStorage().GetBPStorage(blockPoolId); NUnit.Framework.Assert.IsFalse(bps.TrashEnabled()); }
public virtual void TestGetTrashAndRestoreDirectories() { storage = MakeBlockPoolStorage(); // Test a few different nesting levels since block files // could be nested such as subdir1/subdir5/blk_... // Make sure all nesting levels are handled correctly. for (int i = 0; i < 3; ++i) { GetTrashDirectoryForBlockFile("blk_myblockfile", i); GetTrashDirectoryForBlockFile("blk_myblockfile.meta", i); GetRestoreDirectoryForBlockFile("blk_myblockfile", i); GetRestoreDirectoryForBlockFile("blk_myblockfile.meta", i); } }
/* * Test conversion from a block file in a trash directory to its * target directory for restore. */ public virtual void GetRestoreDirectoryForBlockFile(string fileName, int nestingLevel ) { BlockPoolSliceStorage storage = MakeBlockPoolStorage(); string blockFileSubdir = MakeRandomBlockFileSubdir(nestingLevel); string blockFileName = fileName; string deletedFilePath = storage.GetSingularStorageDir().GetRoot() + FilePath.separator + BlockPoolSliceStorage.TrashRootDir + blockFileSubdir + blockFileName; string expectedRestorePath = storage.GetSingularStorageDir().GetRoot() + FilePath .separator + Storage.StorageDirCurrent + Sharpen.Runtime.Substring(blockFileSubdir , 0, blockFileSubdir.Length - 1); Log.Info("Generated deleted file path " + deletedFilePath); Assert.AssertThat(storage.GetRestoreDirectory(new FilePath(deletedFilePath)), IS.Is (expectedRestorePath)); }
public _Runnable_756(BlockPoolSliceStorage _enclosing, IList <FilePath> trashRoots ) { this._enclosing = _enclosing; this.trashRoots = trashRoots; }
/// <summary> /// Test that DataStorage and BlockPoolSliceStorage remove the failed volume /// after failure. /// </summary> /// <exception cref="System.Exception"/> /// <exception cref="System.IO.IOException"/> /// <exception cref="Sharpen.TimeoutException"/> public virtual void TestFailedVolumeBeingRemovedFromDataNode() { Path file1 = new Path("/test1"); DFSTestUtil.CreateFile(fs, file1, 1024, (short)2, 1L); DFSTestUtil.WaitReplication(fs, file1, (short)2); FilePath dn0Vol1 = new FilePath(dataDir, "data" + (2 * 0 + 1)); DataNodeTestUtils.InjectDataDirFailure(dn0Vol1); DataNode dn0 = cluster.GetDataNodes()[0]; long lastDiskErrorCheck = dn0.GetLastDiskErrorCheck(); dn0.CheckDiskErrorAsync(); // Wait checkDiskError thread finish to discover volume failure. while (dn0.GetLastDiskErrorCheck() == lastDiskErrorCheck) { Sharpen.Thread.Sleep(100); } // Verify dn0Vol1 has been completely removed from DN0. // 1. dn0Vol1 is removed from DataStorage. DataStorage storage = dn0.GetStorage(); NUnit.Framework.Assert.AreEqual(1, storage.GetNumStorageDirs()); for (int i = 0; i < storage.GetNumStorageDirs(); i++) { Storage.StorageDirectory sd = storage.GetStorageDir(i); NUnit.Framework.Assert.IsFalse(sd.GetRoot().GetAbsolutePath().StartsWith(dn0Vol1. GetAbsolutePath())); } string bpid = cluster.GetNamesystem().GetBlockPoolId(); BlockPoolSliceStorage bpsStorage = storage.GetBPStorage(bpid); NUnit.Framework.Assert.AreEqual(1, bpsStorage.GetNumStorageDirs()); for (int i_1 = 0; i_1 < bpsStorage.GetNumStorageDirs(); i_1++) { Storage.StorageDirectory sd = bpsStorage.GetStorageDir(i_1); NUnit.Framework.Assert.IsFalse(sd.GetRoot().GetAbsolutePath().StartsWith(dn0Vol1. GetAbsolutePath())); } // 2. dn0Vol1 is removed from FsDataset FsDatasetSpi <FsVolumeSpi> data = dn0.GetFSDataset(); foreach (FsVolumeSpi volume in data.GetVolumes()) { Assert.AssertNotEquals(new FilePath(volume.GetBasePath()).GetAbsoluteFile(), dn0Vol1 .GetAbsoluteFile()); } // 3. all blocks on dn0Vol1 have been removed. foreach (ReplicaInfo replica in FsDatasetTestUtil.GetReplicas(data, bpid)) { NUnit.Framework.Assert.IsNotNull(replica.GetVolume()); Assert.AssertNotEquals(new FilePath(replica.GetVolume().GetBasePath()).GetAbsoluteFile (), dn0Vol1.GetAbsoluteFile()); } // 4. dn0Vol1 is not in DN0's configuration and dataDirs anymore. string[] dataDirStrs = dn0.GetConf().Get(DFSConfigKeys.DfsDatanodeDataDirKey).Split (","); NUnit.Framework.Assert.AreEqual(1, dataDirStrs.Length); NUnit.Framework.Assert.IsFalse(dataDirStrs[0].Contains(dn0Vol1.GetAbsolutePath()) ); }