From 916f31f7d17ea03c18636b293be59717e5f8beb4 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Thu, 18 Jan 2018 09:51:27 -0800 Subject: [PATCH] HDFS-13026. Ozone: TestContainerPersistence is failing becaue of container data mismatch. Contributed by Mukul Kumar Singh. --- .../ozone/container/common/impl/ChunkManagerImpl.java | 9 +++++++-- .../container/common/impl/TestContainerPersistence.java | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) 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 4aa667ec268..9052df7ded7 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 1ec754d7cdc..690289047b7 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.