swamirishi commented on code in PR #7402:
URL: https://github.com/apache/ozone/pull/7402#discussion_r1849423129


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -122,21 +181,69 @@ public boolean addContainer(Container<?> container) throws
    * @return Container
    */
   public Container<?> getContainer(long containerId) {
-    Preconditions.checkState(containerId >= 0,
-        "Container Id cannot be negative.");
+    Preconditions.checkState(containerId >= 0, "Container Id cannot be 
negative.");
     return containerMap.get(containerId);
   }
 
+  /**
+   * Removes container from both memory and database. This should be used when 
the containerData on disk has been
+   * removed completely from the node.
+   * @param containerId
+   * @return True if container is removed from containerMap.
+   * @throws StorageContainerException
+   */
+  public boolean removeContainer(long containerId) throws 
StorageContainerException {
+    return removeContainer(containerId, false, true);
+  }
+
+  /**
+   * Removes containerId from memory. This needs to be used when the container 
is still present on disk, and the
+   * inmemory state of the container needs to be updated.
+   * @param containerId
+   * @return True if container is removed from containerMap.
+   * @throws StorageContainerException
+   */
+  public boolean removeContainerOnlyFromMemory(long containerId) throws 
StorageContainerException {
+    return removeContainer(containerId, false, false);
+  }
+
+  /**
+   * Marks a container to be missing, thus it removes the container from 
inmemory containerMap and marks the
+   * container as missing.
+   * @param containerId
+   * @return True if container is removed from containerMap.
+   * @throws StorageContainerException
+   */
+  public boolean removeMissingContainer(long containerId) throws 
StorageContainerException {
+    return removeContainer(containerId, true, false);
+  }
+
   /**
    * Removes the Container matching with specified containerId.
    * @param containerId ID of the container to remove
    * @return If container is removed from containerMap returns true, otherwise
    * false
    */
-  public boolean removeContainer(long containerId) {
+  private boolean removeContainer(long containerId, boolean markMissing, 
boolean removeFromDB)

Review Comment:
   **false, false** : This happens on finding a duplicate container on startup 
where the container info in memory gets swapped by removing and adding the 
updated container info.
   **true, false** : This happens on volume failure and we have to mark it as 
missing. This is a plain inmemory operation where in we remove the container 
from containerMap and add the containerId to the missingContainerSet.
   **false, true** : This is a regular delete flow which happens when SCM sends 
a delete container command. This will only happen after deleting the entire 
container data from the disk.
   **true, true** : This is an invalid case, this doesn't happen anywhere.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to