Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ private void addReplicaToReplicasMap(Block block, ReplicaMap volumeMap,
}
}


private AtomicLong scanBlockCnt = new AtomicLong(0L);
/**
* Add replicas under the given directory to the volume map
* @param volumeMap the replicas map
Expand All @@ -749,6 +749,11 @@ void addToReplicasMap(ReplicaMap volumeMap, File dir,
lazyWriteReplicaMap, isFinalized, exceptions, subTaskQueue);
subTask.fork();
subTaskQueue.add(subTask);
} else {
long num = scanBlockCnt.get();
if (num > 0 && num % 10000 == 0) {
LOG.info("Scan process: " + num + " blocks have been scanned.");
}
}

if (isFinalized && FsDatasetUtil.isUnlinkTmpFile(file)) {
Expand All @@ -768,6 +773,7 @@ void addToReplicasMap(ReplicaMap volumeMap, File dir,
Block block = new Block(blockId, file.length(), genStamp);
addReplicaToReplicasMap(block, volumeMap, lazyWriteReplicaMap,
isFinalized);
scanBlockCnt.incrementAndGet();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2102,4 +2102,28 @@ public void delayGetMetaDataInputStream() {
DataNodeFaultInjector.set(oldDnInjector);
}
}

/**
* My patch only adds a log print. Therefore, I cannot write assert judgments.
* I can only verify the normal function of addVolume.
*/
@Test
public void testLog4AddToReplicasMap() throws IOException {
List<NamespaceInfo> nsInfos = Lists.newArrayList();
for (String bpid : BLOCK_POOL_IDS) {
nsInfos.add(new NamespaceInfo(0, CLUSTER_ID, bpid, 1));
}
String path = BASE_DIR + "/newData0";
String pathUri = new Path(path).toUri().toString();
StorageLocation loc = StorageLocation.parse(pathUri);
Storage.StorageDirectory sd = createStorageDirectory(
new File(path), conf);
DataStorage.VolumeBuilder builder =
new DataStorage.VolumeBuilder(storage, sd);
when(storage.prepareVolume(eq(datanode), eq(loc),
anyList()))
.thenReturn(builder);
dataset.addVolume(loc, nsInfos);
}

}