|
@@ -2500,8 +2500,14 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
} else {
|
|
|
// Copying block to a new block with new blockId.
|
|
|
// Not truncating original block.
|
|
|
+ FsVolumeSpi volume = rur.getVolume();
|
|
|
+ String blockPath = blockFile.getAbsolutePath();
|
|
|
+ String volumePath = volume.getBasePath();
|
|
|
+ assert blockPath.startsWith(volumePath) :
|
|
|
+ "New block file: " + blockPath + " must be on " +
|
|
|
+ "same volume as recovery replica: " + volumePath;
|
|
|
ReplicaBeingWritten newReplicaInfo = new ReplicaBeingWritten(
|
|
|
- newBlockId, recoveryId, rur.getVolume(), blockFile.getParentFile(),
|
|
|
+ newBlockId, recoveryId, volume, blockFile.getParentFile(),
|
|
|
newlength);
|
|
|
newReplicaInfo.setNumBytes(newlength);
|
|
|
volumeMap.add(bpid, newReplicaInfo);
|
|
@@ -2517,17 +2523,14 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
ReplicaUnderRecovery replicaInfo, String bpid, long newBlkId, long newGS)
|
|
|
throws IOException {
|
|
|
String blockFileName = Block.BLOCK_FILE_PREFIX + newBlkId;
|
|
|
- try (FsVolumeReference ref = volumes.getNextVolume(
|
|
|
- replicaInfo.getVolume().getStorageType(), replicaInfo.getNumBytes())) {
|
|
|
- FsVolumeImpl v = (FsVolumeImpl) ref.getVolume();
|
|
|
- final File tmpDir = v.getBlockPoolSlice(bpid).getTmpDir();
|
|
|
- final File destDir = DatanodeUtil.idToBlockDir(tmpDir, newBlkId);
|
|
|
- final File dstBlockFile = new File(destDir, blockFileName);
|
|
|
- final File dstMetaFile = FsDatasetUtil.getMetaFile(dstBlockFile, newGS);
|
|
|
- return copyBlockFiles(replicaInfo.getMetaFile(),
|
|
|
- replicaInfo.getBlockFile(),
|
|
|
- dstMetaFile, dstBlockFile, true, smallBufferSize, conf);
|
|
|
- }
|
|
|
+ FsVolumeImpl v = (FsVolumeImpl) replicaInfo.getVolume();
|
|
|
+ final File tmpDir = v.getBlockPoolSlice(bpid).getTmpDir();
|
|
|
+ final File destDir = DatanodeUtil.idToBlockDir(tmpDir, newBlkId);
|
|
|
+ final File dstBlockFile = new File(destDir, blockFileName);
|
|
|
+ final File dstMetaFile = FsDatasetUtil.getMetaFile(dstBlockFile, newGS);
|
|
|
+ return copyBlockFiles(replicaInfo.getMetaFile(),
|
|
|
+ replicaInfo.getBlockFile(),
|
|
|
+ dstMetaFile, dstBlockFile, true, smallBufferSize, conf);
|
|
|
}
|
|
|
|
|
|
@Override // FsDatasetSpi
|