This is an automated email from the ASF dual-hosted git repository.

daim pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 4543c6feb2 OAK-11461 : DocumentNodeStoreService -  disable discovery  
(#2057)
4543c6feb2 is described below

commit 4543c6feb212317ac362d36bc4af5925355b6d36
Author: Niek Raaijmakers <[email protected]>
AuthorDate: Tue Feb 11 11:30:26 2025 +0100

    OAK-11461 : DocumentNodeStoreService -  disable discovery  (#2057)
    
    * OAK-11461 - Make it configurable to disable discovery for the document 
node store service
    
    * Update 
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java
    
    Co-authored-by: Rishabh Kumar <[email protected]>
    
    * OAK-11461 - Add unit test
    
    * Update 
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java
    
    Co-authored-by: José Andrés Cordero Benítez 
<[email protected]>
    
    ---------
    
    Co-authored-by: Niek Raaijmakers <[email protected]>
    Co-authored-by: Rishabh Kumar <[email protected]>
    Co-authored-by: José Andrés Cordero Benítez 
<[email protected]>
---
 .../oak/plugins/document/Configuration.java        |  5 +++++
 .../plugins/document/DocumentNodeStoreService.java |  2 ++
 .../DocumentNodeStoreServiceConfigurationTest.java | 23 ++++++++++++++++++++++
 .../document/DocumentNodeStoreServiceTest.java     | 23 ++++++++++++++++++++++
 4 files changed, 53 insertions(+)

diff --git 
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java
 
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java
index 9e7921036a..0c82ea8f2a 100644
--- 
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java
+++ 
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java
@@ -395,4 +395,9 @@ import static 
org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreServic
             description = "Integer value indicating the number of documents to 
check for garbage in each Full GC cycle." +
                     "The default value is " + 
DocumentNodeStoreService.DEFAULT_FGC_PROGRESS_SIZE)
     int fullGCProgressSize() default 
DocumentNodeStoreService.DEFAULT_FGC_PROGRESS_SIZE;
+
+    @AttributeDefinition(
+            name = "Invisible for discovery",
+            description = "Boolean value indicating whether the instance 
should be discoverable by the cluster. The default value is " + 
DocumentNodeStoreService.DEFAULT_INVISIBLE_FOR_DISCOVERY)
+    boolean invisibleForDiscovery() default 
DocumentNodeStoreService.DEFAULT_INVISIBLE_FOR_DISCOVERY;
 }
diff --git 
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
 
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
index 1437945d9a..79e4b98ea6 100644
--- 
a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
+++ 
b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
@@ -130,6 +130,7 @@ import org.slf4j.LoggerFactory;
         configurationPid = {Configuration.PID})
 public class DocumentNodeStoreService {
 
+    public static final boolean DEFAULT_INVISIBLE_FOR_DISCOVERY = false;
     private static final long MB = 1024 * 1024;
     static final String DEFAULT_URI = "mongodb://localhost:27017/oak";
     static final int DEFAULT_CACHE = (int) (DEFAULT_MEMORY_CACHE_SIZE / MB);
@@ -510,6 +511,7 @@ public class DocumentNodeStoreService {
                         config.childrenCachePercentage(),
                         config.diffCachePercentage(),
                         config.prevNoPropCachePercentage()).
+                setClusterInvisible(config.invisibleForDiscovery()).
                 setCacheSegmentCount(config.cacheSegmentCount()).
                 setCacheStackMoveDistance(config.cacheStackMoveDistance()).
                 setBundlingDisabled(config.bundlingDisabled()).
diff --git 
a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfigurationTest.java
 
b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfigurationTest.java
index 398f650174..58a29042f5 100644
--- 
a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfigurationTest.java
+++ 
b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfigurationTest.java
@@ -45,6 +45,7 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 public class DocumentNodeStoreServiceConfigurationTest {
 
@@ -169,6 +170,28 @@ public class DocumentNodeStoreServiceConfigurationTest {
         assertEquals(batchSize, config.fullGCBatchSize());
     }
 
+    @Test
+    public void invisibleForDiscoveryFalse() throws Exception {
+        boolean batchSize = false;
+        addConfigurationEntry(preset, "invisibleForDiscovery", batchSize);
+        Configuration config = createConfiguration();
+        assertFalse(config.invisibleForDiscovery());
+    }
+
+    @Test
+    public void invisibleForDiscoveryTrue() throws Exception {
+        boolean batchSize = true;
+        addConfigurationEntry(preset, "invisibleForDiscovery", batchSize);
+        Configuration config = createConfiguration();
+        assertTrue(config.invisibleForDiscovery());
+    }
+
+    @Test
+    public void invisibleForDiscoveryFalseByDefault() throws Exception {
+        Configuration config = createConfiguration();
+        assertFalse(config.invisibleForDiscovery());
+    }
+
     @Test
     public void fullGCProgressSize() throws Exception {
         int progressSize = 20000;
diff --git 
a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
 
b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
index bfb4891340..b3e4874b91 100644
--- 
a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
+++ 
b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
@@ -256,6 +256,29 @@ public class DocumentNodeStoreServiceTest {
         assertEquals(LeaseCheckMode.STRICT, 
dns.getClusterInfo().getLeaseCheckMode());
     }
 
+    @Test
+    public void invisibleForDiscoveryTrueFalse() {
+        Map<String, Object> config = newConfig(repoHome);
+        MockOsgi.setConfigForPid(context.bundleContext(), PID, config);
+        MockOsgi.activate(service, context.bundleContext());
+
+        DocumentNodeStore dns = context.getService(DocumentNodeStore.class);
+        // false is the default
+        assertFalse(dns.getClusterInfo().isInvisible());
+    }
+
+    @Test
+    public void invisibleForDiscoveryTrue() {
+        Map<String, Object> config = newConfig(repoHome);
+        config.put("invisibleForDiscovery", true);
+        MockOsgi.setConfigForPid(context.bundleContext(), PID, config);
+        MockOsgi.activate(service, context.bundleContext());
+
+        DocumentNodeStore dns = context.getService(DocumentNodeStore.class);
+        assertTrue(dns.getClusterInfo().isInvisible());
+    }
+
+
     @Test
     public void lenientLeaseCheckMode() {
         Map<String, Object> config = newConfig(repoHome);

Reply via email to