You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/08/30 10:32:38 UTC

[GitHub] [ozone] bshashikant commented on a change in pull request #2594: HDDS-5660. Separate container caches for Open and Closed containers.

bshashikant commented on a change in pull request #2594:
URL: https://github.com/apache/ozone/pull/2594#discussion_r698375971



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/utils/ContainerCache.java
##########
@@ -219,17 +238,80 @@ private boolean cleanupDb(ReferenceCountedDB db) {
   }
 
   /**
-   * Add a DB handler into cache.
+   * Add a DB handler into container cache
+   * only if the container is in OPEN State.
    *
    * @param containerDBPath - DB path of the container.
    * @param db - DB handler
    */
-  public void addDB(String containerDBPath, ReferenceCountedDB db) {
+  public void addDB(String containerDBPath, ReferenceCountedDB db,
+                    State state) {
+    if (isContainerWriteable(state)) {
+      lock.lock();
+      try {
+        openContainerCache.putIfAbsent(containerDBPath, db);
+        metrics.incNumOpenContainerInserts();
+      } finally {
+        lock.unlock();
+      }
+    }
+  }
+
+  public void markContainerClosed(String containerPath) {
     lock.lock();
     try {
-      this.putIfAbsent(containerDBPath, db);
+      ReferenceCountedDB db = openContainerCache.remove(containerPath);
+      Preconditions.checkNotNull(db, "Container not found in open cache:" +
+          containerPath);
+      closeContainerCache.putIfAbsent(containerPath, db);
+      metrics.incNumOpenContainerRemoves();
     } finally {
       lock.unlock();
     }
   }
+
+  private boolean isContainerWriteable(State state) {
+    switch (state) {
+    case CLOSED:
+    case QUASI_CLOSED:
+      return false;
+    case CLOSING:
+    case OPEN:
+    case UNHEALTHY:
+      return true;

Review comment:
       Unhealthy containers are writeable?




-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org