diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java index 4aa667ec26..9052df7ded 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java @@ -98,8 +98,13 @@ public class ChunkManagerImpl implements ChunkManager { commitChunk(tmpChunkFile, chunkFile, containerName, info.getLen()); break; case COMBINED: - ChunkUtils.writeData(tmpChunkFile, info, data); - commitChunk(tmpChunkFile, chunkFile, containerName, info.getLen()); + // directly write to the chunk file + long oldSize = chunkFile.length(); + ChunkUtils.writeData(chunkFile, info, data); + long newSize = chunkFile.length(); + containerManager.incrBytesUsed(containerName, newSize - oldSize); + containerManager.incrWriteCount(containerName); + containerManager.incrWriteBytes(containerName, info.getLen()); break; } } catch (ExecutionException | NoSuchAlgorithmException | IOException e) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java index 1ec754d7cd..690289047b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java @@ -531,8 +531,8 @@ public class TestContainerPersistence { try { chunkManager.writeChunk(pipeline, keyName, info, data, COMBINED); } catch (IOException ex) { - Assert.assertTrue(ex.getMessage().contains( - "Rejecting write chunk request. OverWrite flag required.")); + Assert.assertTrue(ex.getCause().getMessage().contains( + "Rejecting write chunk request. OverWrite flag required")); } // With the overwrite flag it should work now.