/// <summary>Duplicate the given block on all volumes.</summary> /// <param name="blockId"/> /// <exception cref="System.IO.IOException"/> private void DuplicateBlock(long blockId) { lock (fds) { ReplicaInfo b = FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, blockId); foreach (FsVolumeSpi v in fds.GetVolumes()) { if (v.GetStorageID().Equals(b.GetVolume().GetStorageID())) { continue; } // Volume without a copy of the block. Make a copy now. FilePath sourceBlock = b.GetBlockFile(); FilePath sourceMeta = b.GetMetaFile(); string sourceRoot = b.GetVolume().GetBasePath(); string destRoot = v.GetBasePath(); string relativeBlockPath = new FilePath(sourceRoot).ToURI().Relativize(sourceBlock .ToURI()).GetPath(); string relativeMetaPath = new FilePath(sourceRoot).ToURI().Relativize(sourceMeta. ToURI()).GetPath(); FilePath destBlock = new FilePath(destRoot, relativeBlockPath); FilePath destMeta = new FilePath(destRoot, relativeMetaPath); destBlock.GetParentFile().Mkdirs(); FileUtils.CopyFile(sourceBlock, destBlock); FileUtils.CopyFile(sourceMeta, destMeta); if (destBlock.Exists() && destMeta.Exists()) { Log.Info("Copied " + sourceBlock + " ==> " + destBlock); Log.Info("Copied " + sourceMeta + " ==> " + destMeta); } } } }
private void VerifyGenStamp(long blockId, long genStamp) { ReplicaInfo memBlock; memBlock = FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, blockId); NUnit.Framework.Assert.IsNotNull(memBlock); NUnit.Framework.Assert.AreEqual(genStamp, memBlock.GetGenerationStamp()); }
private void VerifyStorageType(long blockId, bool expectTransient) { ReplicaInfo memBlock; memBlock = FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, blockId); NUnit.Framework.Assert.IsNotNull(memBlock); MatcherAssert.AssertThat(memBlock.GetVolume().IsTransientStorage(), IS.Is(expectTransient )); }
/// <summary>Get a random blockId that is not used already</summary> private long GetFreeBlockId() { long id = rand.NextLong(); while (true) { id = rand.NextLong(); if (FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, id) == null) { break; } } return(id); }
private void VerifyAddition(long blockId, long genStamp, long size) { ReplicaInfo replicainfo; replicainfo = FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, blockId); NUnit.Framework.Assert.IsNotNull(replicainfo); // Added block has the same file as the one created by the test FilePath file = new FilePath(GetBlockFile(blockId)); NUnit.Framework.Assert.AreEqual(file.GetName(), FsDatasetTestUtil.GetFile(fds, bpid , blockId).GetName()); // Generation stamp is same as that of created file NUnit.Framework.Assert.AreEqual(genStamp, replicainfo.GetGenerationStamp()); // File size matches NUnit.Framework.Assert.AreEqual(size, replicainfo.GetNumBytes()); }
/// <summary>Fetch a copy of ReplicaInfo from a datanode by block id</summary> /// <param name="dn">datanode to retrieve a replicainfo object from</param> /// <param name="bpid">Block pool Id</param> /// <param name="blkId">id of the replica's block</param> /// <returns>copy of ReplicaInfo object @link{FSDataset#fetchReplicaInfo}</returns> public static ReplicaInfo FetchReplicaInfo(DataNode dn, string bpid, long blkId) { return(FsDatasetTestUtil.FetchReplicaInfo(dn.GetFSDataset(), bpid, blkId)); }
private void VerifyDeletion(long blockId) { // Ensure block does not exist in memory NUnit.Framework.Assert.IsNull(FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, blockId )); }