Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[System properties] Add the system properties tool, unified system configuration items #13307

Merged
merged 38 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9f2f88e
Initialize
huajiao-hjyp Jul 21, 2023
3b75df9
update code style
huajiao-hjyp Jul 21, 2023
98592cf
delete redundant file
huajiao-hjyp Jul 21, 2023
1680e34
Change position
huajiao-hjyp Jul 24, 2023
5a04d3b
delete redundant import
huajiao-hjyp Jul 24, 2023
3c08117
Add JsonCompatibilityUtils
huajiao-hjyp Jul 27, 2023
fa0fbc9
Delete unused import
huajiao-hjyp Jul 27, 2023
bad6b52
change funcs
huajiao-hjyp Jul 27, 2023
a9d2bf8
Add test case
huajiao-hjyp Aug 2, 2023
30133e2
update color class
huajiao-hjyp Aug 2, 2023
f24fc7a
add license
huajiao-hjyp Aug 2, 2023
32d4532
fix style
huajiao-hjyp Aug 3, 2023
2a02647
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Aug 10, 2023
9773933
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Sep 5, 2023
909992d
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Oct 10, 2023
7839318
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Nov 2, 2023
6fb09f2
Add class of SystemPropertyConfigUtils
huajiao-hjyp Nov 3, 2023
94c1f19
Unify config
huajiao-hjyp Nov 7, 2023
43fc484
Fix conflict
huajiao-hjyp Nov 7, 2023
9421cd5
Delete permit
huajiao-hjyp Nov 7, 2023
541ca81
Fix style
huajiao-hjyp Nov 7, 2023
9380843
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Nov 8, 2023
7ea1a6e
unify config
huajiao-hjyp Nov 10, 2023
856be27
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Nov 10, 2023
5ea5312
Fix code style
huajiao-hjyp Nov 10, 2023
b9dfa32
Update comment
huajiao-hjyp Nov 13, 2023
412b7b4
Normalized style
huajiao-hjyp Nov 13, 2023
2985ae8
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Nov 13, 2023
c5c0c40
Fix native CI bug
huajiao-hjyp Nov 15, 2023
44558cf
unify code style
huajiao-hjyp Nov 15, 2023
86a0ff3
Add log
huajiao-hjyp Nov 15, 2023
53734a0
fix code format
huajiao-hjyp Nov 15, 2023
f6b5cde
Add log
huajiao-hjyp Nov 16, 2023
3a36239
Update graalvm
huajiao-hjyp Nov 16, 2023
826acd1
Delete log
huajiao-hjyp Nov 16, 2023
01f056e
Fix bugs
huajiao-hjyp Nov 17, 2023
a07778e
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Nov 17, 2023
0247ba3
Merge branch '3.3' of https://github.com/apache/dubbo into 3.3
huajiao-hjyp Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
*/
package org.apache.dubbo.common.aot;

import org.apache.dubbo.common.utils.SystemPropertyConfigUtils;

import static org.apache.dubbo.common.constants.CommonConstants.ThirdPartyProperty.GRAALVM_NATIVEIMAGE_IMAGECODE;

