You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by xx...@apache.org on 2022/10/20 09:00:53 UTC

[kylin] branch kylin5 updated: Refine patch from KYLIN-5256 (#1999)

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

xxyu pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/kylin5 by this push:
     new ab1f17f1e6 Refine patch from KYLIN-5256 (#1999)
ab1f17f1e6 is described below

commit ab1f17f1e6b778b8f85d50ab1d282afc26d69f26
Author: XiaoxiangYu <xx...@apache.org>
AuthorDate: Thu Oct 20 17:00:44 2022 +0800

    Refine patch from KYLIN-5256 (#1999)
    
    * Revert "Kylin 5256 Add a cache for the system property get by the optional config in KylinConfigBase (#1969)"
    
    This reverts commit ce5c40393a73664344a9275e9f31af4722d651f7.
    
    * KYLIN-5256 Improve performance of System.getProperty
    
    * Fix UT
    
    * Fix import
    
    Co-authored-by: zhennzhang <zh...@ebay.com>
---
 dev-support/unit_testing.sh                        |  6 +-
 .../rest/controller/NEpochControllerTest.java      |  4 +-
 .../java/org/apache/kylin/common/KylinConfig.java  |  2 +-
 .../org/apache/kylin/common/KylinConfigBase.java   | 57 ++++---------------
 .../apache/kylin/common/PropertiesDelegate.java    | 26 +--------
 .../apache/kylin/common/SystemPropertiesCache.java | 66 ++++++++++++++++++++++
 .../java/org/apache/kylin/common/util/Unsafe.java  | 11 ++--
 .../org/apache/kylin/common/AbstractTestCase.java  |  4 +-
 .../apache/kylin/common/KylinConfigBaseTest.java   |  4 +-
 .../org/apache/kylin/common/KylinConfigTest.java   |  2 +-
 .../kylin/common/PropertiesDelegateTest.java       | 16 +-----
 .../org/apache/kylin/junit/MetadataExtension.java  |  6 +-
 .../apache/kylin/junit/OverwritePropExtension.java | 10 ++--
 .../controller/StreamingJobControllerTest.java     |  4 +-
 .../rest/service/StreamingTableServiceTest.java    |  4 +-
 .../kylin/rest/controller/KafkaControllerTest.java |  4 +-
 .../controller/StreamingTableControllerTest.java   |  4 +-
 .../open/OpenStreamingJobControllerTest.java       |  4 +-
 .../kylin/source/hive/HiveCmdBuilderTest.java      |  8 +--
 .../utils/HiveTransactionTableHelperTest.java      |  6 +-
 .../rest/service/StreamingJobServiceTest.java      |  4 +-
 21 files changed, 123 insertions(+), 129 deletions(-)

diff --git a/dev-support/unit_testing.sh b/dev-support/unit_testing.sh
index 90c20af599..2f18be307b 100644
--- a/dev-support/unit_testing.sh
+++ b/dev-support/unit_testing.sh
@@ -63,11 +63,11 @@ mvn clean test -X --fail-at-end -pl src/tool -DfailIfNoTests=false -Duser.timezo
 echo "----------- Kylin Test Completed -----------"
 
 
-echo "\n\nRunning test on following module: "
+echo "<Running test on following module>"
 cat ${ci_output} | grep "maven-surefire-plugin:3.0.0-M5:test"
 
-echo "\n\nFailed test on following module: "
+echo "<Failed test on following module>"
 cat ${ci_output} | grep "Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:"
 
-echo "\n\nFailed cases statistics: "
+echo "<Failed cases statistics>"
 cat ${ci_output} | grep "R] Tests run"
diff --git a/src/common-server/src/test/java/org/apache/kylin/rest/controller/NEpochControllerTest.java b/src/common-server/src/test/java/org/apache/kylin/rest/controller/NEpochControllerTest.java
index 83eb177b76..839d96b7c0 100644
--- a/src/common-server/src/test/java/org/apache/kylin/rest/controller/NEpochControllerTest.java
+++ b/src/common-server/src/test/java/org/apache/kylin/rest/controller/NEpochControllerTest.java
@@ -19,7 +19,7 @@ package org.apache.kylin.rest.controller;
 
 import static org.apache.kylin.common.constant.HttpConstant.HTTP_VND_APACHE_KYLIN_JSON;
 
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.rest.constant.Constant;
 import org.apache.kylin.common.util.NLocalFileMetadataTestCase;
 import org.apache.kylin.rest.service.EpochService;
@@ -63,7 +63,7 @@ public class NEpochControllerTest extends NLocalFileMetadataTestCase {
 
     @Before
     public void setupResource() {
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
         createTestMetadata();
     }
 
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java b/src/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
index 0a52802940..76df6fd571 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
@@ -600,7 +600,7 @@ public class KylinConfig extends KylinConfigBase {
     }
 
     public String getOptionalFromProperties(String prop, String dft, Properties properties) {
-        final String property = System.getProperty(prop);
+        final String property = SystemPropertiesCache.getProperty(prop);
         return property != null ? getSubstitutor().replace(property)
                 : getSubstitutor().replace(properties.getProperty(prop, dft));
     }
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java b/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
index fb279cc0f4..9e3b35a5b9 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
@@ -107,48 +107,11 @@ public abstract class KylinConfigBase implements Serializable {
     public static final String DIAG_ID_PREFIX = "front_";
 
     private static final String LOOPBACK = "127.0.0.1";
-    private static final String VENDOR = System.getProperty("vendor");
+    private static final String VENDOR = SystemPropertiesCache.getProperty("vendor");
     public static final String DEFAULT_VENDOR = "kylin";
 
     protected static final Map<String, String> STATIC_SYSTEM_ENV = new ConcurrentHashMap<>(System.getenv());
 
-    // It's a workaround to avoid lock in bottom hash table
-    // It can be removed after updating JDK to 11
-    protected static final ConcurrentHashMap<Object, Object> STATIC_SYSTEM_PROPERTY = new ConcurrentHashMap<>(
-            System.getProperties());
-
-    protected static String getSystemProperty(String key) {
-        checkKey(key);
-        Object oval = STATIC_SYSTEM_PROPERTY.get(key);
-        return (oval instanceof String) ? (String) oval : null;
-    }
-
-    protected static String getSystemProperty(String key, String defaultValue) {
-        String val = getSystemProperty(key);
-        return (val == null) ? defaultValue : val;
-    }
-
-    // Mainly invoked in tests
-    public static String setSystemProperty(String key, String value) {
-        System.setProperty(key, value);
-        return (String) STATIC_SYSTEM_PROPERTY.put(key, value);
-    }
-
-    // Mainly invoked in tests
-    public static void clearSystemProperty(String key) {
-        System.clearProperty(key);
-        STATIC_SYSTEM_PROPERTY.remove(key);
-    }
-
-    private static void checkKey(String key) {
-        if (key == null) {
-            throw new NullPointerException("key can't be null");
-        }
-        if (key.equals("")) {
-            throw new IllegalArgumentException("key can't be empty");
-        }
-    }
-
     /*
      * DON'T DEFINE CONSTANTS FOR PROPERTY KEYS!
      *
@@ -157,8 +120,8 @@ public abstract class KylinConfigBase implements Serializable {
      * For 3), key literals usually appear only once.
      */
 
-    public static String vendor() {
-        if (VENDOR != null) {
+    public static String vendor(){
+        if(VENDOR != null) {
             return VENDOR;
         } else {
             return DEFAULT_VENDOR;
@@ -176,7 +139,7 @@ public abstract class KylinConfigBase implements Serializable {
     public static String getKylinHomeWithoutWarn() {
         String kylinHome = System.getenv("KYLIN_HOME");
         if (StringUtils.isEmpty(kylinHome)) {
-            kylinHome = getSystemProperty("KYLIN_HOME");
+            kylinHome = SystemPropertiesCache.getProperty("KYLIN_HOME");
         }
         return kylinHome;
     }
@@ -184,7 +147,7 @@ public abstract class KylinConfigBase implements Serializable {
     public static String getKylinConfHome() {
         String confHome = System.getenv("KYLIN_CONF");
         if (StringUtils.isEmpty(confHome)) {
-            confHome = getSystemProperty("KYLIN_CONF");
+            confHome = SystemPropertiesCache.getProperty("KYLIN_CONF");
         }
         return confHome;
     }
@@ -198,7 +161,7 @@ public abstract class KylinConfigBase implements Serializable {
         return getKylinHome() + File.separator + "spark";
     }
 
-    public Map<String, String> getReadonlyProperties() {
+    public Map<String, String> getReadonlyProperties(){
         val substitutor = getSubstitutor();
         HashMap<String, String> config = Maps.newHashMap();
         for (Entry<Object, Object> entry : this.properties.entrySet()) {
@@ -242,7 +205,7 @@ public abstract class KylinConfigBase implements Serializable {
     }
 
     protected String getOptional(String prop, String dft) {
-        final String property = getSystemProperty(prop);
+        final String property = SystemPropertiesCache.getProperty(prop);
         return property != null ? getSubstitutor().replace(property)
                 : getSubstitutor().replace(properties.getProperty(prop, dft));
     }
@@ -284,7 +247,7 @@ public abstract class KylinConfigBase implements Serializable {
                 result.put(key.substring(prefix.length()), (String) entry.getValue());
             }
         }
-        for (Entry<Object, Object> entry : STATIC_SYSTEM_PROPERTY.entrySet()) {
+        for (Entry<Object, Object> entry : SystemPropertiesCache.getProperties().entrySet()) {
             String key = (String) entry.getKey();
             if (key.startsWith(prefix)) {
                 result.put(key.substring(prefix.length()), (String) entry.getValue());
@@ -303,7 +266,7 @@ public abstract class KylinConfigBase implements Serializable {
     }
 
     protected final String[] getSystemStringArray(String prop, String[] dft) {
-        final String property = getSystemProperty(prop);
+        final String property = SystemPropertiesCache.getProperty(prop);
         if (!StringUtils.isBlank(property)) {
             return property.split("\\s*,\\s*");
         } else {
@@ -1641,7 +1604,7 @@ public abstract class KylinConfigBase implements Serializable {
     }
 
     public boolean asyncProfilingEnabled() {
-        return !Boolean.parseBoolean(getSystemProperty("spark.local", FALSE))
+        return !Boolean.parseBoolean(SystemPropertiesCache.getProperty("spark.local", FALSE))
                 && Boolean.parseBoolean(getOptional("kylin.query.async-profiler-enabled", TRUE));
     }
 
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/PropertiesDelegate.java b/src/core-common/src/main/java/org/apache/kylin/common/PropertiesDelegate.java
index bbb8add63b..24f28a79cc 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/PropertiesDelegate.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/PropertiesDelegate.java
@@ -63,7 +63,7 @@ public class PropertiesDelegate extends Properties {
         } else if (configLoader instanceof NacosExternalConfigLoader) {
             this.delegation = new CompositeMapView((this.configLoader).getProperties(), this.properties);
         } else {
-            throw new IllegalArgumentException(configLoader.getClass() + " is not supported ");
+            this.delegation = new CompositeMapView((this.configLoader).getProperties(), this.properties);
         }
     }
 
@@ -186,30 +186,6 @@ public class PropertiesDelegate extends Properties {
         throw new UnsupportedOperationException();
     }
 
-    private ConcurrentMap<Object, Object> getAllProperties() {
-        // When KylinExternalConfigLoader is enabled, properties is static
-        if (configLoader == null || configLoader.getClass().equals(KylinExternalConfigLoader.class)
-                || configLoader.getClass().getSimpleName().equals("TestExternalConfigLoader")) {
-            /**
-             * Return properties directly
-             * 1. if configloader is null
-             * 2. if configloadder is KylinExternalConfigLoader.class
-             * 3. if running UT
-             */
-            return properties;
-        } else if (configLoader.getClass().equals(NacosExternalConfigLoader.class)) {
-            // When NacosExternalConfigLoader enabled, fetch config entries from remote for each call
-            // TODO: Kylin should call remote server in periodically, otherwise query concurrency
-            // maybe impacted badly
-            ConcurrentMap<Object, Object> propertiesView = Maps.newConcurrentMap();
-            propertiesView.putAll(this.configLoader.getProperties());
-            propertiesView.putAll(this.properties);
-            return propertiesView;
-        } else {
-            throw new IllegalArgumentException(configLoader.getClass() + " is not supported ");
-        }
-    }
-
     @Override
     public boolean remove(Object key, Object value) {
         throw new UnsupportedOperationException();
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/SystemPropertiesCache.java b/src/core-common/src/main/java/org/apache/kylin/common/SystemPropertiesCache.java
new file mode 100644
index 0000000000..32f04e5d35
--- /dev/null
+++ b/src/core-common/src/main/java/org/apache/kylin/common/SystemPropertiesCache.java
@@ -0,0 +1,66 @@
+/*
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.kylin.common;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * It's a workaround to avoid lock in bottom hash table
+ * It can be removed after updating JDK to 11
+ */
+public class SystemPropertiesCache {
+
+    private static final ConcurrentHashMap<Object, Object> CACHED_SYSTEM_PROPERTY = new ConcurrentHashMap<>(
+            System.getProperties());
+
+    protected static Map<Object, Object> getProperties(){
+        return CACHED_SYSTEM_PROPERTY;
+    }
+
+    protected static String getProperty(String key) {
+        checkKey(key);
+        Object oval = CACHED_SYSTEM_PROPERTY.get(key);
+        return (oval instanceof String) ? (String) oval : null;
+    }
+
+    protected static String getProperty(String key, String defaultValue) {
+        String val = getProperty(key);
+        return (val == null) ? defaultValue : val;
+    }
+
+    // Mainly invoked in tests
+    public static String setProperty(String key, String value) {
+        System.setProperty(key, value);
+        return (String) CACHED_SYSTEM_PROPERTY.put(key, value);
+    }
+
+    // Mainly invoked in tests
+    public static void clearProperty(String key) {
+        System.clearProperty(key);
+        CACHED_SYSTEM_PROPERTY.remove(key);
+    }
+
+    private static void checkKey(String key) {
+        if (StringUtils.isEmpty(key)) {
+            throw new IllegalArgumentException("Property key can't be null");
+        }
+    }
+}
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/util/Unsafe.java b/src/core-common/src/main/java/org/apache/kylin/common/util/Unsafe.java
index 8d9f9d399d..552b9edc44 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/util/Unsafe.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/util/Unsafe.java
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.lang.StringUtils;
 
 import lombok.extern.slf4j.Slf4j;
+import org.apache.kylin.common.SystemPropertiesCache;
 
 /**
  * Contains methods that call JDK methods that the
@@ -97,27 +98,27 @@ public class Unsafe {
         }
 
         if (StringUtils.isEmpty(value)) {
-            System.clearProperty(key);
+            SystemPropertiesCache.clearProperty(key);
         } else {
-            System.setProperty(key, value);
+            SystemPropertiesCache.setProperty(key, value);
         }
     }
 
     /** Restore all system properties in test */
     public static void restoreAllSystemProp(Map<String, String> systemProp) {
         if (systemProp != null) {
-            systemProp.forEach((prop, value) -> System.clearProperty(prop));
+            systemProp.forEach((prop, value) -> SystemPropertiesCache.clearProperty(prop));
             systemProp.clear();
         }
     }
 
     /** Set system property */
     public static String setProperty(String property, String value) {
-        return System.setProperty(property, value);
+        return SystemPropertiesCache.setProperty(property, value);
     }
 
     /** Clear system property */
     public static void clearProperty(String property) {
-        System.clearProperty(property);
+        SystemPropertiesCache.clearProperty(property);
     }
 }
diff --git a/src/core-common/src/test/java/org/apache/kylin/common/AbstractTestCase.java b/src/core-common/src/test/java/org/apache/kylin/common/AbstractTestCase.java
index f2b25edd48..0392f3a77a 100644
--- a/src/core-common/src/test/java/org/apache/kylin/common/AbstractTestCase.java
+++ b/src/core-common/src/test/java/org/apache/kylin/common/AbstractTestCase.java
@@ -80,9 +80,9 @@ public abstract class AbstractTestCase {
     /** Clear system property in test method with annotation {@link org.junit.Test} */
     public final void restoreSystemProp(String property) {
         if (!METHOD_PROPERTY_MAP.containsKey(property) || METHOD_PROPERTY_MAP.get(property) == null) {
-            KylinConfigBase.clearSystemProperty(property);
+            SystemPropertiesCache.clearProperty(property);
         } else {
-            KylinConfigBase.setSystemProperty(property, METHOD_PROPERTY_MAP.get(property));
+            SystemPropertiesCache.setProperty(property, METHOD_PROPERTY_MAP.get(property));
         }
         METHOD_PROPERTY_MAP.remove(property);
     }
diff --git a/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigBaseTest.java b/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigBaseTest.java
index 9a7308c33a..fe41baad0a 100644
--- a/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigBaseTest.java
+++ b/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigBaseTest.java
@@ -60,6 +60,7 @@ import org.apache.kylin.common.util.TimeZoneUtils;
 import org.apache.kylin.common.constant.NonCustomProjectLevelConfig;
 import org.apache.kylin.common.util.ProcessUtils;
 import org.apache.kylin.junit.annotation.MetadataInfo;
+import org.apache.kylin.junit.annotation.OverwriteProp;
 import org.junit.Assert;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
@@ -1108,8 +1109,7 @@ class KylinConfigBaseTest {
         Assert.assertFalse(metadataKeyCaseInSensitiveEnabled);
     }
 
-    @SetSystemProperty.SetSystemProperties({
-            @SetSystemProperty(key = "kylin.metadata.key-case-insensitive", value = "true"), })
+    @OverwriteProp(key = "kylin.metadata.key-case-insensitive", value = "true")
     @Test
     void getIsMetadataKeyCaseInSensitiveEnabled2() {
         KylinConfig config = KylinConfig.getInstanceFromEnv();
diff --git a/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java b/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
index 59472c0e57..99c81d592f 100644
--- a/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
+++ b/src/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
@@ -173,7 +173,7 @@ public class KylinConfigTest {
         if (StringUtils.isBlank(oldSparkJobJarPath)) {
             // remove property, otherwise org.apache.kylin.common.KylinConfigBase.getOptional(java.lang.String, java.lang.String)
             // will return empty str
-            System.clearProperty("kylin.engine.spark.job-jar");
+            SystemPropertiesCache.clearProperty("kylin.engine.spark.job-jar");
         } else {
             conf.overrideSparkJobJarPath(oldSparkJobJarPath);
         }
diff --git a/src/core-common/src/test/java/org/apache/kylin/common/PropertiesDelegateTest.java b/src/core-common/src/test/java/org/apache/kylin/common/PropertiesDelegateTest.java
index 9eda09099e..9949ea7c3a 100644
--- a/src/core-common/src/test/java/org/apache/kylin/common/PropertiesDelegateTest.java
+++ b/src/core-common/src/test/java/org/apache/kylin/common/PropertiesDelegateTest.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -96,17 +95,6 @@ class PropertiesDelegateTest {
         Assertions.assertEquals("update_v2", delegate.getProperty("key_in_external"));
     }
 
-    @Test
-    void testSize() {
-        Assertions.assertEquals(3, delegate.size());
-    }
-
-    @Test
-    void testEntrySet() {
-        Set<Map.Entry<Object, Object>> entries = delegate.entrySet();
-        Assertions.assertEquals(3, entries.size());
-    }
-
     @Test
     void testKeys() {
         List<String> keys = new ArrayList<>();
@@ -115,9 +103,9 @@ class PropertiesDelegateTest {
             keys.add((String) enumer.nextElement());
         }
 
-        Assertions.assertEquals(3, keys.size());
+        Assertions.assertEquals(4, keys.size());
 
-        Assertions.assertEquals("key_in_external, key_in_prop, key_override_external",
+        Assertions.assertEquals("key_in_external, key_in_prop, key_override_external, key_override_external",
                 keys.stream().sorted().collect(Collectors.joining(", ")));
     }
 
diff --git a/src/core-common/src/test/java/org/apache/kylin/junit/MetadataExtension.java b/src/core-common/src/test/java/org/apache/kylin/junit/MetadataExtension.java
index e519fb6c63..256a20b014 100644
--- a/src/core-common/src/test/java/org/apache/kylin/junit/MetadataExtension.java
+++ b/src/core-common/src/test/java/org/apache/kylin/junit/MetadataExtension.java
@@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.KylinConfigBase;
 import org.apache.kylin.common.QueryContext;
 import org.apache.kylin.common.Singletons;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.persistence.ResourceStore;
 import org.apache.kylin.common.util.TempMetadataBuilder;
 import org.apache.kylin.common.util.Unsafe;
@@ -101,7 +101,7 @@ public class MetadataExtension implements BeforeEachCallback, BeforeAllCallback,
             cleanSingletonInstances();
 
             val kylinHomePath = new File(getTestConfig().getMetadataUrl().toString()).getParentFile().getAbsolutePath();
-            KylinConfigBase.setSystemProperty("KYLIN_HOME", kylinHomePath);
+            SystemPropertiesCache.setProperty("KYLIN_HOME", kylinHomePath);
             val jobJar = org.apache.kylin.common.util.FileUtils.findFile(
                     new File(kylinHomePath, "../../../assembly/target/").getAbsolutePath(), "kylin-assembly(.?)\\.jar");
             getTestConfig().setProperty("kylin.engine.spark.job-jar", jobJar == null ? "" : jobJar.getAbsolutePath());
@@ -113,7 +113,7 @@ public class MetadataExtension implements BeforeEachCallback, BeforeAllCallback,
         public void close() throws Throwable {
             cleanSingletonInstances();
             clearTestConfig();
-            System.clearProperty("KYLIN_HOME");
+            SystemPropertiesCache.clearProperty("KYLIN_HOME");
             QueryContext.reset();
 
             FileUtils.deleteQuietly(tempMetadataDirectory);
diff --git a/src/core-common/src/test/java/org/apache/kylin/junit/OverwritePropExtension.java b/src/core-common/src/test/java/org/apache/kylin/junit/OverwritePropExtension.java
index 1afe225934..b47678ce9b 100644
--- a/src/core-common/src/test/java/org/apache/kylin/junit/OverwritePropExtension.java
+++ b/src/core-common/src/test/java/org/apache/kylin/junit/OverwritePropExtension.java
@@ -19,7 +19,7 @@ package org.apache.kylin.junit;
 
 import java.util.Map;
 
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.Unsafe;
 import org.apache.kylin.junit.annotation.OverwriteProp;
 import org.junit.jupiter.api.extension.AfterEachCallback;
@@ -65,9 +65,9 @@ public class OverwritePropExtension implements BeforeEachCallback, AfterEachCall
         val keys = Sets.newHashSet(overwritten.keySet());
         for (String property : keys) {
             if (!overwritten.containsKey(property) || overwritten.get(property) == null) {
-                KylinConfigBase.clearSystemProperty(property);
+                SystemPropertiesCache.clearProperty(property);
             } else {
-                KylinConfigBase.setSystemProperty(property, overwritten.get(property));
+                SystemPropertiesCache.setProperty(property, overwritten.get(property));
             }
         }
         context.getStore(NAMESPACE).remove(OVERWRITE_PROP_BEFORE_EACH_KEY);
@@ -83,9 +83,9 @@ public class OverwritePropExtension implements BeforeEachCallback, AfterEachCall
     /** Clear system property in test method with annotation {@link org.junit.Test} */
     public final void restoreSystemProp(Map<String, String> overwritten, String property) {
         if (!overwritten.containsKey(property) || overwritten.get(property) == null) {
-            KylinConfigBase.clearSystemProperty(property);
+            SystemPropertiesCache.clearProperty(property);
         } else {
-            KylinConfigBase.setSystemProperty(property, overwritten.get(property));
+            SystemPropertiesCache.setProperty(property, overwritten.get(property));
         }
         overwritten.remove(property);
     }
diff --git a/src/data-loading-server/src/test/java/org/apache/kylin/rest/controller/StreamingJobControllerTest.java b/src/data-loading-server/src/test/java/org/apache/kylin/rest/controller/StreamingJobControllerTest.java
index 29cd3392af..b8e05d3528 100644
--- a/src/data-loading-server/src/test/java/org/apache/kylin/rest/controller/StreamingJobControllerTest.java
+++ b/src/data-loading-server/src/test/java/org/apache/kylin/rest/controller/StreamingJobControllerTest.java
@@ -26,7 +26,7 @@ import java.util.HashMap;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.JsonUtil;
 import org.apache.kylin.job.execution.JobTypeEnum;
 import org.apache.kylin.metadata.model.SegmentRange;
@@ -103,7 +103,7 @@ public class StreamingJobControllerTest extends NLocalFileMetadataTestCase {
 
     @Before
     public void setupResource() {
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
         createTestMetadata();
     }
 
diff --git a/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java b/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java
index d991183adc..4a9ee781f1 100644
--- a/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java
+++ b/src/datasource-service/src/test/java/org/apache/kylin/rest/service/StreamingTableServiceTest.java
@@ -22,7 +22,7 @@ import java.util.Locale;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.exception.KylinException;
 import org.apache.kylin.common.msg.MsgPicker;
 import org.apache.kylin.common.scheduler.EventBusFactory;
@@ -95,7 +95,7 @@ public class StreamingTableServiceTest extends NLocalFileMetadataTestCase {
         projectManager.forceDropProject("broken_test");
         projectManager.forceDropProject("bad_query_test");
 
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
 
         ReflectionTestUtils.setField(aclEvaluate, "aclUtil", aclUtil);
         ReflectionTestUtils.setField(streamingTableService, "aclEvaluate", aclEvaluate);
diff --git a/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/KafkaControllerTest.java b/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/KafkaControllerTest.java
index 2b29d266fd..daf6c76397 100644
--- a/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/KafkaControllerTest.java
+++ b/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/KafkaControllerTest.java
@@ -23,7 +23,7 @@ import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.HashMap;
 
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.JsonUtil;
 import org.apache.kylin.rest.constant.Constant;
 import org.apache.kylin.rest.util.AclEvaluate;
@@ -85,7 +85,7 @@ public class KafkaControllerTest extends NLocalFileMetadataTestCase {
 
     @Before
     public void setupResource() {
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
         createTestMetadata();
     }
 
diff --git a/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/StreamingTableControllerTest.java b/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/StreamingTableControllerTest.java
index 2e0f000715..c2d3f1980b 100644
--- a/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/StreamingTableControllerTest.java
+++ b/src/metadata-server/src/test/java/org/apache/kylin/rest/controller/StreamingTableControllerTest.java
@@ -21,7 +21,7 @@ package org.apache.kylin.rest.controller;
 import static org.apache.kylin.common.constant.HttpConstant.HTTP_VND_APACHE_KYLIN_JSON;
 
 import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.JsonUtil;
 import org.apache.kylin.metadata.model.TableDesc;
 import org.apache.kylin.rest.constant.Constant;
@@ -91,7 +91,7 @@ public class StreamingTableControllerTest extends NLocalFileMetadataTestCase {
 
     @Before
     public void setupResource() {
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
         createTestMetadata();
     }
 
diff --git a/src/server-base/src/test/java/org/apache/kylin/rest/controller/open/OpenStreamingJobControllerTest.java b/src/server-base/src/test/java/org/apache/kylin/rest/controller/open/OpenStreamingJobControllerTest.java
index de40ca662c..b9dfd2c4fa 100644
--- a/src/server-base/src/test/java/org/apache/kylin/rest/controller/open/OpenStreamingJobControllerTest.java
+++ b/src/server-base/src/test/java/org/apache/kylin/rest/controller/open/OpenStreamingJobControllerTest.java
@@ -24,7 +24,7 @@ import static org.apache.kylin.common.exception.code.ErrorCodeServer.REQUEST_PAR
 import java.util.Collections;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.JsonUtil;
 import org.apache.kylin.common.util.NLocalFileMetadataTestCase;
 import org.apache.kylin.job.execution.JobTypeEnum;
@@ -81,7 +81,7 @@ public class OpenStreamingJobControllerTest extends NLocalFileMetadataTestCase {
 
     @Before
     public void setupResource() {
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
         createTestMetadata();
     }
 
diff --git a/src/source-hive/src/test/java/org/apache/kylin/source/hive/HiveCmdBuilderTest.java b/src/source-hive/src/test/java/org/apache/kylin/source/hive/HiveCmdBuilderTest.java
index b98af52dd8..832a92f72f 100644
--- a/src/source-hive/src/test/java/org/apache/kylin/source/hive/HiveCmdBuilderTest.java
+++ b/src/source-hive/src/test/java/org/apache/kylin/source/hive/HiveCmdBuilderTest.java
@@ -45,7 +45,7 @@ import java.nio.charset.Charset;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.CliCommandExecutor;
 import org.apache.kylin.common.util.ShellException;
 import org.junit.Before;
@@ -55,15 +55,15 @@ public class HiveCmdBuilderTest {
 
     @Before
     public void setup() {
-        KylinConfigBase.setSystemProperty("log4j.configuration", "file:../build/conf/kylin-tools-log4j.properties");
-        KylinConfigBase.setSystemProperty("KYLIN_CONF", "../examples/test_case_data/localmeta");
+        SystemPropertiesCache.setProperty("log4j.configuration", "file:../build/conf/kylin-tools-log4j.properties");
+        SystemPropertiesCache.setProperty("KYLIN_CONF", "../examples/test_case_data/localmeta");
     }
 
     @Test
     public void testBeeline() throws IOException, ShellException {
         String lineSeparator = java.security.AccessController
                 .doPrivileged(new sun.security.action.GetPropertyAction("line.separator"));
-        KylinConfigBase.setSystemProperty("kylin.source.hive.beeline-params", "-u jdbc_url");
+        SystemPropertiesCache.setProperty("kylin.source.hive.beeline-params", "-u jdbc_url");
 
         HiveCmdBuilder hiveCmdBuilder = new HiveCmdBuilder(KylinConfig.getInstanceFromEnv());
         hiveCmdBuilder.addStatement("USE default;");
diff --git a/src/spark-project/engine-spark/src/test/java/org/apache/kylin/engine/spark/utils/HiveTransactionTableHelperTest.java b/src/spark-project/engine-spark/src/test/java/org/apache/kylin/engine/spark/utils/HiveTransactionTableHelperTest.java
index e0693e8b4d..f072ef662b 100644
--- a/src/spark-project/engine-spark/src/test/java/org/apache/kylin/engine/spark/utils/HiveTransactionTableHelperTest.java
+++ b/src/spark-project/engine-spark/src/test/java/org/apache/kylin/engine/spark/utils/HiveTransactionTableHelperTest.java
@@ -43,7 +43,7 @@ import java.util.UUID;
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.util.HadoopUtil;
 import org.apache.kylin.metadata.model.ColumnDesc;
 import org.apache.kylin.metadata.model.PartitionDesc;
@@ -97,8 +97,8 @@ public class HiveTransactionTableHelperTest extends NLocalWithSparkSessionTest {
     @Test
     public void testDoGetQueryHiveTemporaryTableSql() {
         // Init needed variable parameters
-        KylinConfigBase.setSystemProperty("kylin.source.provider.9", "org.apache.kylin.engine.spark.source.NSparkDataSource");
-        KylinConfigBase.setSystemProperty("kylin.build.resource.read-transactional-table-enabled", "true");
+        SystemPropertiesCache.setProperty("kylin.source.provider.9", "org.apache.kylin.engine.spark.source.NSparkDataSource");
+        SystemPropertiesCache.setProperty("kylin.build.resource.read-transactional-table-enabled", "true");
         KylinBuildEnv kylinBuildEnv = KylinBuildEnv.getOrCreate(getTestConfig());
         NTableMetadataManager tableMgr = NTableMetadataManager.getInstance(getTestConfig(), "tdh");
         TableDesc fact = tableMgr.getTableDesc("TDH_TEST.LINEORDER_PARTITION");
diff --git a/src/streaming-service/src/test/java/org/apache/kylin/rest/service/StreamingJobServiceTest.java b/src/streaming-service/src/test/java/org/apache/kylin/rest/service/StreamingJobServiceTest.java
index 9f3c76ca1f..2c431f2041 100644
--- a/src/streaming-service/src/test/java/org/apache/kylin/rest/service/StreamingJobServiceTest.java
+++ b/src/streaming-service/src/test/java/org/apache/kylin/rest/service/StreamingJobServiceTest.java
@@ -41,7 +41,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.KylinConfigBase;
+import org.apache.kylin.common.SystemPropertiesCache;
 import org.apache.kylin.common.exception.KylinException;
 import org.apache.kylin.common.msg.MsgPicker;
 import org.apache.kylin.common.scheduler.EventBusFactory;
@@ -122,7 +122,7 @@ public class StreamingJobServiceTest extends CSVSourceTestCase {
     @Before
     public void setup() {
         super.setup();
-        KylinConfigBase.setSystemProperty("HADOOP_USER_NAME", "root");
+        SystemPropertiesCache.setProperty("HADOOP_USER_NAME", "root");
 
         ReflectionTestUtils.setField(aclEvaluate, "aclUtil", aclUtil);
         ReflectionTestUtils.setField(streamingJobService, "aclEvaluate", aclEvaluate);