elek commented on a change in pull request #166: HDDS-2372. Datanode pipeline
is failing with NoSuchFileException
URL: https://github.com/apache/hadoop-ozone/pull/166#discussion_r347298870
##########
File path:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/ChunkManagerImpl.java
##########
@@ -210,19 +216,39 @@ public ByteBuffer readChunk(Container container, BlockID
blockID,
// of the chunk file.
if (containerData.getLayOutVersion() == ChunkLayOutVersion
.getLatestVersion().getVersion()) {
- File chunkFile = ChunkUtils.getChunkFile(containerData, info);
- // In case the chunk file does not exist but tmp chunk file exist,
- // read from tmp chunk file if readFromTmpFile is set to true
- if (!chunkFile.exists() && dispatcherContext != null
- && dispatcherContext.isReadFromTmpFile()) {
- chunkFile = getTmpChunkFile(chunkFile, dispatcherContext);
+ File finalChunkFile = ChunkUtils.getChunkFile(containerData, info);
+ File tmpChunkFile = getTmpChunkFile(finalChunkFile, dispatcherContext);
+
+ List<File> possibleFiles = new ArrayList<>();
+ possibleFiles.add(finalChunkFile);
+ if (dispatcherContext.isReadFromTmpFile()) {
+ possibleFiles.add(tmpChunkFile);
+ possibleFiles.add(finalChunkFile);
}
- data = ChunkUtils.readData(chunkFile, info, volumeIOStats);
- containerData.incrReadCount();
- long length = chunkFile.length();
- containerData.incrReadBytes(length);
- return data;
+
+ boolean found = false;
+
+ for (File chunkFile : possibleFiles) {
+ try {
+ data = ChunkUtils.readData(chunkFile, info, volumeIOStats);
+ containerData.incrReadCount();
+ long length = chunkFile.length();
Review comment:
Thanks, updated.
(BTW, I don't know why this `incrReadBytes` is used at all as we already
have `volumeIOStats.incReadBytes` in ChunkUtils. But that's an other question.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]