diff --git a/bom/pom.xml b/bom/pom.xml index b6f0ad425aa78c2b77b58535715e048712ce3d34..caac9e152f884df657ef084cd8956beffbd85462 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -110,6 +110,7 @@ <xz.version>1.8</xz.version> <commons-compress.version>1.19</commons-compress.version> <ant.version>1.10.6</ant.version> + <snakeyaml.version>1.26</snakeyaml.version> <lz4.version>1.7.1</lz4.version> <!-- Compiler settings properties --> @@ -173,6 +174,11 @@ <artifactId>config</artifactId> <version>${config.version}</version> </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>${snakeyaml.version}</version> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> @@ -248,8 +254,8 @@ <version>${apache-zookeeper.version}</version> <exclusions> <exclusion> - <artifactId>io.netty</artifactId> - <groupId>netty</groupId> + <artifactId>io.netty</artifactId> + <groupId>netty</groupId> </exclusion> </exclusions> </dependency> diff --git a/config/seata-config-core/pom.xml b/config/seata-config-core/pom.xml index dd147b13fd31c9202479be04beb49106afcb2afd..f9a2f0e447919abacedc68442cd88c12886f7cd6 100644 --- a/config/seata-config-core/pom.xml +++ b/config/seata-config-core/pom.xml @@ -35,6 +35,10 @@ <groupId>com.typesafe</groupId> <artifactId>config</artifactId> </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> diff --git a/config/seata-config-core/src/main/java/io/seata/config/ConfigurationCache.java b/config/seata-config-core/src/main/java/io/seata/config/ConfigurationCache.java index 56e2b93e280cb9080e4622205271c21a6aab5812..c7ea93054737d616e13792e79da27179100dff3f 100644 --- a/config/seata-config-core/src/main/java/io/seata/config/ConfigurationCache.java +++ b/config/seata-config-core/src/main/java/io/seata/config/ConfigurationCache.java @@ -100,4 +100,7 @@ public class ConfigurationCache implements ConfigurationChangeListener { private static final ConfigurationCache INSTANCE = new ConfigurationCache(); } + public void clear() { + CONFIG_CACHE.clear(); + } } diff --git a/config/seata-config-core/src/main/java/io/seata/config/ConfigurationFactory.java b/config/seata-config-core/src/main/java/io/seata/config/ConfigurationFactory.java index b1ba6cedeb8fa0ebd871cef09fc99015c67953f9..232fac3868592577299e7d34bc8a481e66653e7b 100644 --- a/config/seata-config-core/src/main/java/io/seata/config/ConfigurationFactory.java +++ b/config/seata-config-core/src/main/java/io/seata/config/ConfigurationFactory.java @@ -16,6 +16,7 @@ package io.seata.config; import java.util.Objects; + import io.seata.common.exception.NotSupportYetException; import io.seata.common.loader.EnhancedServiceLoader; import io.seata.common.loader.EnhancedServiceNotFoundException; @@ -33,8 +34,7 @@ public final class ConfigurationFactory { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationFactory.class); - private static final String REGISTRY_CONF_PREFIX = "registry"; - private static final String REGISTRY_CONF_SUFFIX = ".conf"; + private static final String REGISTRY_CONF_DEFAULT = "registry"; private static final String ENV_SYSTEM_KEY = "SEATA_ENV"; public static final String ENV_PROPERTY_KEY = "seataEnv"; @@ -42,28 +42,32 @@ public final class ConfigurationFactory { private static final String ENV_SEATA_CONFIG_NAME = "SEATA_CONFIG_NAME"; - public static final Configuration CURRENT_FILE_INSTANCE; + public static Configuration CURRENT_FILE_INSTANCE; static { + load(); + } + + private static void load() { String seataConfigName = System.getProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME); if (seataConfigName == null) { seataConfigName = System.getenv(ENV_SEATA_CONFIG_NAME); } if (seataConfigName == null) { - seataConfigName = REGISTRY_CONF_PREFIX; + seataConfigName = REGISTRY_CONF_DEFAULT; } String envValue = System.getProperty(ENV_PROPERTY_KEY); if (envValue == null) { envValue = System.getenv(ENV_SYSTEM_KEY); } - Configuration configuration = (envValue == null) ? new FileConfiguration(seataConfigName + REGISTRY_CONF_SUFFIX, - false) : new FileConfiguration(seataConfigName + "-" + envValue + REGISTRY_CONF_SUFFIX, false); + Configuration configuration = (envValue == null) ? new FileConfiguration(seataConfigName, + false) : new FileConfiguration(seataConfigName + "-" + envValue, false); Configuration extConfiguration = null; try { extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); if (LOGGER.isInfoEnabled()) { LOGGER.info("load Configuration:{}", extConfiguration == null ? configuration.getClass().getSimpleName() - : extConfiguration.getClass().getSimpleName()); + : extConfiguration.getClass().getSimpleName()); } } catch (EnhancedServiceNotFoundException ignore) { @@ -99,13 +103,12 @@ public final class ConfigurationFactory { String configTypeName; try { configTypeName = CURRENT_FILE_INSTANCE.getConfig( - ConfigurationKeys.FILE_ROOT_CONFIG + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR - + ConfigurationKeys.FILE_ROOT_TYPE); + ConfigurationKeys.FILE_ROOT_CONFIG + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + + ConfigurationKeys.FILE_ROOT_TYPE); if (StringUtils.isBlank(configTypeName)) { throw new NotSupportYetException("config type can not be null"); } - configType = ConfigType.getType(configTypeName); } catch (Exception e) { throw e; @@ -114,14 +117,14 @@ public final class ConfigurationFactory { Configuration configuration; if (ConfigType.File == configType) { String pathDataId = String.join(ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR, - ConfigurationKeys.FILE_ROOT_CONFIG, FILE_TYPE, NAME_KEY); + ConfigurationKeys.FILE_ROOT_CONFIG, FILE_TYPE, NAME_KEY); String name = CURRENT_FILE_INSTANCE.getConfig(pathDataId); configuration = new FileConfiguration(name); try { extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); if (LOGGER.isInfoEnabled()) { LOGGER.info("load Configuration:{}", extConfiguration == null - ? configuration.getClass().getSimpleName() : extConfiguration.getClass().getSimpleName()); + ? configuration.getClass().getSimpleName() : extConfiguration.getClass().getSimpleName()); } } catch (EnhancedServiceNotFoundException ignore) { @@ -130,7 +133,7 @@ public final class ConfigurationFactory { } } else { configuration = EnhancedServiceLoader - .load(ConfigurationProvider.class, Objects.requireNonNull(configType).name()).provide(); + .load(ConfigurationProvider.class, Objects.requireNonNull(configType).name()).provide(); } try { Configuration configurationCache; @@ -149,4 +152,11 @@ public final class ConfigurationFactory { } return null == extConfiguration ? configuration : extConfiguration; } + + protected static void reload() { + ConfigurationCache.getInstance().clear(); + load(); + instance = null; + getInstance(); + } } diff --git a/config/seata-config-core/src/main/java/io/seata/config/FileConfigFactory.java b/config/seata-config-core/src/main/java/io/seata/config/FileConfigFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..271dda1e94c46ee9121bc1d619f6f3c09ab8f840 --- /dev/null +++ b/config/seata-config-core/src/main/java/io/seata/config/FileConfigFactory.java @@ -0,0 +1,76 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config; + +import io.seata.common.loader.EnhancedServiceLoader; +import io.seata.config.file.FileConfig; +import java.io.File; +import java.util.LinkedHashMap; +import java.util.Set; + +/** + * @author wangwei-ying + */ +public class FileConfigFactory { + + public static final String DEFAULT_TYPE = "CONF"; + + public static final String YAML_TYPE = "YAML"; + + private static final LinkedHashMap<String, String> SUFFIX_MAP = new LinkedHashMap<String, String>(4) { + { + put("conf", DEFAULT_TYPE); + put("properties", DEFAULT_TYPE); + put("yml", YAML_TYPE); + } + }; + + + public static FileConfig load() { + return loadService(DEFAULT_TYPE, null, null); + } + + public static FileConfig load(File targetFile, String name) { + String fileName = targetFile.getName(); + String configType = getConfigType(fileName); + return loadService(configType, new Class[]{File.class, String.class}, new Object[]{targetFile, name}); + } + + private static String getConfigType(String fileName) { + String configType = DEFAULT_TYPE; + int suffixIndex = fileName.lastIndexOf("."); + if (suffixIndex > 0) { + configType = SUFFIX_MAP.getOrDefault(fileName.substring(suffixIndex + 1), DEFAULT_TYPE); + } + + return configType; + } + + private static FileConfig loadService(String name, Class[] argsType, Object[] args) { + FileConfig fileConfig = EnhancedServiceLoader.load(FileConfig.class, name, argsType, args); + return fileConfig; + } + + public static Set<String> getSuffixSet() { + return SUFFIX_MAP.keySet(); + } + + public synchronized static void register(String suffix, String beanActiveName) { + SUFFIX_MAP.put(suffix, beanActiveName); + } + + +} diff --git a/config/seata-config-core/src/main/java/io/seata/config/FileConfiguration.java b/config/seata-config-core/src/main/java/io/seata/config/FileConfiguration.java index 511f6b2b627ebc0f966caf5631d4c26043d228a6..92a044c53e6db0cd3720ad8b7a4af63831447dde 100644 --- a/config/seata-config-core/src/main/java/io/seata/config/FileConfiguration.java +++ b/config/seata-config-core/src/main/java/io/seata/config/FileConfiguration.java @@ -16,7 +16,9 @@ package io.seata.config; import java.io.File; +import java.io.UnsupportedEncodingException; import java.net.URL; +import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -27,13 +29,12 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; import io.netty.util.internal.ConcurrentSet; import io.seata.common.thread.NamedThreadFactory; import io.seata.common.util.CollectionUtils; import io.seata.common.util.StringUtils; import io.seata.config.ConfigFuture.ConfigOperation; +import io.seata.config.file.FileConfig; import org.apache.commons.lang.ObjectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,7 +48,7 @@ public class FileConfiguration extends AbstractConfiguration { private static final Logger LOGGER = LoggerFactory.getLogger(FileConfiguration.class); - private Config fileConfig; + private FileConfig fileConfig; private ExecutorService configOperateExecutor; @@ -59,10 +60,10 @@ public class FileConfiguration extends AbstractConfiguration { private static final String REGISTRY_TYPE = "file"; - private static final String SYS_FILE_RESOURCE_PREFIX = "file:"; + public static final String SYS_FILE_RESOURCE_PREFIX = "file:"; private final ConcurrentMap<String, Set<ConfigurationChangeListener>> configListenersMap = new ConcurrentHashMap<>( - 8); + 8); private final Map<String, String> listenedConfigMap = new HashMap<>(8); @@ -100,39 +101,20 @@ public class FileConfiguration extends AbstractConfiguration { * @param allowDynamicRefresh the allow dynamic refresh */ public FileConfiguration(String name, boolean allowDynamicRefresh) { - if (name == null) { - throw new IllegalArgumentException("name can't be null"); - } else if (name.startsWith(SYS_FILE_RESOURCE_PREFIX)) { - File targetFile = new File(name.substring(SYS_FILE_RESOURCE_PREFIX.length())); - if (targetFile.exists()) { - targetFilePath = targetFile.getPath(); - Config appConfig = ConfigFactory.parseFileAnySyntax(targetFile); - fileConfig = ConfigFactory.load(appConfig); - if (LOGGER.isInfoEnabled()) { - LOGGER.info("The configuration file used is {}", name); - } - } else { - targetFilePath = null; - } + LOGGER.info("The file name of the operation is {}", name); + File file = getConfigFile(name); + if (file == null) { + targetFilePath = null; } else { - URL resource = this.getClass().getClassLoader().getResource(name); - if (resource != null) { - targetFilePath = resource.getPath(); - fileConfig = ConfigFactory.load(name); - if (LOGGER.isInfoEnabled()) { - LOGGER.info("The configuration file used is {}", name); - } - - } else { - targetFilePath = null; - } + targetFilePath = file.getPath(); + fileConfig = FileConfigFactory.load(file, name); } /** * For seata-server side the conf file should always exists. * For application(or client) side,conf file may not exists when using seata-spring-boot-starter */ if (targetFilePath == null) { - fileConfig = ConfigFactory.load(); + fileConfig = FileConfigFactory.load(); this.allowDynamicRefresh = false; } else { targetFileLastModified = new File(targetFilePath).lastModified(); @@ -141,8 +123,68 @@ public class FileConfiguration extends AbstractConfiguration { this.name = name; configOperateExecutor = new ThreadPoolExecutor(CORE_CONFIG_OPERATE_THREAD, MAX_CONFIG_OPERATE_THREAD, - Integer.MAX_VALUE, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), - new NamedThreadFactory("configOperate", MAX_CONFIG_OPERATE_THREAD)); + Integer.MAX_VALUE, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), + new NamedThreadFactory("configOperate", MAX_CONFIG_OPERATE_THREAD)); + } + + private File getConfigFile(String name) { + try { + if (name == null) { + throw new IllegalArgumentException("name can't be null"); + } + String filePath = null; + boolean filePathCustom = name.startsWith(SYS_FILE_RESOURCE_PREFIX); + if (filePathCustom) { + filePath = name.substring(SYS_FILE_RESOURCE_PREFIX.length()); + } else { + // projectDir first + filePath = this.getClass().getClassLoader().getResource("").getPath() + name; + } + filePath = URLDecoder.decode(filePath, "utf-8"); + File targetFile = new File(filePath); + if (!targetFile.exists()) { + for (String s : FileConfigFactory.getSuffixSet()) { + targetFile = new File(filePath + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + s); + if (targetFile.exists()) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("The configuration file used is {}", targetFile.getPath()); + } + return targetFile; + } + } + } else { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("The configuration file used is {}", name); + } + return targetFile; + } + if (!filePathCustom) { + URL resource = this.getClass().getClassLoader().getResource(name); + if (resource == null) { + for (String s : FileConfigFactory.getSuffixSet()) { + resource = this.getClass().getClassLoader().getResource(name + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + s); + if (resource != null) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("The configuration file used is {}", resource.getPath()); + } + String path = resource.getPath(); + path = URLDecoder.decode(path, "utf-8"); + return new File(path); + } + } + } else { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("The configuration file used is {}", name); + } + String path = resource.getPath(); + path = URLDecoder.decode(path, "utf-8"); + return new File(path); + } + } + } catch (UnsupportedEncodingException e) { + LOGGER.error("file not found--" + e.getMessage(), e); + } + return null; } @Override @@ -161,21 +203,21 @@ public class FileConfiguration extends AbstractConfiguration { public boolean putConfig(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigOperation.PUT, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); - return (Boolean)configFuture.get(); + return (Boolean) configFuture.get(); } @Override public boolean putConfigIfAbsent(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigOperation.PUTIFABSENT, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); - return (Boolean)configFuture.get(); + return (Boolean) configFuture.get(); } @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigOperation.REMOVE, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); - return (Boolean)configFuture.get(); + return (Boolean) configFuture.get(); } @Override @@ -245,13 +287,7 @@ public class FileConfiguration extends AbstractConfiguration { if (allowDynamicRefresh) { long tempLastModified = new File(targetFilePath).lastModified(); if (tempLastModified > targetFileLastModified) { - Config tempConfig; - if (name.startsWith(SYS_FILE_RESOURCE_PREFIX)) { - Config appConfig = ConfigFactory.parseFileAnySyntax(new File(targetFilePath)); - tempConfig = ConfigFactory.load(appConfig); - } else { - tempConfig = ConfigFactory.load(name); - } + FileConfig tempConfig = FileConfigFactory.load(new File(targetFilePath), name); if (tempConfig != null) { fileConfig = tempConfig; targetFileLastModified = tempLastModified; @@ -275,7 +311,7 @@ public class FileConfiguration extends AbstractConfiguration { setFailResult(configFuture); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Could not found property {}, try to use default value instead. exception:{}", - configFuture.getDataId(), e.getMessage()); + configFuture.getDataId(), e.getMessage()); } } } @@ -300,8 +336,8 @@ public class FileConfiguration extends AbstractConfiguration { private final String dataId; private final ConfigurationChangeListener listener; private final ExecutorService executor = new ThreadPoolExecutor(CORE_LISTENER_THREAD, MAX_LISTENER_THREAD, 0L, - TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), - new NamedThreadFactory("fileListener", MAX_LISTENER_THREAD)); + TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), + new NamedThreadFactory("fileListener", MAX_LISTENER_THREAD)); /** * Instantiates a new FileListener. diff --git a/config/seata-config-core/src/main/java/io/seata/config/file/FileConfig.java b/config/seata-config-core/src/main/java/io/seata/config/file/FileConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..770568bb4dd1906ef1e50580c1c012753b97b2eb --- /dev/null +++ b/config/seata-config-core/src/main/java/io/seata/config/file/FileConfig.java @@ -0,0 +1,29 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config.file; + + +/** + * @author wangwei-ying + */ +public interface FileConfig { + /** + * @param path path expression + */ + String getString(String path); + + +} diff --git a/config/seata-config-core/src/main/java/io/seata/config/file/SimpleFileConfig.java b/config/seata-config-core/src/main/java/io/seata/config/file/SimpleFileConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..5a642ebe3df903a8a65e8ac8425071f9a083f579 --- /dev/null +++ b/config/seata-config-core/src/main/java/io/seata/config/file/SimpleFileConfig.java @@ -0,0 +1,53 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config.file; + +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; + +import io.seata.common.loader.LoadLevel; +import io.seata.common.loader.Scope; +import io.seata.config.FileConfigFactory; +import io.seata.config.FileConfiguration; + +import java.io.File; + +/** + * @author wangwei-ying + */ +@LoadLevel(name = FileConfigFactory.DEFAULT_TYPE,scope = Scope.PROTOTYPE) +public class SimpleFileConfig implements FileConfig { + + private Config fileConfig; + + public SimpleFileConfig() { + fileConfig = ConfigFactory.load(); + } + + public SimpleFileConfig(File file, String name) { + if (name.startsWith(FileConfiguration.SYS_FILE_RESOURCE_PREFIX)) { + Config appConfig = ConfigFactory.parseFileAnySyntax(file); + fileConfig = ConfigFactory.load(appConfig); + } else { + fileConfig = ConfigFactory.load(file.getName()); + } + } + + @Override + public String getString(String path) { + return fileConfig.getString(path); + } +} diff --git a/config/seata-config-core/src/main/java/io/seata/config/file/YamlFileConfig.java b/config/seata-config-core/src/main/java/io/seata/config/file/YamlFileConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..0634ad49a97ced76d8d4959b1b1b969ec348e607 --- /dev/null +++ b/config/seata-config-core/src/main/java/io/seata/config/file/YamlFileConfig.java @@ -0,0 +1,67 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config.file; + +import io.seata.common.loader.LoadLevel; +import io.seata.common.loader.Scope; +import io.seata.config.FileConfigFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.Yaml; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.Map; + +/** + * @author wangwei-ying + */ +@LoadLevel(name = FileConfigFactory.YAML_TYPE, order = 1, scope = Scope.PROTOTYPE) +public class YamlFileConfig implements FileConfig { + + private static final Logger LOGGER = LoggerFactory.getLogger(YamlFileConfig.class); + private Map configMap; + + public YamlFileConfig(File file, String name) { + Yaml yaml = new Yaml(); + try { + configMap = (Map) yaml.load(new FileInputStream(file)); + } catch (FileNotFoundException e) { + throw new IllegalArgumentException("file not found"); + } + } + + @Override + public String getString(String path) { + try { + Map config = configMap; + String[] dataId = path.split("\\."); + for (int i = 0; i < dataId.length - 1; i++) { + if (config.containsKey(dataId[i])) { + config = (Map) config.get(dataId[i]); + } else { + return null; + } + } + Object value = config.get(dataId[dataId.length - 1]); + return value == null ? null : String.valueOf(value); + } catch (Exception e) { + LOGGER.warn("get config data error" + path, e); + return null; + } + } +} diff --git a/config/seata-config-core/src/main/resources/META-INF/services/io.seata.config.file.FileConfig b/config/seata-config-core/src/main/resources/META-INF/services/io.seata.config.file.FileConfig new file mode 100644 index 0000000000000000000000000000000000000000..911c3d91a464d1887a537c8f9128e4fb4f8f6032 --- /dev/null +++ b/config/seata-config-core/src/main/resources/META-INF/services/io.seata.config.file.FileConfig @@ -0,0 +1,2 @@ +io.seata.config.file.SimpleFileConfig +io.seata.config.file.YamlFileConfig diff --git a/config/seata-config-core/src/test/java/io.seata.config/ConfigProperty.java b/config/seata-config-core/src/test/java/io.seata.config/ConfigProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..3638e0266aa7aa51aaf009328de920c73bf561b4 --- /dev/null +++ b/config/seata-config-core/src/test/java/io.seata.config/ConfigProperty.java @@ -0,0 +1,26 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config; + +/** + * @author wangwei-ying + */ +public interface ConfigProperty { + final String ENV_PROPERTY_KEY = "seataEnv"; + final String SYSTEM_PROPERTY_SEATA_CONFIG_NAME = "seata.config.name"; + final String REGISTRY_CONF_DEFAULT = "registry"; + +} diff --git a/config/seata-config-core/src/test/java/io.seata.config/FileConfigurationTest.java b/config/seata-config-core/src/test/java/io.seata.config/FileConfigurationTest.java index d42dde3533675e9879ab65f066a9cb7778b00ba0..09c9ffb44161b808d33bf365b116770ed9730bf4 100644 --- a/config/seata-config-core/src/test/java/io.seata.config/FileConfigurationTest.java +++ b/config/seata-config-core/src/test/java/io.seata.config/FileConfigurationTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; */ class FileConfigurationTest { - private Configuration fileConfig = ConfigurationFactory.getInstance(); + @BeforeEach void setUp() { @@ -40,6 +40,7 @@ class FileConfigurationTest { @Test void addConfigListener() throws InterruptedException { + Configuration fileConfig = ConfigurationFactory.getInstance(); CountDownLatch countDownLatch = new CountDownLatch(1); boolean value = fileConfig.getBoolean("service.disableGlobalTransaction"); fileConfig.addConfigListener("service.disableGlobalTransaction", (event) -> { diff --git a/config/seata-config-core/src/test/java/io.seata.config/ProConfigurationFactoryTest.java b/config/seata-config-core/src/test/java/io.seata.config/ProConfigurationFactoryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ea5607dfc9052ab6cd5d96a02b3eb5e3bff020f3 --- /dev/null +++ b/config/seata-config-core/src/test/java/io.seata.config/ProConfigurationFactoryTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static io.seata.config.ConfigProperty.ENV_PROPERTY_KEY; +import static io.seata.config.ConfigProperty.SYSTEM_PROPERTY_SEATA_CONFIG_NAME; +import static io.seata.config.ConfigProperty.REGISTRY_CONF_DEFAULT; + +/** + * @author wangwei-ying + */ +class ProConfigurationFactoryTest { + + @Test + void getInstance() { + System.setProperty(ENV_PROPERTY_KEY, "test-pro"); + System.setProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME, REGISTRY_CONF_DEFAULT); + ConfigurationFactory.reload(); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.name"), "file-test-pro.conf"); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.testBlank"), ""); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.testNull"), null); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.testExist"), null); + Configuration instance = ConfigurationFactory.getInstance(); + Assertions.assertEquals(instance.getConfig("service.disableGlobalTransaction"), "true"); + Assertions.assertEquals(instance.getConfig("service.default.grouplist"), "127.0.0.1:8092"); + + } + + @AfterAll + public static void afterAll() { + System.clearProperty(ENV_PROPERTY_KEY); + System.clearProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME); + ConfigurationFactory.reload(); + } +} \ No newline at end of file diff --git a/config/seata-config-core/src/test/java/io.seata.config/RegistryConfigurationFactoryTest.java b/config/seata-config-core/src/test/java/io.seata.config/RegistryConfigurationFactoryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4052b545b134ee30ebdff345ac53a03e1f6bfcac --- /dev/null +++ b/config/seata-config-core/src/test/java/io.seata.config/RegistryConfigurationFactoryTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static io.seata.config.ConfigProperty.ENV_PROPERTY_KEY; +import static io.seata.config.ConfigProperty.SYSTEM_PROPERTY_SEATA_CONFIG_NAME; +import static io.seata.config.ConfigProperty.REGISTRY_CONF_DEFAULT; + + +/** + * @author wangwei-ying + */ +class RegistryConfigurationFactoryTest { + + @Test + void getInstance() { + System.setProperty(ENV_PROPERTY_KEY,"test"); + System.setProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME,REGISTRY_CONF_DEFAULT); + ConfigurationFactory.reload(); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.name"),"file-test.conf"); + Configuration instance = ConfigurationFactory.getInstance(); + Assertions.assertEquals(instance.getConfig("service.disableGlobalTransaction"),"true"); + Assertions.assertEquals(instance.getConfig("service.default.grouplist"), "127.0.0.1:8091"); + + } + @AfterAll + public static void afterAll(){ + System.clearProperty(ENV_PROPERTY_KEY); + System.clearProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME); + ConfigurationFactory.reload(); + } +} \ No newline at end of file diff --git a/config/seata-config-core/src/test/java/io.seata.config/YamlConfigurationFactoryTest.java b/config/seata-config-core/src/test/java/io.seata.config/YamlConfigurationFactoryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d5d4ff26060d2522093ca664ded514221aa6c393 --- /dev/null +++ b/config/seata-config-core/src/test/java/io.seata.config/YamlConfigurationFactoryTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 1999-2019 Seata.io Group. + * + * Licensed 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 io.seata.config; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static io.seata.config.ConfigProperty.ENV_PROPERTY_KEY; +import static io.seata.config.ConfigProperty.SYSTEM_PROPERTY_SEATA_CONFIG_NAME; +import static io.seata.config.ConfigProperty.REGISTRY_CONF_DEFAULT; + +/** + * @author wangwei-ying + */ +class YamlConfigurationFactoryTest { + + @Test + public void getInstance() { + System.setProperty(ENV_PROPERTY_KEY, "test-yaml"); + System.setProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME, REGISTRY_CONF_DEFAULT); + ConfigurationFactory.reload(); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.name"), "file-test-yaml.conf"); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.testBlank"), ""); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.testNull"), null); + Assertions.assertEquals(ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig("config.file.testExist"), null); + Configuration instance = ConfigurationFactory.getInstance(); + Assertions.assertEquals(instance.getConfig("service.disableGlobalTransaction"), "true"); + Assertions.assertEquals(instance.getConfig("service.default.grouplist"), "127.0.0.1:8093"); + } + + @AfterAll + public static void afterAll() { + System.clearProperty(ENV_PROPERTY_KEY); + System.clearProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME); + ConfigurationFactory.reload(); + } +} \ No newline at end of file diff --git a/config/seata-config-core/src/test/resources/file-test-pro.conf b/config/seata-config-core/src/test/resources/file-test-pro.conf new file mode 100644 index 0000000000000000000000000000000000000000..c23cae3396a405d4cc15f5958a642e7290825cc3 --- /dev/null +++ b/config/seata-config-core/src/test/resources/file-test-pro.conf @@ -0,0 +1,8 @@ +service { + #transaction service group mapping + vgroupMapping.my_test_tx_group = "default" + #only support when registry.type=file, please don't set multiple addresses + default.grouplist = "127.0.0.1:8092" + #disable seata + disableGlobalTransaction = true +} \ No newline at end of file diff --git a/config/seata-config-core/src/test/resources/file-test-yaml.conf b/config/seata-config-core/src/test/resources/file-test-yaml.conf new file mode 100644 index 0000000000000000000000000000000000000000..196f3500aa02dd0ca6b54eaa61afa646921d6b04 --- /dev/null +++ b/config/seata-config-core/src/test/resources/file-test-yaml.conf @@ -0,0 +1,8 @@ +service { + #transaction service group mapping + vgroupMapping.my_test_tx_group = "default" + #only support when registry.type=file, please don't set multiple addresses + default.grouplist = "127.0.0.1:8093" + #disable seata + disableGlobalTransaction = true +} \ No newline at end of file diff --git a/config/seata-config-core/src/test/resources/file-test.conf b/config/seata-config-core/src/test/resources/file-test.conf new file mode 100644 index 0000000000000000000000000000000000000000..6599bd384caa34db6fe1bd4da3874efa7c97dfcf --- /dev/null +++ b/config/seata-config-core/src/test/resources/file-test.conf @@ -0,0 +1,8 @@ +service { + #transaction service group mapping + vgroupMapping.my_test_tx_group = "default" + #only support when registry.type=file, please don't set multiple addresses + default.grouplist = "127.0.0.1:8091" + #disable seata + disableGlobalTransaction = true +} \ No newline at end of file diff --git a/config/seata-config-core/src/test/resources/registry-test-pro.properties b/config/seata-config-core/src/test/resources/registry-test-pro.properties new file mode 100644 index 0000000000000000000000000000000000000000..337cb27678e723965901e2d975cfd263ab5d922e --- /dev/null +++ b/config/seata-config-core/src/test/resources/registry-test-pro.properties @@ -0,0 +1,21 @@ + +#Copyright 1999-2019 Seata.io Group. +# +#Licensed 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. +registry.type=file +registry.file.name=file-test-pro.conf + +config.type=file +config.file.name=file-test-pro.conf +config.file.testBlank= + diff --git a/config/seata-config-core/src/test/resources/registry-test-yaml.yml b/config/seata-config-core/src/test/resources/registry-test-yaml.yml new file mode 100644 index 0000000000000000000000000000000000000000..df749326afb182226be5592148839b14539b447d --- /dev/null +++ b/config/seata-config-core/src/test/resources/registry-test-yaml.yml @@ -0,0 +1,11 @@ +registry: + type: file + file: + name: file.conf +config: + type: file + file: + name: file-test-yaml.conf + # for test + testBlank: '' + testNull: diff --git a/config/seata-config-core/src/test/resources/registry-test.conf b/config/seata-config-core/src/test/resources/registry-test.conf new file mode 100644 index 0000000000000000000000000000000000000000..efe9f48c8baa6280b5bea093577c962928a316eb --- /dev/null +++ b/config/seata-config-core/src/test/resources/registry-test.conf @@ -0,0 +1,73 @@ +registry { + # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa + type = "file" + + nacos { + serverAddr = "localhost" + namespace = "" + cluster = "default" + } + eureka { + serviceUrl = "http://localhost:8761/eureka" + application = "default" + weight = "1" + } + redis { + serverAddr = "localhost:6379" + db = "0" + } + zk { + cluster = "default" + serverAddr = "127.0.0.1:2181" + sessionTimeout = 6000 + connectTimeout = 2000 + } + consul { + cluster = "default" + serverAddr = "127.0.0.1:8500" + } + etcd3 { + cluster = "default" + serverAddr = "http://localhost:2379" + } + sofa { + serverAddr = "127.0.0.1:9603" + application = "default" + region = "DEFAULT_ZONE" + datacenter = "DefaultDataCenter" + cluster = "default" + group = "SEATA_GROUP" + addressWaitTime = "3000" + } + file { + name = "file-test.conf" + } +} + +config { + # file、nacos 、apollo、zk、consul、etcd3 + type = "file" + + nacos { + serverAddr = "localhost" + namespace = "" + } + consul { + serverAddr = "127.0.0.1:8500" + } + apollo { + appId = "seata-server" + apolloMeta = "http://192.168.1.204:8801" + } + zk { + serverAddr = "127.0.0.1:2181" + sessionTimeout = 6000 + connectTimeout = 2000 + } + etcd3 { + serverAddr = "http://localhost:2379" + } + file { + name = "file-test.conf" + } +} diff --git a/script/server/config/file.conf b/script/server/config/file.conf new file mode 100644 index 0000000000000000000000000000000000000000..55f583ebbd14cd85882d1d04f2b99152fc950acd --- /dev/null +++ b/script/server/config/file.conf @@ -0,0 +1,53 @@ + +## transaction log store, only used in seata-server +store { + ## store mode: file、db、redis + mode = "file" + + ## file store property + file { + ## store location dir + dir = "sessionStore" + # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions + maxBranchSessionSize = 16384 + # globe session size , if exceeded throws exceptions + maxGlobalSessionSize = 512 + # file buffer size , if exceeded allocate new buffer + fileWriteBufferCacheSize = 16384 + # when recover batch read size + sessionReloadReadSize = 100 + # async, sync + flushDiskMode = async + } + + ## database store property + db { + ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc. + datasource = "druid" + ## mysql/oracle/postgresql/h2/oceanbase etc. + dbType = "mysql" + driverClassName = "com.mysql.jdbc.Driver" + url = "jdbc:mysql://127.0.0.1:3306/seata" + user = "mysql" + password = "mysql" + minConn = 5 + maxConn = 100 + globalTable = "global_table" + branchTable = "branch_table" + lockTable = "lock_table" + queryLimit = 100 + maxWait = 5000 + } + + ## redis store property + redis { + host = "127.0.0.1" + port = "6379" + password = "" + database = "0" + minConn = 1 + maxConn = 10 + queryLimit = 100 + } + +} diff --git a/script/server/config/file.properties b/script/server/config/file.properties new file mode 100644 index 0000000000000000000000000000000000000000..f3ee19aa943c86b869d6b9b346303802609cee73 --- /dev/null +++ b/script/server/config/file.properties @@ -0,0 +1,27 @@ +store.mode=file +store.file.dir=sessionStore +store.file.maxBranchSessionSize=16384 +store.file.maxGlobalSessionSize=512 +store.file.fileWriteBufferCacheSize=16384 +store.file.sessionReloadReadSize=100 +store.file.flushDiskMode=async +store.db.datasource=druid +store.db.dbType=mysql +store.db.driverClassName=com.mysql.jdbc.Driver +store.db.url=jdbc:mysql://127.0.0.1:3306/seata +store.db.user=mysql +store.db.password=mysql +store.db.minConn=5 +store.db.maxConn=100 +store.db.globalTable=global_table +store.db.branchTable=branch_table +store.db.lockTable=lock_table +store.db.queryLimit=100 +store.db.maxWait=5000 +store.redis.host=127.0.0.1 +store.redis.port=6379 +store.redis.password= +store.redis.database=0 +store.redis.minConn=1 +store.redis.maxConn=10 +store.redis.queryLimit=100 diff --git a/script/server/config/file.yml b/script/server/config/file.yml new file mode 100644 index 0000000000000000000000000000000000000000..791545a211be224e0594f3f7d30e33f6d3882372 --- /dev/null +++ b/script/server/config/file.yml @@ -0,0 +1,47 @@ + +## transaction log store, only used in seata-server +store: + + ## store mode: file、db、redis + mode: file + ## file store property + file: + ## store location dir + dir: sessionStore + # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions + maxBranchSessionSize: 16384 + # globe session size , if exceeded throws exceptions + maxGlobalSessionSize: 512 + # file buffer size , if exceeded allocate new buffer + fileWriteBufferCacheSize: 16384 + # when recover batch read size + sessionReloadReadSize: 100 + # async, sync + flushDiskMode: async + ## database store property + db: + ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc. + datasource: druid + ## mysql/oracle/postgresql/h2/oceanbase etc. + dbType: mysql + driverClassName: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/seata + user: mysql + password: mysql + minConn: 5 + maxConn: 100 + globalTable: global_table + branchTable: branch_table + lockTable: lock_table + queryLimit: 100 + maxWait: 5000 + ## redis store property + redis: + host: 127.0.0.1 + port: 6379 + password: "" + database: 0 + minConn: 1 + maxConn: 10 + queryLimit: 100 + diff --git a/script/server/config/registry.conf b/script/server/config/registry.conf new file mode 100644 index 0000000000000000000000000000000000000000..cd85ac735586784830eb8cf7f87dd53dfd819abd --- /dev/null +++ b/script/server/config/registry.conf @@ -0,0 +1,91 @@ +registry { + # file,nacos,eureka,redis,zk,consul,etcd3,sofa + type = "file" + loadBalance = "RandomLoadBalance" + loadBalanceVirtualNodes = 10 + + nacos { + application = "seata-server" + serverAddr = "127.0.0.1:8848" + group = "SEATA_GROUP" + namespace = "" + cluster = "default" + username = "" + password = "" + } + eureka { + serviceUrl = "http://localhost:8761/eureka" + application = "default" + weight = "1" + } + redis { + serverAddr = "localhost:6379" + db = 0 + password = "" + cluster = "default" + timeout = 0 + } + zk { + cluster = "default" + serverAddr = "127.0.0.1:2181" + sessionTimeout = 6000 + connectTimeout = 2000 + username = "" + password = "" + } + consul { + cluster = "default" + serverAddr = "127.0.0.1:8500" + } + etcd3 { + cluster = "default" + serverAddr = "http://localhost:2379" + } + sofa { + serverAddr = "127.0.0.1:9603" + application = "default" + region = "DEFAULT_ZONE" + datacenter = "DefaultDataCenter" + cluster = "default" + group = "SEATA_GROUP" + addressWaitTime = "3000" + } + file { + name = "file.conf" + } +} + +config { + # file、nacos 、apollo、zk、consul、etcd3 + type = "file" + + nacos { + serverAddr = "127.0.0.1:8848" + namespace = "" + group = "SEATA_GROUP" + username = "" + password = "" + } + consul { + serverAddr = "127.0.0.1:8500" + } + apollo { + appId = "seata-server" + apolloMeta = "http://192.168.1.204:8801" + namespace = "application" + apolloAccesskeySecret = "" + } + zk { + serverAddr = "127.0.0.1:2181" + sessionTimeout = 6000 + connectTimeout = 2000 + username = "" + password = "" + } + etcd3 { + serverAddr = "http://localhost:2379" + } + file { + name = "file.conf" + } +} diff --git a/script/server/config/registry.properties b/script/server/config/registry.properties new file mode 100644 index 0000000000000000000000000000000000000000..9c859befefb73a8613a3c3a66fa3ed53d3891b99 --- /dev/null +++ b/script/server/config/registry.properties @@ -0,0 +1,54 @@ +registry.type=file +registry.loadBalance=RandomLoadBalance +registry.loadBalanceVirtualNodes=10 +registry.nacos.application=seata-server +registry.nacos.serverAddr=127.0.0.1:8848 +registry.nacos.group=SEATA_GROUP +registry.nacos.namespace= +registry.nacos.cluster=default +registry.nacos.username= +registry.nacos.password= +registry.eureka.serviceUrl=http://localhost:8761/eureka +registry.eureka.application=default +registry.eureka.weight=1 +registry.redis.serverAddr=localhost:6379 +registry.redis.db=0 +registry.redis.password= +registry.redis.cluster=default +registry.redis.timeout=0 +registry.zk.cluster=default +registry.zk.serverAddr=127.0.0.1:2181 +registry.zk.sessionTimeout=6000 +registry.zk.connectTimeout=2000 +registry.zk.username= +registry.zk.password= +registry.consul.cluster=default +registry.consul.serverAddr=127.0.0.1:8500 +registry.etcd3.cluster=default +registry.etcd3.serverAddr=http://localhost:2379 +registry.sofa.serverAddr=127.0.0.1:9603 +registry.sofa.application=default +registry.sofa.region=DEFAULT_ZONE +registry.sofa.datacenter=DefaultDataCenter +registry.sofa.cluster=default +registry.sofa.group=SEATA_GROUP +registry.sofa.addressWaitTime=3000 +registry.file.name=file.properties +config.type=file +config.nacos.serverAddr=127.0.0.1:8848 +config.nacos.namespace= +config.nacos.group=SEATA_GROUP +config.nacos.username= +config.nacos.password= +config.consul.serverAddr=127.0.0.1:8500 +config.apollo.appId=seata-server +config.apollo.apolloMeta=http://192.168.1.204:8801 +config.apollo.namespace=application +config.apollo.apolloAccesskeySecret= +config.zk.serverAddr=127.0.0.1:2181 +config.zk.sessionTimeout=6000 +config.zk.connectTimeout=2000 +config.zk.username= +config.zk.password= +config.etcd3.serverAddr=http://localhost:2379 +config.file.name=file.properties diff --git a/script/server/config/registry.yml b/script/server/config/registry.yml new file mode 100644 index 0000000000000000000000000000000000000000..13d0d9cae86f58d9029bc1fd7ced3d29e74b5d07 --- /dev/null +++ b/script/server/config/registry.yml @@ -0,0 +1,91 @@ +registry: + # file,nacos,eureka,redis,zk,consul,etcd3,sofa + type: file + loadBalance: RandomLoadBalance + loadBalanceVirtualNodes: 10 + + nacos: + application: seata-server + serverAddr: 127.0.0.1:8848 + group: SEATA_GROUP + namespace: + cluster: default + username: + password: + + eureka: + serviceUrl: http://localhost:8761/eureka + application: default + weight: 1 + + redis: + serverAddr: localhost:6379 + db: 0 + password: + cluster: default + timeout: 0 + + zk: + cluster: default + serverAddr: 127.0.0.1:2181 + sessionTimeout: 6000 + connectTimeout: 2000 + username: + password: + + consul: + cluster: default + serverAddr: 127.0.0.1:8500 + + etcd3: + cluster: default + serverAddr: http://localhost:2379 + + sofa: + serverAddr: 127.0.0.1:9603 + application: default + region: DEFAULT_ZONE + datacenter: DefaultDataCenter + cluster: default + group: SEATA_GROUP + addressWaitTime: 3000 + + file: + name: file.yml + + + +config: + # file、nacos 、apollo、zk、consul、etcd3 + type: file + + nacos: + serverAddr: 127.0.0.1:8848 + namespace: + group: SEATA_GROUP + username: + password: + + consul: + serverAddr: 127.0.0.1:8500 + + apollo: + appId: seata-server + apolloMeta: http://192.168.1.204:8801 + namespace: application + apolloAccesskeySecret: + + zk: + serverAddr: 127.0.0.1:2181 + sessionTimeout: 6000 + connectTimeout: 2000 + username: + password: + + etcd3: + serverAddr: http://localhost:2379 + + file: + name: file.yml + +