Ver código fonte

HDFS-13026. Ozone: TestContainerPersistence is failing becaue of container data mismatch. Contributed by Mukul Kumar Singh.

Anu Engineer 7 anos atrás
pai
commit
87bce6e8e7

+ 7 - 2
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) {

+ 2 - 2
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.