smengcl commented on code in PR #4680:
URL: https://github.com/apache/ozone/pull/4680#discussion_r1197224374


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/lock/BootstrapStateHandler.java:
##########
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.lock;
+
+import java.util.concurrent.Semaphore;
+
+/** Bootstrap state handler interface. */
+public interface BootstrapStateHandler {
+  Lock getBootstrapStateLock();
+
+  /** Bootstrap state handler lock implementation. */
+  class Lock implements AutoCloseable {
+    private Semaphore semaphore = new Semaphore(1);

Review Comment:
   nit
   ```suggestion
       private final Semaphore semaphore = new Semaphore(1);
   ```



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java:
##########
@@ -222,6 +225,25 @@ public void testIrrelevantSstFileDeletion()
     Assert.assertTrue(
         processedSnapshotIds.contains(snapshotInfo.getSnapshotID()));
 
+    long count;
+    // Prevent the new snapshot from being filtered
+    try (BootstrapStateHandler.Lock lock =
+             sstFilteringService.getBootstrapStateLock().lock()) {
+      count = sstFilteringService.getSnapshotFilteredCount().get();
+      writeClient.createSnapshot("vol1", "buck2", "snapshot2");
+
+      // Confirm that it is not filtered
+      assertThrows(TimeoutException.class, () -> GenericTestUtils.waitFor(
+          () -> sstFilteringService.getSnapshotFilteredCount().get() > count,
+          1000, 10000));
+      assertEquals(count, 
sstFilteringService.getSnapshotFilteredCount().get());
+    }
+    // Now allow filtering
+    GenericTestUtils.waitFor(
+        () -> sstFilteringService.getSnapshotFilteredCount().get() > count,
+        1000, 10000);
+
+
   }

Review Comment:
   ```suggestion
           1000, 10000);
     }
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServlet.java:
##########
@@ -112,6 +115,8 @@ public void init() throws ServletException {
         allowedUsers,
         allowedGroups,
         om.isSpnegoEnabled());
+    lock = new Lock(om);
+
   }

Review Comment:
   ```suggestion
           om.isSpnegoEnabled());
   
       lock = new Lock(om);
     }
   ```



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