/// <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); } } } }
public ReplicaUnderRecovery(ReplicaInfo replica, long recoveryId) : base(replica, replica.GetVolume(), replica.GetDir()) { // the original replica that needs to be recovered // recovery id; it is also the generation stamp // that the replica will be bumped to after recovery if (replica.GetState() != HdfsServerConstants.ReplicaState.Finalized && replica.GetState () != HdfsServerConstants.ReplicaState.Rbw && replica.GetState() != HdfsServerConstants.ReplicaState .Rwr) { throw new ArgumentException("Cannot recover replica: " + replica); } this.original = replica; this.recoveryId = recoveryId; }