diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/container/common/helpers/ContainerInfo.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/container/common/helpers/ContainerInfo.java index 1c3442a1ca..ff8bcdb164 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/container/common/helpers/ContainerInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/container/common/helpers/ContainerInfo.java @@ -100,10 +100,6 @@ public long getAllocatedBytes() { return allocatedBytes; } - public void setAllocatedBytes(long allocatedBytes) { - this.allocatedBytes = allocatedBytes; - } - public long getUsedBytes() { return usedBytes; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java index 2c1d3c428f..47b84f9b7c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java @@ -480,8 +480,16 @@ public void flushContainerInfo() throws IOException { OzoneProtos.SCMContainerInfo oldInfoProto = OzoneProtos.SCMContainerInfo.PARSER.parseFrom(containerBytes); ContainerInfo oldInfo = ContainerInfo.fromProtobuf(oldInfoProto); - oldInfo.setAllocatedBytes(info.getAllocatedBytes()); - containerStore.put(dbKey, oldInfo.getProtobuf().toByteArray()); + ContainerInfo newInfo = new ContainerInfo.Builder() + .setAllocatedBytes(info.getAllocatedBytes()) + .setContainerName(oldInfo.getContainerName()) + .setNumberOfKeys(oldInfo.getNumberOfKeys()) + .setOwner(oldInfo.getOwner()) + .setPipeline(oldInfo.getPipeline()) + .setState(oldInfo.getState()) + .setUsedBytes(oldInfo.getUsedBytes()) + .build(); + containerStore.put(dbKey, newInfo.getProtobuf().toByteArray()); } else { LOG.debug("Container state manager has container {} but not found " + "in container store, a deleted container?",