/// <summary>Copy constructor.</summary> /// <param name="from">where to copy from</param> public ReplicaUnderRecovery(Org.Apache.Hadoop.Hdfs.Server.Datanode.ReplicaUnderRecovery from) : base(from) { this.original = from.GetOriginalReplica(); this.recoveryId = from.GetRecoveryID(); }
/// <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; }
/// <exception cref="System.Exception"/> private static ReplicaInPipeline GetReplica(DataNode datanode, string bpid, HdfsServerConstants.ReplicaState expectedState) { ICollection <ReplicaInfo> replicas = FsDatasetTestUtil.GetReplicas(datanode.GetFSDataset (), bpid); for (int i = 0; i < 5 && replicas.Count == 0; i++) { Log.Info("wait since replicas.size() == 0; i=" + i); Sharpen.Thread.Sleep(1000); } NUnit.Framework.Assert.AreEqual(1, replicas.Count); ReplicaInfo r = replicas.GetEnumerator().Next(); NUnit.Framework.Assert.AreEqual(expectedState, r.GetState()); return((ReplicaInPipeline)r); }