You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fo...@apache.org on 2021/11/26 07:27:52 UTC

[jackrabbit-oak] branch trunk updated: OAK-9627: disable elastic index cleaner by default (#425)

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

fortino 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 f545723  OAK-9627: disable elastic index cleaner by default (#425)
f545723 is described below

commit f545723e3bd7f25c33b3b03db66a9138e2dc63d8
Author: Fabrizio Fortino <fa...@gmail.com>
AuthorDate: Fri Nov 26 08:27:43 2021 +0100

    OAK-9627: disable elastic index cleaner by default (#425)
---
 .../index/elastic/ElasticIndexProviderService.java     |  7 ++++---
 .../index/elastic/ElasticIndexProviderServiceTest.java | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderService.java b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderService.java
index c44dc42..48381bc 100644
--- a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderService.java
+++ b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderService.java
@@ -117,8 +117,8 @@ public class ElasticIndexProviderService {
         String localTextExtractionDir();
 
         @AttributeDefinition(name = "Remote index cleanup frequency", description = "Frequency (in seconds) of running remote index deletion scheduled task." +
-                "Set this to -1 to disable the task. Default is 1 hour.")
-        int remoteIndexCleanupFrequency() default 60*60;
+                "Default is -1 (disabled)).")
+        int remoteIndexCleanupFrequency() default -1;
 
         @AttributeDefinition(name = "Remote index deletion threshold", description = "Time in seconds after which a remote index whose local index is not found gets deleted." +
                 "Default is 1 day.")
@@ -196,7 +196,8 @@ public class ElasticIndexProviderService {
             LOG.warn("The Elastic cluster at {} is not reachable. The index cleaner job has not been enabled", elasticConnection);
             return;
         }
-        if (contextConfig.remoteIndexCleanupFrequency() == -1) {
+        if (contextConfig.remoteIndexCleanupFrequency() <= 0) {
+            LOG.info("Index Cleaner disabled by configuration");
             return;
         }
         ElasticIndexCleaner task = new ElasticIndexCleaner(elasticConnection, nodeStore, contextConfig.remoteIndexDeletionThreshold());
diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
index d93bbef..77563a3 100644
--- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
+++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java
@@ -102,6 +102,24 @@ public class ElasticIndexProviderServiceTest {
         assertNotNull(context.getService(QueryIndexProvider.class));
         assertNotNull(context.getService(IndexEditorProvider.class));
 
+        assertEquals(0, WhiteboardUtils.getServices(wb, Runnable.class).size());
+
+        MockOsgi.deactivate(service, context.bundleContext());
+    }
+
+    @Test
+    public void withIndexCleanerSetup() throws Exception {
+        Map<String, Object> props = new HashMap<>();
+        props.put(PROP_LOCAL_TEXT_EXTRACTION_DIR, folder.newFolder("localTextExtractionDir").getAbsolutePath());
+        props.put(PROP_INDEX_PREFIX, "elastic");
+        props.put(PROP_ELASTIC_HOST, "localhost");
+        props.put(PROP_ELASTIC_PORT, elasticRule.elastic.getFirstMappedPort());
+        props.put("remoteIndexCleanupFrequency", 600);
+        MockOsgi.activate(service, context.bundleContext(), props);
+
+        assertNotNull(context.getService(QueryIndexProvider.class));
+        assertNotNull(context.getService(IndexEditorProvider.class));
+
         assertEquals(1, WhiteboardUtils.getServices(wb, Runnable.class).size());
 
         MockOsgi.deactivate(service, context.bundleContext());