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 re...@apache.org on 2022/12/21 12:17:01 UTC

[jackrabbit-oak] branch 1.22 updated: OAK-9018: use SystemPropertySupplier in RDBVersionGCSupport

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

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


The following commit(s) were added to refs/heads/1.22 by this push:
     new 81a6bad4bd OAK-9018: use SystemPropertySupplier in RDBVersionGCSupport
81a6bad4bd is described below

commit 81a6bad4bda1026c6b5379f7365a538cafd3342f
Author: Julian Reschke <re...@apache.org>
AuthorDate: Mon Apr 20 10:10:23 2020 +0000

    OAK-9018: use SystemPropertySupplier in RDBVersionGCSupport
    
    git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1876749 13f79535-47bb-0310-9956-ffa450edef68
---
 .../plugins/document/rdb/RDBVersionGCSupport.java  | 33 ++++------------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBVersionGCSupport.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBVersionGCSupport.java
index db55255065..ab47041a68 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBVersionGCSupport.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBVersionGCSupport.java
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.oak.plugins.document.VersionGCSupport;
 import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.QueryCondition;
 import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.UnsupportedIndexedPropertyException;
 import org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable;
+import org.apache.jackrabbit.oak.plugins.document.util.SystemPropertySupplier;
 import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.stats.Clock;
 import org.slf4j.Logger;
@@ -59,34 +60,12 @@ public class RDBVersionGCSupport extends VersionGCSupport {
 
     // 1: seek using historical, paging mode
     // 2: use custom single query directly using RDBDocumentStore API
-    private static final int MODE;
-
     private static final int DEFAULTMODE = 2;
 
-    static {
-        String propName = RDBVersionGCSupport.class.getName() + ".MODE";
-        String value = System.getProperty(propName, "");
-        switch (value) {
-            case "":
-                MODE = DEFAULTMODE;
-                break;
-            case "1":
-                MODE = 1;
-                break;
-            case "2":
-                MODE = 2;
-                break;
-            default:
-                LOG.error("Ignoring unexpected value '" + value + "' for system property " + propName);
-                MODE = DEFAULTMODE;
-                break;
-        }
-
-        if (DEFAULTMODE != MODE) {
-            LOG.info("Strategy for " + RDBVersionGCSupport.class.getName() + " set to " + MODE + " (via system property "
-                    + propName + ")");
-        }
-    }
+    private static final int MODE = SystemPropertySupplier.create(RDBVersionGCSupport.class.getName() + ".MODE", DEFAULTMODE)
+            .loggingTo(LOG).validateWith(value -> (value == 1 || value == 2)).formatSetMessage((name, value) -> String
+                    .format("Strategy for %s set to %s (via system property %s)", RDBVersionGCSupport.class.getName(), value, name))
+            .get();
 
     public RDBVersionGCSupport(RDBDocumentStore store) {
         super(store);
@@ -303,4 +282,4 @@ public class RDBVersionGCSupport extends VersionGCSupport {
             }
         };
     }
- }
\ No newline at end of file
+ }