HDDS-350. ContainerMapping#flushContainerInfo doesn't set containerId. Contributed by Ajay Kumar.
This commit is contained in:
parent
5aa15cfaff
commit
4c25f37c6c
|
@ -212,6 +212,7 @@ public class ContainerInfo implements Comparator<ContainerInfo>,
|
||||||
public HddsProtos.SCMContainerInfo getProtobuf() {
|
public HddsProtos.SCMContainerInfo getProtobuf() {
|
||||||
HddsProtos.SCMContainerInfo.Builder builder =
|
HddsProtos.SCMContainerInfo.Builder builder =
|
||||||
HddsProtos.SCMContainerInfo.newBuilder();
|
HddsProtos.SCMContainerInfo.newBuilder();
|
||||||
|
Preconditions.checkState(containerID > 0);
|
||||||
return builder.setAllocatedBytes(getAllocatedBytes())
|
return builder.setAllocatedBytes(getAllocatedBytes())
|
||||||
.setContainerID(getContainerID())
|
.setContainerID(getContainerID())
|
||||||
.setUsedBytes(getUsedBytes())
|
.setUsedBytes(getUsedBytes())
|
||||||
|
|
|
@ -733,21 +733,7 @@ public class ContainerMapping implements Mapping {
|
||||||
// return info of a deleted container. may revisit this in the future,
|
// return info of a deleted container. may revisit this in the future,
|
||||||
// for now, just skip a not-found container
|
// for now, just skip a not-found container
|
||||||
if (containerBytes != null) {
|
if (containerBytes != null) {
|
||||||
HddsProtos.SCMContainerInfo oldInfoProto =
|
containerStore.put(dbKey, info.getProtobuf().toByteArray());
|
||||||
HddsProtos.SCMContainerInfo.PARSER.parseFrom(containerBytes);
|
|
||||||
ContainerInfo oldInfo = ContainerInfo.fromProtobuf(oldInfoProto);
|
|
||||||
ContainerInfo newInfo = new ContainerInfo.Builder()
|
|
||||||
.setAllocatedBytes(info.getAllocatedBytes())
|
|
||||||
.setNumberOfKeys(oldInfo.getNumberOfKeys())
|
|
||||||
.setOwner(oldInfo.getOwner())
|
|
||||||
.setPipelineID(oldInfo.getPipelineID())
|
|
||||||
.setState(oldInfo.getState())
|
|
||||||
.setUsedBytes(oldInfo.getUsedBytes())
|
|
||||||
.setDeleteTransactionId(oldInfo.getDeleteTransactionId())
|
|
||||||
.setReplicationFactor(oldInfo.getReplicationFactor())
|
|
||||||
.setReplicationType(oldInfo.getReplicationType())
|
|
||||||
.build();
|
|
||||||
containerStore.put(dbKey, newInfo.getProtobuf().toByteArray());
|
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Container state manager has container {} but not found " +
|
LOG.debug("Container state manager has container {} but not found " +
|
||||||
"in container store, a deleted container?",
|
"in container store, a deleted container?",
|
||||||
|
|
|
@ -360,4 +360,12 @@ public class TestContainerMapping {
|
||||||
return containerInfo;
|
return containerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFlushAllContainers() throws IOException {
|
||||||
|
ContainerInfo info = createContainer();
|
||||||
|
List<ContainerInfo> containers = mapping.getStateManager().getAllContainers();
|
||||||
|
Assert.assertTrue(containers.size() > 0);
|
||||||
|
mapping.flushContainerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue