Skip to content

Commit fec6d33

Browse files
author
Niek Raaijmakers
committed
OAK-11461 - Make it configurable to disable discovery for the document node store service
1 parent 7d46f39 commit fec6d33

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,9 @@
395395
description = "Integer value indicating the number of documents to check for garbage in each Full GC cycle." +
396396
"The default value is " + DocumentNodeStoreService.DEFAULT_FGC_PROGRESS_SIZE)
397397
int fullGCProgressSize() default DocumentNodeStoreService.DEFAULT_FGC_PROGRESS_SIZE;
398+
399+
@AttributeDefinition(
400+
name = "Invisible for discovery",
401+
description = "Boolean value indicating that the instance should not be discoverable for the cluster. The default value is " + DocumentNodeStoreService.DEFAULT_INVISIBLE_FOR_DISCOVERY)
402+
boolean invisibleForDiscovery() default DocumentNodeStoreService.DEFAULT_INVISIBLE_FOR_DISCOVERY;
398403
}

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
configurationPid = {Configuration.PID})
131131
public class DocumentNodeStoreService {
132132

133+
public static final boolean DEFAULT_INVISIBLE_FOR_DISCOVERY = false;
133134
private static final long MB = 1024 * 1024;
134135
static final String DEFAULT_URI = "mongodb://localhost:27017/oak";
135136
static final int DEFAULT_CACHE = (int) (DEFAULT_MEMORY_CACHE_SIZE / MB);
@@ -510,6 +511,7 @@ private void configureBuilder(DocumentNodeStoreBuilder<?> builder) {
510511
config.childrenCachePercentage(),
511512
config.diffCachePercentage(),
512513
config.prevNoPropCachePercentage()).
514+
setClusterInvisible(config.invisibleForDiscovery()).
513515
setCacheSegmentCount(config.cacheSegmentCount()).
514516
setCacheStackMoveDistance(config.cacheStackMoveDistance()).
515517
setBundlingDisabled(config.bundlingDisabled()).

oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,29 @@ public void strictLeaseCheckMode() {
256256
assertEquals(LeaseCheckMode.STRICT, dns.getClusterInfo().getLeaseCheckMode());
257257
}
258258

259+
@Test
260+
public void invisibleForDiscoveryTrueFalse() {
261+
Map<String, Object> config = newConfig(repoHome);
262+
MockOsgi.setConfigForPid(context.bundleContext(), PID, config);
263+
MockOsgi.activate(service, context.bundleContext());
264+
265+
DocumentNodeStore dns = context.getService(DocumentNodeStore.class);
266+
// false is the default
267+
assertFalse(dns.getClusterInfo().isInvisible());
268+
}
269+
270+
@Test
271+
public void invisibleForDiscoveryTrue() {
272+
Map<String, Object> config = newConfig(repoHome);
273+
config.put("invisibleForDiscovery", true);
274+
MockOsgi.setConfigForPid(context.bundleContext(), PID, config);
275+
MockOsgi.activate(service, context.bundleContext());
276+
277+
DocumentNodeStore dns = context.getService(DocumentNodeStore.class);
278+
assertTrue(dns.getClusterInfo().isInvisible());
279+
}
280+
281+
259282
@Test
260283
public void lenientLeaseCheckMode() {
261284
Map<String, Object> config = newConfig(repoHome);

0 commit comments

Comments
 (0)