avijayanhwx commented on a change in pull request #2172:
URL: https://github.com/apache/ozone/pull/2172#discussion_r619377109
##########
File path:
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconContainerManager.java
##########
@@ -122,26 +122,87 @@ public void checkAndAddNewContainer(ContainerID
containerID,
scmClient.getContainerWithPipeline(containerID.getId());
LOG.debug("Verified new container from SCM {}, {} ",
containerID, containerWithPipeline.getPipeline().getId());
- // If no other client added this, go ahead and add this container.
- if (!containerExist(containerID)) {
- addNewContainer(containerID.getId(), containerWithPipeline);
- }
+ // no need call "containerExist" to check, because
+ // 1 containerExist and addNewContainer can not be atomic
+ // 2 addNewContainer will double check the existence
+ addNewContainer(containerID.getId(), containerWithPipeline);
Review comment:
Looks like
org.apache.hadoop.ozone.recon.scm.ReconContainerManager#addNewContainer does
not use the first argument (containerId). Can we remove it?
##########
File path:
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/scm/TestReconContainerManager.java
##########
@@ -127,6 +129,33 @@ public void testCheckAndAddNewContainer() throws
IOException {
getContainerManager().getContainer(containerID).getState());
}
+ @Test
+ public void testCheckAndAddNewContainerBatch() throws IOException {
+ List<ContainerReplicaProto> containerReplicaProtoList = new LinkedList<>();
+ ReconContainerManager containerManager = getContainerManager();
+ for (long i = 200L; i < 300L; i++) {
+ assertFalse(containerManager.containerExist(ContainerID.valueOf(i)));
+ ContainerReplicaProto.Builder ciBuilder =
+ ContainerReplicaProto.newBuilder();
+ ContainerReplicaProto crp = ciBuilder.
+ setContainerID(i).setState(OPEN).build();
+ containerReplicaProtoList.add(crp);
Review comment:
Can we also testing adding containers in non OPEN state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]