public abstract class NativeDetector {

/**
* See https://github.com/oracle/graal/blob/master/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/ImageInfo.java
*/
private static final boolean IMAGE_CODE = (System.getProperty("org.graalvm.nativeimage.imagecode") != null);
private static final boolean IMAGE_CODE =
(SystemPropertyConfigUtils.getSystemProperty(GRAALVM_NATIVEIMAGE_IMAGECODE) != null);

/**
* Returns {@code true} if invoked in the context of image building or during image runtime, else {@code false}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConcurrentHashMapUtils;
import org.apache.dubbo.common.utils.SystemPropertyConfigUtils;

import java.io.File;
import java.io.IOException;
Expand All @@ -34,6 +35,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import static org.apache.dubbo.common.constants.CommonConstants.SystemProperty.USER_HOME;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_CACHE_PATH_INACCESSIBLE;

/**
Expand Down Expand Up @@ -81,7 +83,7 @@ public static FileCacheStore getInstance(String basePath, String cacheName) {
public static FileCacheStore getInstance(String basePath, String cacheName, boolean enableFileCache) {
if (basePath == null) {
// default case: ~/.dubbo
basePath = System.getProperty("user.home") + File.separator + ".dubbo";
basePath = SystemPropertyConfigUtils.getSystemProperty(USER_HOME) + File.separator + ".dubbo";
}
if (basePath.endsWith(File.separator)) {
basePath = basePath.substring(0, basePath.length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.common.utils.SystemPropertyConfigUtils;

import java.lang.annotation.Annotation;

Expand All @@ -38,17 +39,18 @@ public class Dubbo2CompactUtils {

private static void initEnabled() {
try {
String fromProp = System.getProperty(CommonConstants.DUBBO2_COMPACT_ENABLE);
String fromProp =
SystemPropertyConfigUtils.getSystemProperty(CommonConstants.DubboProperty.DUBBO2_COMPACT_ENABLE);
if (StringUtils.isNotEmpty(fromProp)) {
enabled = Boolean.parseBoolean(fromProp);
return;
}
String fromEnv = System.getenv(CommonConstants.DUBBO2_COMPACT_ENABLE);
String fromEnv = System.getenv(CommonConstants.DubboProperty.DUBBO2_COMPACT_ENABLE);
if (StringUtils.isNotEmpty(fromEnv)) {
enabled = Boolean.parseBoolean(fromEnv);
return;
}
fromEnv = System.getenv(StringUtils.toOSStyleKey(CommonConstants.DUBBO2_COMPACT_ENABLE));
fromEnv = System.getenv(StringUtils.toOSStyleKey(CommonConstants.DubboProperty.DUBBO2_COMPACT_ENABLE));
enabled = !StringUtils.isNotEmpty(fromEnv) || Boolean.parseBoolean(fromEnv);
} catch (Throwable t) {
enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConfigUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.common.utils.SystemPropertyConfigUtils;
import org.apache.dubbo.config.AbstractConfig;
import org.apache.dubbo.config.context.ConfigConfigurationAdapter;
import org.apache.dubbo.rpc.model.ScopeModel;
Expand Down Expand Up @@ -96,10 +97,12 @@ public void initialize() throws IllegalStateException {
*/
@Deprecated
private void loadMigrationRule() {
if (Boolean.parseBoolean(System.getProperty(CommonConstants.DUBBO_MIGRATION_FILE_ENABLE, "false"))) {
String path = System.getProperty(CommonConstants.DUBBO_MIGRATION_KEY);
if (Boolean.parseBoolean(SystemPropertyConfigUtils.getSystemProperty(
CommonConstants.DubboProperty.DUBBO_MIGRATION_FILE_ENABLE, "false"))) {
String path =
SystemPropertyConfigUtils.getSystemProperty(CommonConstants.DubboProperty.DUBBO_MIGRATION_KEY);
if (StringUtils.isEmpty(path)) {
path = System.getenv(CommonConstants.DUBBO_MIGRATION_KEY);
path = System.getenv(CommonConstants.DubboProperty.DUBBO_MIGRATION_KEY);
if (StringUtils.isEmpty(path)) {
path = CommonConstants.DEFAULT_DUBBO_MIGRATION_FILE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,8 @@ public interface CommonConstants {

String DISABLED_KEY = "disabled";

String DUBBO_PROPERTIES_KEY = "dubbo.properties.file";

String DEFAULT_DUBBO_PROPERTIES = "dubbo.properties";

String DUBBO_MIGRATION_KEY = "dubbo.migration.file";

String DUBBO_MIGRATION_FILE_ENABLE = "dubbo.migration-file.enable";

String DEFAULT_DUBBO_MIGRATION_FILE = "dubbo-migration.yaml";

String ANY_VALUE = "*";
Expand Down Expand Up @@ -299,14 +293,6 @@ public interface CommonConstants {
*/
String BROADCAST_CLUSTER = "broadcast";

/**
* The property name for {@link NetworkInterface#getDisplayName() the name of network interface} that
* the Dubbo application prefers
*
* @since 2.7.6
*/
String DUBBO_PREFERRED_NETWORK_INTERFACE = "dubbo.network.interface.preferred";

@Deprecated
String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds";

Expand Down Expand Up @@ -439,12 +425,6 @@ public interface CommonConstants {
*/
String DEFAULT_SERVICE_NAME_MAPPING_PROPERTIES_PATH = "META-INF/dubbo/service-name-mapping.properties";

String CLASS_DESERIALIZE_BLOCK_ALL = "dubbo.security.serialize.blockAllClassExceptAllow";

String CLASS_DESERIALIZE_ALLOWED_LIST = "dubbo.security.serialize.allowedClassList";

String CLASS_DESERIALIZE_BLOCKED_LIST = "dubbo.security.serialize.blockedClassList";

String ENABLE_NATIVE_JAVA_GENERIC_SERIALIZE = "dubbo.security.serialize.generic.native-java-enable";

String SERIALIZE_BLOCKED_LIST_FILE_PATH = "security/serialize.blockedlist";
Expand Down Expand Up @@ -475,8 +455,6 @@ public interface CommonConstants {

String DEFAULT_VERSION = "0.0.0";

String CLASS_DESERIALIZE_OPEN_CHECK = "dubbo.security.serialize.openCheckClass";

String ROUTER_KEY = "router";

String EXPORT_ASYNC_KEY = "export-async";
Expand Down Expand Up @@ -512,16 +490,6 @@ public interface CommonConstants {

String SERVICE_MODEL = "serviceModel";

/**
* The property name for {@link NetworkInterface#getDisplayName() the name of network interface} that
* the Dubbo application will be ignored
*
* @since 2.7.6
*/
String DUBBO_NETWORK_IGNORED_INTERFACE = "dubbo.network.interface.ignored";

String OS_NAME_KEY = "os.name";

String OS_LINUX_PREFIX = "linux";

String OS_WIN_PREFIX = "win";
Expand Down Expand Up @@ -566,10 +534,6 @@ public interface CommonConstants {

String INJVM_IGNORE_SAME_MODULE_KEY = "injvm.ignore.same-module";

String SET_FUTURE_IN_SYNC_MODE = "future.sync.set";

String CLEAR_FUTURE_AFTER_GET = "future.clear.once";

String NATIVE_STUB = "nativestub";

String METADATA = "metadata";
Expand All @@ -578,8 +542,6 @@ public interface CommonConstants {

String OPTIMIZER_KEY = "optimizer";

String PREFER_JSON_FRAMEWORK_NAME = "dubbo.json-framework.prefer";

/**
* @since 3.1.0
*/
Expand Down Expand Up @@ -616,19 +578,9 @@ public interface CommonConstants {
String EXECUTOR_MANAGEMENT_MODE_DEFAULT = "default";
String EXECUTOR_MANAGEMENT_MODE_ISOLATION = "isolation";

/**
* used in JVMUtil.java ,Control stack print lines, default is 32 lines
*/
String DUBBO_JSTACK_MAXLINE = "dubbo.jstack-dump.max-line";

String ENCODE_IN_IO_THREAD_KEY = "encode.in.io";
boolean DEFAULT_ENCODE_IN_IO_THREAD = false;

/**
* @since 3.2.0
*/
String BYTE_ACCESSOR_KEY = "byte.accessor";

String PAYLOAD = "payload";

String DUBBO_METRICS_CONFIGCENTER_ENABLE = "dubbo.metrics.configcenter.enable";
Expand All @@ -643,17 +595,157 @@ public interface CommonConstants {

String REST_SERVICE_DEPLOYER_URL_ATTRIBUTE_KEY = "restServiceDeployerAttributeKey";

String SERVICE_DEPLOYER_ATTRIBUTE_KEY = "serviceDeployer";

String DUBBO_MANUAL_REGISTER_KEY = "dubbo.application.manual-register";

String DUBBO2_COMPACT_ENABLE = "dubbo.compact.enable";

String POD_NAMESPACE = "POD_NAMESPACE";

String CLUSTER_DOMAIN = "CLUSTER_DOMAIN";

String EXT_PROTOCOL = "ext.protocol";

String IS_EXTRA = "isExtra";

/**
* System-related VM properties
*/
interface SystemProperty {
huajiao-hjyp marked this conversation as resolved.
Show resolved Hide resolved

String USER_HOME = "user.home";

String SYSTEM_JAVA_VERSION = "java.version";

String SYSTEM_JAVA_IO_TMPDIR = "java.io.tmpdir";

String SYSTEM_LINE_SEPARATOR = "line.separator";

String SERIALIZATION_SECURITY_CHECK_KEY = "serialization.security.check";

String SYSTEM_BYTE_ACCESSOR_KEY = "byte.accessor";

String SYSTEM_OS_NAME = "os.name";

String SYSTEM_OS_VERSION = "os.version";

String JAVA_RUNTIME_NAME = "java.runtime.name";

String JAVA_RUNTIME_VERSION = "java.runtime.version";

String JAVA_VM_NAME = "java.vm.name";

String JAVA_VM_VERSION = "java.vm.version";

String JAVA_VM_INFO = "java.vm.info";

String JAVA_HOME = "java.home";

String OS_ARCH = "os.arch";

String SYSTEM_FILE_ENCODING = "file.encoding";

String SYSTEM_TCP_RESPONSE_TIMEOUT = "sun.rmi.transport.tcp.responseTimeout";
}

/**
* Third-party-related VM properties
*/
interface ThirdPartyProperty {
String NETTY_EPOLL_ENABLE_KEY = "netty.epoll.enable";

String SET_FUTURE_IN_SYNC_MODE = "future.sync.set";

String CLEAR_FUTURE_AFTER_GET = "future.clear.once";

String APOLLO_ADDR_KEY = "apollo.meta";

String APOLLO_CLUSTER_KEY = "apollo.cluster";

String APOLLO_ENV_KEY = "env";

String APOLLO_APPID_KEY = "app.id";

String NACOS_SERVICE_NAME_SEPARATOR = "nacos.service.name.separator";

String GRAALVM_NATIVEIMAGE_IMAGECODE = "org.graalvm.nativeimage.imagecode";

/**
* The JVM arguments to set if it can use embedded zookeeper, the default value is {@code true}.
*/
String ZOOKEEPER_CONFIG_ENABLE_EMBEDDED = "enableEmbeddedZookeeper";
}

/**
* Dubbo custom VM properties
*/
interface DubboProperty {
String DUBBO_MIGRATION_FILE_ENABLE = "dubbo.migration-file.enable";
String DUBBO_MIGRATION_KEY = "dubbo.migration.file";
String DUBBO_APPLICATION_LOGGER = "dubbo.application.logger";
String DUBBO_PROPERTIES_KEY = "dubbo.properties.file";
String DUBBO_PREFER_JSON_FRAMEWORK_NAME = "dubbo.json-framework.prefer";

/**
* used in JVMUtil.java ,Control stack print lines, default is 32 lines
*/
String DUBBO_JSTACK_MAXLINE = "dubbo.jstack-dump.max-line";

/**
* The property name for {@link NetworkInterface#getDisplayName() the name of network interface} that
* the Dubbo application will be ignored
*
* @since 2.7.6
*/
String DUBBO_NETWORK_IGNORED_INTERFACE = "dubbo.network.interface.ignored";

/**
* The property name for {@link NetworkInterface#getDisplayName() the name of network interface} that
* the Dubbo application prefers
*
* @since 2.7.6
*/
String DUBBO_PREFERRED_NETWORK_INTERFACE = "dubbo.network.interface.preferred";

String DUBBO_CLASS_DESERIALIZE_ALLOWED_LIST = "dubbo.security.serialize.allowedClassList";
String DUBBO_CLASS_DESERIALIZE_BLOCKED_LIST = "dubbo.security.serialize.blockedClassList";
String DUBBO_CLASS_DESERIALIZE_OPEN_CHECK = "dubbo.security.serialize.openCheckClass";
String DUBBO_CLASS_DESERIALIZE_BLOCK_ALL = "dubbo.security.serialize.blockAllClassExceptAllow";
String DUBBO_RESOLVE_FILE = "dubbo.resolve.file";
String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY";
String DUBBO_MONITOR_ADDRESS = "dubbo.monitor.address";
String DUBBO_CONTAINER_KEY = "dubbo.container";
String DUBBO_SHUTDOWN_HOOK_KEY = "dubbo.shutdown.hook";
String DUBBO_SPRING_CONFIG = "dubbo.spring.config";
String DUBBO_MAPPING_CACHE_FILEPATH = "dubbo.mapping.cache.filePath";

String DUBBO_MAPPING_CACHE_FILENAME = "dubbo.mapping.cache.fileName";

String DUBBO_MAPPING_CACHE_ENTRYSIZE = "dubbo.mapping.cache.entrySize";

String DUBBO_MAPPING_CACHE_MAXFILESIZE = "dubbo.mapping.cache.maxFileSize";

String DUBBO_META_CACHE_FILEPATH = "dubbo.meta.cache.filePath";

String DUBBO_META_CACHE_FILENAME = "dubbo.meta.cache.fileName";

String DUBBO_META_CACHE_ENTRYSIZE = "dubbo.meta.cache.entrySize";

String DUBBO_META_CACHE_MAXFILESIZE = "dubbo.meta.cache.maxFileSize";

String DUBBO_USE_SECURE_RANDOM_ID = "dubbo.application.use-secure-random-request-id";

String DUBBO_CLOSE_TIMEOUT_CONFIG_KEY = "dubbo.protocol.default-close-timeout";

String DUBBO_HEARTBEAT_CONFIG_KEY = "dubbo.protocol.default-heartbeat";

String DUBBO_DEFAULT_REMOTING_SERIALIZATION_PROPERTY = "DUBBO_DEFAULT_SERIALIZATION";

String DUBBO_HESSIAN_ALLOW_NON_SERIALIZABLE = "dubbo.hessian.allowNonSerializable";

String DUBBO_HESSIAN_WHITELIST = "dubbo.application.hessian2.whitelist";

String DUBBO_HESSIAN_ALLOW = "dubbo.application.hessian2.allow";

String DUBBO_HESSIAN_DENY = "dubbo.application.hessian2.deny";

String DUBBO_MANUAL_REGISTER_KEY = "dubbo.application.manual-register";

String DUBBO2_COMPACT_ENABLE = "dubbo.compact.enable";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.dubbo.common.logger;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.logger.jcl.JclLoggerAdapter;
import org.apache.dubbo.common.logger.jdk.JdkLoggerAdapter;
import org.apache.dubbo.common.logger.log4j.Log4jLoggerAdapter;
Expand All @@ -24,6 +25,7 @@
import org.apache.dubbo.common.logger.support.FailsafeErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.support.FailsafeLogger;
import org.apache.dubbo.common.utils.ConcurrentHashMapUtils;
import org.apache.dubbo.common.utils.SystemPropertyConfigUtils;
import org.apache.dubbo.rpc.model.FrameworkModel;

import java.io.File;
Expand All @@ -47,7 +49,8 @@ public class LoggerFactory {

// search common-used logging frameworks
static {
String logger = System.getProperty("dubbo.application.logger", "");
String logger =
SystemPropertyConfigUtils.getSystemProperty(CommonConstants.DubboProperty.DUBBO_APPLICATION_LOGGER, "");
switch (logger) {
case Slf4jLoggerAdapter.NAME:
setLoggerAdapter(new Slf4jLoggerAdapter());
Expand Down
Loading
Loading