From e1debce41b800fee936979b2d2607c3e192dae02 Mon Sep 17 00:00:00 2001 From: wu Date: Mon, 30 Sep 2019 17:16:30 +0800 Subject: [PATCH 01/18] support spring-boot auto configuration --- all/pom.xml | 1 - .../io/seata/config/ConfigurationFactory.java | 20 ++- .../config/ExtConfigurationProvider.java | 30 ++++ pom.xml | 1 + seata-spring-boot-starter/pom.xml | 103 +++++++++++ .../autoconfigure/SeataAutoConfiguration.java | 64 +++++++ .../boot/autoconfigure/StarterConstants.java | 105 +++++++++++ .../properties/SeataProperties.java | 69 ++++++++ .../properties/file/ClientProperties.java | 52 ++++++ .../properties/file/LockProperties.java | 50 ++++++ .../properties/file/ServiceProperties.java | 83 +++++++++ .../properties/file/ShutdownProperties.java | 43 +++++ .../properties/file/SpringProperties.java | 44 +++++ .../properties/file/SupportProperties.java | 31 ++++ .../file/ThreadFactoryProperties.java | 126 ++++++++++++++ .../file/TransactionProperties.java | 83 +++++++++ .../properties/file/TransportProperties.java | 96 +++++++++++ .../registry/ConfigApolloProperties.java | 50 ++++++ .../registry/ConfigFileProperties.java | 40 +++++ .../registry/ConfigNacosProperties.java | 60 +++++++ .../properties/registry/ConfigProperties.java | 44 +++++ .../registry/ConfigZooKeeperProperties.java | 60 +++++++ .../registry/RegistryConsulProperties.java | 50 ++++++ .../registry/RegistryEecd3Properties.java | 50 ++++++ .../registry/RegistryEurekaProperties.java | 60 +++++++ .../registry/RegistryFileProperties.java | 41 +++++ .../registry/RegistryNacosProperties.java | 60 +++++++ .../registry/RegistryProperties.java | 44 +++++ .../registry/RegistryRedisProperties.java | 51 ++++++ .../registry/RegistrySofaProperties.java | 101 +++++++++++ .../registry/RegistryZooKeeperProperties.java | 70 ++++++++ .../SpringBootConfigurationProvider.java | 163 ++++++++++++++++++ .../boot/autoconfigure/util/SpringUtils.java | 76 ++++++++ .../autoconfigure/util/StringFormatUtils.java | 108 ++++++++++++ .../io.seata.config.ExtConfigurationProvider | 1 + .../main/resources/META-INF/spring.factories | 2 + .../annotation/GlobalTransactionScanner.java | 1 + 37 files changed, 2130 insertions(+), 3 deletions(-) create mode 100644 config/seata-config-core/src/main/java/io/seata/config/ExtConfigurationProvider.java create mode 100644 seata-spring-boot-starter/pom.xml create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/SeataProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ShutdownProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ThreadFactoryProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransportProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigApolloProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigFileProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigZooKeeperProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/SpringUtils.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/StringFormatUtils.java create mode 100644 seata-spring-boot-starter/src/main/resources/META-INF/services/io.seata.config.ExtConfigurationProvider create mode 100644 seata-spring-boot-starter/src/main/resources/META-INF/spring.factories diff --git a/all/pom.xml b/all/pom.xml index e65e3b4d446..a6017de615c 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -232,7 +232,6 @@ seata-codec-kryo ${project.version} - org.springframework 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 e0c574315ed..852ab633edc 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 @@ -50,8 +50,16 @@ public final class ConfigurationFactory { if (null == envValue) { envValue = System.getenv(ENV_SYSTEM_KEY); } - CURRENT_FILE_INSTANCE = (null == envValue) ? new FileConfiguration(seataConfigName + REGISTRY_CONF_SUFFIX) + Configuration configuration = (null == envValue) ? new FileConfiguration(seataConfigName + REGISTRY_CONF_SUFFIX) : new FileConfiguration(seataConfigName + "-" + envValue + REGISTRY_CONF_SUFFIX); + Configuration extConfiguration = null; + try { + extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); + + } catch (Exception ignore) { + + } + CURRENT_FILE_INSTANCE = null == extConfiguration ? configuration : extConfiguration; } private static final String NAME_KEY = "name"; @@ -91,7 +99,15 @@ private static Configuration buildConfiguration() { + FILE_TYPE + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + NAME_KEY; String name = CURRENT_FILE_INSTANCE.getConfig(pathDataId); - return new FileConfiguration(name); + Configuration configuration = new FileConfiguration(name); + Configuration extConfiguration=null; + try { + extConfiguration=EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); + }catch (Exception ignore){ + + } + + return null == extConfiguration ? configuration : extConfiguration; } else { return EnhancedServiceLoader.load(ConfigurationProvider.class, Objects.requireNonNull(configType).name()) .provide(); diff --git a/config/seata-config-core/src/main/java/io/seata/config/ExtConfigurationProvider.java b/config/seata-config-core/src/main/java/io/seata/config/ExtConfigurationProvider.java new file mode 100644 index 00000000000..c19f5376850 --- /dev/null +++ b/config/seata-config-core/src/main/java/io/seata/config/ExtConfigurationProvider.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * the interface ext configuration provider + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +public interface ExtConfigurationProvider { + /** + * provide a AbstractConfiguration implementation instance + * @param originalConfiguration + * @return configuration + */ + Configuration provide(Configuration originalConfiguration); +} diff --git a/pom.xml b/pom.xml index 9a6a1b2d79b..d01c8224ab7 100644 --- a/pom.xml +++ b/pom.xml @@ -43,6 +43,7 @@ tm metrics codec + seata-spring-boot-starter pom diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml new file mode 100644 index 00000000000..616a549b97b --- /dev/null +++ b/seata-spring-boot-starter/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + io.seata + seata-spring-boot-starter + 0.9.0-SNAPSHOT + + jar + seata-spring-boot-starter ${project.version} + + + + 1.8 + 1.8 + UTF-8 + + 2.1.8.RELEASE + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + io.seata + seata-bom + ${project.version} + pom + import + + + + + + + + ${project.groupId} + seata-tm + ${project.version} + + + ${project.groupId} + seata-rm-datasource + ${project.version} + + + ${project.groupId} + seata-tcc + ${project.version} + + + ${project.groupId} + seata-rm + ${project.version} + + + ${project.groupId} + seata-codec-all + ${project.version} + + + ${project.groupId} + seata-spring + ${project.version} + + + + org.springframework.boot + spring-boot-autoconfigure + true + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java new file mode 100644 index 00000000000..6083b8e33ca --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java @@ -0,0 +1,64 @@ +/* + * 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.spring.boot.autoconfigure; + +import io.seata.rm.datasource.DataSourceProxy; +import io.seata.spring.annotation.GlobalTransactionScanner; +import io.seata.spring.boot.autoconfigure.properties.SeataProperties; +import io.seata.spring.boot.autoconfigure.util.SpringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.DependsOn; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@ComponentScan(basePackages = "io.seata.spring.boot.autoconfigure.properties") +@ConditionalOnProperty(prefix = StarterConstants.SEATA_PREFIX, name = "enabled", matchIfMissing = true) +@ConditionalOnClass({DataSourceProxy.class}) +@Configuration +@EnableConfigurationProperties({SeataProperties.class}) +public class SeataAutoConfiguration { + private static final Logger LOGGER = LoggerFactory.getLogger(SeataAutoConfiguration.class); + @Autowired + private SeataProperties seataProperties; + + @Bean + public SpringUtils springUtils() { + return new SpringUtils(); + } + + @Bean + @DependsOn({"springUtils"}) + @ConditionalOnMissingBean(GlobalTransactionScanner.class) + public GlobalTransactionScanner globalTransactionScanner() { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("Automatically configure Seata"); + } + return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup()); + } + + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java new file mode 100644 index 00000000000..ef10cd46e38 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java @@ -0,0 +1,105 @@ +/* + * 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.spring.boot.autoconfigure; + +import io.seata.spring.boot.autoconfigure.properties.file.ClientProperties; +import io.seata.spring.boot.autoconfigure.properties.file.LockProperties; +import io.seata.spring.boot.autoconfigure.properties.file.ServiceProperties; +import io.seata.spring.boot.autoconfigure.properties.file.ShutdownProperties; +import io.seata.spring.boot.autoconfigure.properties.file.SpringProperties; +import io.seata.spring.boot.autoconfigure.properties.file.SupportProperties; +import io.seata.spring.boot.autoconfigure.properties.file.ThreadFactoryProperties; +import io.seata.spring.boot.autoconfigure.properties.file.TransactionProperties; +import io.seata.spring.boot.autoconfigure.properties.file.TransportProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigFileProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryFileProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryProperties; + +import java.util.HashMap; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +public class StarterConstants { + public static final String SEATA_PREFIX = "seata"; + public static final String TRANSPORT_PREFIX = SEATA_PREFIX + ".transport"; + public static final String THREAD_FACTORY_PREFIX = TRANSPORT_PREFIX + ".thread-factory"; + public static final String SHUTDOWN_PREFIX = TRANSPORT_PREFIX + ".shutdown"; + public static final String SERVICE_PREFIX = SEATA_PREFIX + ".service"; + public static final String CLIENT_PREFIX = SEATA_PREFIX + ".client"; + public static final String LOCK_PREFIX = CLIENT_PREFIX + ".lock"; + public static final String TRANSACTION_PREFIX = SEATA_PREFIX + ".transaction"; + public static final String SUPPORT_PREFIX = SEATA_PREFIX + ".support"; + public static final String SPRING_PREFIX = SUPPORT_PREFIX + ".spring"; + + public static final String REGISTRY_PREFIX = SEATA_PREFIX + ".registry"; + public static final String REGISTRY_NACOS_PREFIX = REGISTRY_PREFIX + ".nacos"; + public static final String REGISTRY_EUREKA_PREFIX = REGISTRY_PREFIX + ".eureka"; + public static final String REGISTRY_REDIS_PREFIX = REGISTRY_PREFIX + ".redis"; + public static final String REGISTRY_ZK_PREFIX = REGISTRY_PREFIX + ".zk"; + public static final String REGISTRY_CONSUL_PREFIX = REGISTRY_PREFIX + ".consul"; + public static final String REGISTRY_ETCD3_PREFIX = REGISTRY_PREFIX + ".etcd3"; + public static final String REGISTRY_SOFA_PREFIX = REGISTRY_PREFIX + ".sofa"; + public static final String REGISTRY_FILE_PREFIX = REGISTRY_PREFIX + ".file"; + + public static final String CONFIG_PREFIX = SEATA_PREFIX + ".config"; + public static final String CONFIG_NACOS_PREFIX = CONFIG_PREFIX + ".nacos"; + public static final String CONFIG_APOLLO_PREFIX = CONFIG_PREFIX + ".apollo"; + public static final String CONFIG_ZK_PREFIX = CONFIG_PREFIX + ".zk"; + public static final String CONFIG_FILE_PREFIX = CONFIG_PREFIX + ".file"; + + public static final HashMap PROPERTY_MAP = new HashMap() { + private static final long serialVersionUID = -8902807645596274597L; + + { + put(CLIENT_PREFIX, ClientProperties.class); + put(LOCK_PREFIX, LockProperties.class); + put(SERVICE_PREFIX, ServiceProperties.class); + put(SHUTDOWN_PREFIX, ShutdownProperties.class); + put(SPRING_PREFIX, SpringProperties.class); + put(SUPPORT_PREFIX, SupportProperties.class); + put(THREAD_FACTORY_PREFIX, ThreadFactoryProperties.class); + put(TRANSACTION_PREFIX, TransactionProperties.class); + put(TRANSPORT_PREFIX, TransportProperties.class); + put(CONFIG_PREFIX, ConfigProperties.class); + put(CONFIG_FILE_PREFIX, ConfigFileProperties.class); + put(REGISTRY_PREFIX, RegistryProperties.class); + put(REGISTRY_FILE_PREFIX, RegistryFileProperties.class); + } + + }; + + + /** + * The following special keys need to be normalized. + */ + public static String SPECIAL_KEY_VGROUP_MAPPING = "service.vgroup_mapping"; + public static String NORMALIZED_KEY_VGROUP_MAPPING = "vgroupMapping"; + public static String SPECIAL_KEY_GROUPLIST = "grouplist"; + public static String NORMALIZED_KEY_GROUPLIST = "grouplist"; + public static String SPECIAL_KEY_DATASOURCE_AUTOPROXY = "datasource.autoproxy"; + public static String NORMALIZED_KEY_DATASOURCE_AUTOPROXY = "datasourceAutoproxy"; + public static String SPECIAL_KEY_TRANSACTION = "transaction."; + public static String NORMALIZED_KEY_TRANSACTION = "transaction."; + public static String SPECIAL_KEY_CLIENT = "client."; + public static String NORMALIZED_KEY_CLIENT = "client."; + public static String SPECIAL_KEY_CLIENT_LOCK = "client.lock."; + public static String NORMALIZED_KEY_CLIENT_LOCK = "client.lock."; + public static String SPECIAL_KEY_TRANSPORT_THREAD_FACTORY = "transport.thread-factory."; + public static String NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY = "transport.thread-factory."; +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/SeataProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/SeataProperties.java new file mode 100644 index 00000000000..c5168d4ecab --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/SeataProperties.java @@ -0,0 +1,69 @@ +/* + * 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.spring.boot.autoconfigure.properties; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.SEATA_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = SEATA_PREFIX) +public class SeataProperties { + /** + * whether enable auto configuration + */ + private boolean enabled = true; + /** + * application id + */ + private String applicationId; + /** + * transaction service group + */ + private String txServiceGroup; + + public boolean isEnabled() { + return enabled; + } + + public SeataProperties setEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + public String getApplicationId() { + return applicationId; + } + + public SeataProperties setApplicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + public String getTxServiceGroup() { + return txServiceGroup; + } + + public SeataProperties setTxServiceGroup(String txServiceGroup) { + this.txServiceGroup = txServiceGroup; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java new file mode 100644 index 00000000000..e25ea51a3a5 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CLIENT_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = CLIENT_PREFIX) +public class ClientProperties { + private int asyncCommitBufferLimit = 10000; + private int reportRetryCount = 5; + + public int getAsyncCommitBufferLimit() { + return asyncCommitBufferLimit; + } + + public ClientProperties setAsyncCommitBufferLimit(int asyncCommitBufferLimit) { + this.asyncCommitBufferLimit = asyncCommitBufferLimit; + return this; + } + + public int getReportRetryCount() { + return reportRetryCount; + } + + public ClientProperties setReportRetryCount(int reportRetryCount) { + this.reportRetryCount = reportRetryCount; + return this; + } + + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java new file mode 100644 index 00000000000..91d203dc159 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java @@ -0,0 +1,50 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.LOCK_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = LOCK_PREFIX) +public class LockProperties { + private int lockRetryInterval = 10; + private int lockRetryTimes = 30; + + public int getLockRetryInterval() { + return lockRetryInterval; + } + + public LockProperties setLockRetryInterval(int lockRetryInterval) { + this.lockRetryInterval = lockRetryInterval; + return this; + } + + public int getLockRetryTimes() { + return lockRetryTimes; + } + + public LockProperties setLockRetryTimes(int lockRetryTimes) { + this.lockRetryTimes = lockRetryTimes; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java new file mode 100644 index 00000000000..dc9cd8338d8 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java @@ -0,0 +1,83 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.SERVICE_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = SERVICE_PREFIX) +public class ServiceProperties { + /** + * vgroup->rgroup + */ + private String vgroupMapping = "default"; + /** + * only support single node + */ + private String grouplist = "127.0.0.1:8091"; + /** + * degrade current not support + */ + private boolean enableDegrade = false; + /** + * disable + */ + private boolean disable = false; + + public String getVgroupMapping() { + return vgroupMapping; + } + + public ServiceProperties setVgroupMapping(String vgroupMapping) { + this.vgroupMapping = vgroupMapping; + return this; + } + + public String getGrouplist() { + return grouplist; + } + + public ServiceProperties setGrouplist(String grouplist) { + this.grouplist = grouplist; + return this; + } + + public boolean isEnableDegrade() { + return enableDegrade; + } + + public ServiceProperties setEnableDegrade(boolean enableDegrade) { + this.enableDegrade = enableDegrade; + return this; + } + + public boolean isDisable() { + return disable; + } + + public ServiceProperties setDisable(boolean disable) { + this.disable = disable; + return this; + } + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ShutdownProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ShutdownProperties.java new file mode 100644 index 00000000000..79179c31574 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ShutdownProperties.java @@ -0,0 +1,43 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.SHUTDOWN_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = SHUTDOWN_PREFIX) +public class ShutdownProperties { + /** + * when destroy server, wait seconds + */ + private long wait = 3L; + + public long getWait() { + return wait; + } + + public ShutdownProperties setWait(long wait) { + this.wait = wait; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java new file mode 100644 index 00000000000..615e4a9e1f5 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java @@ -0,0 +1,44 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPRING_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = SPRING_PREFIX) +public class SpringProperties { + /** + * auto proxy the DataSource bean + */ + private boolean datasourceAutoproxy = true; + + public boolean isDatasourceAutoproxy() { + return datasourceAutoproxy; + } + + public SpringProperties setDatasourceAutoproxy(boolean datasourceAutoproxy) { + this.datasourceAutoproxy = datasourceAutoproxy; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java new file mode 100644 index 00000000000..fe8b32a569d --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java @@ -0,0 +1,31 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.SUPPORT_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = SUPPORT_PREFIX) +public class SupportProperties { +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ThreadFactoryProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ThreadFactoryProperties.java new file mode 100644 index 00000000000..39f484f1827 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ThreadFactoryProperties.java @@ -0,0 +1,126 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.THREAD_FACTORY_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = THREAD_FACTORY_PREFIX) +public class ThreadFactoryProperties { + private String bossThreadPrefix = "NettyBoss"; + private String workerThreadPrefix = "NettyServerNIOWorker"; + private String serverExecutorThreadPrefix = "NettyServerBizHandler"; + private boolean shareBossWorker = false; + private String clientSelectorThreadPrefix = "NettyClientSelector"; + private int clientSelectorThreadSize = 1; + private String clientWorkerThreadPrefix = "NettyClientWorkerThread"; + /** + * netty boss thread size,will not be used for UDT + */ + private int bossThreadSize = 1; + /** + * auto default pin or 8 + */ + private int workerThreadSize = 8; + + public String getBossThreadPrefix() { + return bossThreadPrefix; + } + + public ThreadFactoryProperties setBossThreadPrefix(String bossThreadPrefix) { + this.bossThreadPrefix = bossThreadPrefix; + return this; + } + + public String getWorkerThreadPrefix() { + return workerThreadPrefix; + } + + public ThreadFactoryProperties setWorkerThreadPrefix(String workerThreadPrefix) { + this.workerThreadPrefix = workerThreadPrefix; + return this; + } + + public String getServerExecutorThreadPrefix() { + return serverExecutorThreadPrefix; + } + + public ThreadFactoryProperties setServerExecutorThreadPrefix(String serverExecutorThreadPrefix) { + this.serverExecutorThreadPrefix = serverExecutorThreadPrefix; + return this; + } + + public boolean isShareBossWorker() { + return shareBossWorker; + } + + public ThreadFactoryProperties setShareBossWorker(boolean shareBossWorker) { + this.shareBossWorker = shareBossWorker; + return this; + } + + public String getClientSelectorThreadPrefix() { + return clientSelectorThreadPrefix; + } + + public ThreadFactoryProperties setClientSelectorThreadPrefix(String clientSelectorThreadPrefix) { + this.clientSelectorThreadPrefix = clientSelectorThreadPrefix; + return this; + } + + public String getClientWorkerThreadPrefix() { + return clientWorkerThreadPrefix; + } + + public ThreadFactoryProperties setClientWorkerThreadPrefix(String clientWorkerThreadPrefix) { + this.clientWorkerThreadPrefix = clientWorkerThreadPrefix; + return this; + } + + public int getClientSelectorThreadSize() { + return clientSelectorThreadSize; + } + + public ThreadFactoryProperties setClientSelectorThreadSize(int clientSelectorThreadSize) { + this.clientSelectorThreadSize = clientSelectorThreadSize; + return this; + } + + public int getBossThreadSize() { + return bossThreadSize; + } + + public ThreadFactoryProperties setBossThreadSize(int bossThreadSize) { + this.bossThreadSize = bossThreadSize; + return this; + } + + public int getWorkerThreadSize() { + return workerThreadSize; + } + + public ThreadFactoryProperties setWorkerThreadSize(int workerThreadSize) { + this.workerThreadSize = workerThreadSize; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java new file mode 100644 index 00000000000..6c6906da285 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java @@ -0,0 +1,83 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.TRANSACTION_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = TRANSACTION_PREFIX) +public class TransactionProperties { + private boolean undoDataValidation = true; + private String undoLogSerialization = "jackson"; + private int undoLogSaveDays = 7; + /** + * schedule delete expired undo_log in milliseconds + */ + private long undoLogDeletePeriod = 86400000L; + private String undoLogTable = "undo_log"; + + public boolean isUndoDataValidation() { + return undoDataValidation; + } + + public TransactionProperties setUndoDataValidation(boolean undoDataValidation) { + this.undoDataValidation = undoDataValidation; + return this; + } + + public String getUndoLogSerialization() { + return undoLogSerialization; + } + + public TransactionProperties setUndoLogSerialization(String undoLogSerialization) { + this.undoLogSerialization = undoLogSerialization; + return this; + } + + public int getUndoLogSaveDays() { + return undoLogSaveDays; + } + + public TransactionProperties setUndoLogSaveDays(int undoLogSaveDays) { + this.undoLogSaveDays = undoLogSaveDays; + return this; + } + + public long getUndoLogDeletePeriod() { + return undoLogDeletePeriod; + } + + public TransactionProperties setUndoLogDeletePeriod(long undoLogDeletePeriod) { + this.undoLogDeletePeriod = undoLogDeletePeriod; + return this; + } + + public String getUndoLogTable() { + return undoLogTable; + } + + public TransactionProperties setUndoLogTable(String undoLogTable) { + this.undoLogTable = undoLogTable; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransportProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransportProperties.java new file mode 100644 index 00000000000..96e7b05d9c8 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransportProperties.java @@ -0,0 +1,96 @@ +/* + * 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.spring.boot.autoconfigure.properties.file; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.TRANSPORT_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/09/30 + */ +@Component +@ConfigurationProperties(prefix = TRANSPORT_PREFIX) +public class TransportProperties { + /** + * tcp udt unix-domain-socket + */ + private String type = "TCP"; + /** + * NIO NATIVE + */ + private String server = "NIO"; + /** + * enable heartbeat + */ + private boolean heartbeat = true; + /** + * serialization + */ + private String serialization = "seata"; + /** + * compressor + */ + private String compressor = "none"; + + public String getType() { + return type; + } + + public TransportProperties setType(String type) { + this.type = type; + return this; + } + + public String getServer() { + return server; + } + + public TransportProperties setServer(String server) { + this.server = server; + return this; + } + + public boolean isHeartbeat() { + return heartbeat; + } + + public TransportProperties setHeartbeat(boolean heartbeat) { + this.heartbeat = heartbeat; + return this; + } + + public String getSerialization() { + return serialization; + } + + public TransportProperties setSerialization(String serialization) { + this.serialization = serialization; + return this; + } + + public String getCompressor() { + return compressor; + } + + public TransportProperties setCompressor(String compressor) { + this.compressor = compressor; + return this; + } + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigApolloProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigApolloProperties.java new file mode 100644 index 00000000000..b04807b3aa4 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigApolloProperties.java @@ -0,0 +1,50 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_APOLLO_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_APOLLO_PREFIX) +public class ConfigApolloProperties { + private String appId = "seata-server"; + private String apolloMeta = "http://192.168.1.204:8801"; + + public String getAppId() { + return appId; + } + + public ConfigApolloProperties setAppId(String appId) { + this.appId = appId; + return this; + } + + public String getApolloMeta() { + return apolloMeta; + } + + public ConfigApolloProperties setApolloMeta(String apolloMeta) { + this.apolloMeta = apolloMeta; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigFileProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigFileProperties.java new file mode 100644 index 00000000000..ca98bc2eca0 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigFileProperties.java @@ -0,0 +1,40 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_FILE_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_FILE_PREFIX) +public class ConfigFileProperties { + private String name = "file.conf"; + + public String getName() { + return name; + } + + public ConfigFileProperties setName(String name) { + this.name = name; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java new file mode 100644 index 00000000000..bdfb21cdfaf --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java @@ -0,0 +1,60 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_NACOS_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_NACOS_PREFIX) +public class ConfigNacosProperties { + private String serverAddr = "localhost"; + private String namespace = "public"; + private String cluster = "default"; + + public String getServerAddr() { + return serverAddr; + } + + public ConfigNacosProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public String getNamespace() { + return namespace; + } + + public ConfigNacosProperties setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + public String getCluster() { + return cluster; + } + + public ConfigNacosProperties setCluster(String cluster) { + this.cluster = cluster; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java new file mode 100644 index 00000000000..12869951a08 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java @@ -0,0 +1,44 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_PREFIX) +public class ConfigProperties { + /** + * file、nacos 、apollo、zk + */ + private String type = "file"; + + public String getType() { + return type; + } + + public ConfigProperties setType(String type) { + this.type = type; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigZooKeeperProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigZooKeeperProperties.java new file mode 100644 index 00000000000..e1f8bf62f40 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigZooKeeperProperties.java @@ -0,0 +1,60 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_ZK_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_ZK_PREFIX) +public class ConfigZooKeeperProperties { + private String serverAddr = "127.0.0.1:2181"; + private long sessionTimeout = 6000L; + private long connectTimeout = 2000L; + + public String getServerAddr() { + return serverAddr; + } + + public ConfigZooKeeperProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public long getSessionTimeout() { + return sessionTimeout; + } + + public ConfigZooKeeperProperties setSessionTimeout(long sessionTimeout) { + this.sessionTimeout = sessionTimeout; + return this; + } + + public long getConnectTimeout() { + return connectTimeout; + } + + public ConfigZooKeeperProperties setConnectTimeout(long connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulProperties.java new file mode 100644 index 00000000000..c84afa8f2ac --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulProperties.java @@ -0,0 +1,50 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_CONSUL_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_CONSUL_PREFIX) +public class RegistryConsulProperties { + private String cluster = "default"; + private String serverAddr = "127.0.0.1:8500"; + + public String getCluster() { + return cluster; + } + + public RegistryConsulProperties setCluster(String cluster) { + this.cluster = cluster; + return this; + } + + public String getServerAddr() { + return serverAddr; + } + + public RegistryConsulProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java new file mode 100644 index 00000000000..cc028e4b0f2 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java @@ -0,0 +1,50 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_ETCD3_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_ETCD3_PREFIX) +public class RegistryEecd3Properties { + private String cluster = "default"; + private String serverAddr = "http://localhost:2379"; + + public String getCluster() { + return cluster; + } + + public RegistryEecd3Properties setCluster(String cluster) { + this.cluster = cluster; + return this; + } + + public String getServerAddr() { + return serverAddr; + } + + public RegistryEecd3Properties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java new file mode 100644 index 00000000000..6c5e667e638 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java @@ -0,0 +1,60 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_EUREKA_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_EUREKA_PREFIX) +public class RegistryEurekaProperties { + private String serviceUrl = "http://localhost:1001/eureka"; + private String application = "default"; + private String weight = "1"; + + public String getServiceUrl() { + return serviceUrl; + } + + public RegistryEurekaProperties setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + return this; + } + + public String getApplication() { + return application; + } + + public RegistryEurekaProperties setApplication(String application) { + this.application = application; + return this; + } + + public String getWeight() { + return weight; + } + + public RegistryEurekaProperties setWeight(String weight) { + this.weight = weight; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java new file mode 100644 index 00000000000..c99845396aa --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java @@ -0,0 +1,41 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_FILE_PREFIX; +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_SOFA_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_FILE_PREFIX) +public class RegistryFileProperties { + private String name = "file.conf"; + + public String getName() { + return name; + } + + public RegistryFileProperties setName(String name) { + this.name = name; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java new file mode 100644 index 00000000000..d7cf5df8d8d --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java @@ -0,0 +1,60 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_NACOS_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_NACOS_PREFIX) +public class RegistryNacosProperties { + private String serverAddr = "localhost"; + private String namespace = "public"; + private String cluster = "default"; + + public String getServerAddr() { + return serverAddr; + } + + public RegistryNacosProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public String getNamespace() { + return namespace; + } + + public RegistryNacosProperties setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + public String getCluster() { + return cluster; + } + + public RegistryNacosProperties setCluster(String cluster) { + this.cluster = cluster; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java new file mode 100644 index 00000000000..81c225d4145 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java @@ -0,0 +1,44 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_PREFIX) +public class RegistryProperties { + /** + * file 、nacos 、eureka、redis、zk、consul、etcd3、sofa + */ + private String type = "file"; + + public String getType() { + return type; + } + + public RegistryProperties setType(String type) { + this.type = type; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java new file mode 100644 index 00000000000..ee859fcba28 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java @@ -0,0 +1,51 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_EUREKA_PREFIX; +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_REDIS_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_REDIS_PREFIX) +public class RegistryRedisProperties { + private String serverAddr = "localhost:6379"; + private String db = "0"; + + public String getServerAddr() { + return serverAddr; + } + + public RegistryRedisProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public String getDb() { + return db; + } + + public RegistryRedisProperties setDb(String db) { + this.db = db; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java new file mode 100644 index 00000000000..380f9b10cd7 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java @@ -0,0 +1,101 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_ETCD3_PREFIX; +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_SOFA_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_SOFA_PREFIX) +public class RegistrySofaProperties { + private String serverAddr = "127.0.0.1:9603"; + private String application = "default"; + private String region = "DEFAULT_ZONE"; + private String datacenter = "DefaultDataCenter"; + private String cluster = "default"; + private String group = "SEATA_GROUP"; + private String addressWaitTime = "3000"; + + public String getServerAddr() { + return serverAddr; + } + + public RegistrySofaProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public String getApplication() { + return application; + } + + public RegistrySofaProperties setApplication(String application) { + this.application = application; + return this; + } + + public String getRegion() { + return region; + } + + public RegistrySofaProperties setRegion(String region) { + this.region = region; + return this; + } + + public String getDatacenter() { + return datacenter; + } + + public RegistrySofaProperties setDatacenter(String datacenter) { + this.datacenter = datacenter; + return this; + } + + public String getCluster() { + return cluster; + } + + public RegistrySofaProperties setCluster(String cluster) { + this.cluster = cluster; + return this; + } + + public String getGroup() { + return group; + } + + public RegistrySofaProperties setGroup(String group) { + this.group = group; + return this; + } + + public String getAddressWaitTime() { + return addressWaitTime; + } + + public RegistrySofaProperties setAddressWaitTime(String addressWaitTime) { + this.addressWaitTime = addressWaitTime; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperProperties.java new file mode 100644 index 00000000000..47c4f07d4e6 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperProperties.java @@ -0,0 +1,70 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_ZK_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +@Component +@ConfigurationProperties(prefix = REGISTRY_ZK_PREFIX) +public class RegistryZooKeeperProperties { + private String cluster = "default"; + private String serverAddr = "127.0.0.1:2181"; + private long sessionTimeout = 6000L; + private long connectTimeout = 2000L; + + public String getCluster() { + return cluster; + } + + public RegistryZooKeeperProperties setCluster(String cluster) { + this.cluster = cluster; + return this; + } + + public String getServerAddr() { + return serverAddr; + } + + public RegistryZooKeeperProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + + public long getSessionTimeout() { + return sessionTimeout; + } + + public RegistryZooKeeperProperties setSessionTimeout(long sessionTimeout) { + this.sessionTimeout = sessionTimeout; + return this; + } + + public long getConnectTimeout() { + return connectTimeout; + } + + public RegistryZooKeeperProperties setConnectTimeout(long connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java new file mode 100644 index 00000000000..ab4908299ed --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java @@ -0,0 +1,163 @@ +/* + * 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.spring.boot.autoconfigure.provider; + +import io.seata.config.Configuration; +import io.seata.config.ExtConfigurationProvider; +import io.seata.spring.boot.autoconfigure.StarterConstants; +import io.seata.spring.boot.autoconfigure.util.SpringUtils; +import io.seata.spring.boot.autoconfigure.util.StringFormatUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.cglib.proxy.Enhancer; +import org.springframework.cglib.proxy.MethodInterceptor; +import org.springframework.cglib.proxy.MethodProxy; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CLIENT; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CLIENT_LOCK; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_DATASOURCE_AUTOPROXY; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_GROUPLIST; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_TRANSACTION; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_VGROUP_MAPPING; +import static io.seata.spring.boot.autoconfigure.StarterConstants.PROPERTY_MAP; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_CLIENT; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_CLIENT_LOCK; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_DATASOURCE_AUTOPROXY; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_GROUPLIST; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_TRANSACTION; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_TRANSPORT_THREAD_FACTORY; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_VGROUP_MAPPING; + + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +public class SpringBootConfigurationProvider implements ExtConfigurationProvider { + private static final String INTERCEPT_METHOD_PREFIX = "get"; + + @Override + public Configuration provide(Configuration originalConfiguration) { + return (Configuration) Enhancer.create(originalConfiguration.getClass(), new MethodInterceptor() { + @Override + public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { + if (method.getName().startsWith(INTERCEPT_METHOD_PREFIX) && args.length > 0) { + Object result = null; + String rawDataId = (String) args[0]; + if (args.length == 1) { + result = get(convertDataId(rawDataId)); + } else if (args.length == 2) { + result = get(convertDataId(rawDataId), args[1]); + } else if (args.length == 3) { + result = get(convertDataId(rawDataId), args[1], (Long) args[2]); + } + if (null != result) { + return result; + } + + } + + return method.invoke(originalConfiguration, args); + } + }); + } + + private Object get(String dataId, Object defaultValue, long timeoutMills) throws IllegalAccessException { + return get(dataId, defaultValue); + + } + + private Object get(String dataId, Object defaultValue) throws IllegalAccessException { + Object result = get(dataId); + if (null == result) { + return defaultValue; + } + return result; + } + + private Object get(String dataId) throws IllegalAccessException { + String propertySuffix = getPropertySuffix(dataId); + Class propertyClass = getPropertyClass(getPropertyPrefix(dataId)); + if (null != propertyClass) { + Object propertyObject = SpringUtils.getBean(propertyClass); + Optional fieldOptional = Stream.of(propertyObject.getClass().getDeclaredFields()).filter(f -> f.getName().equalsIgnoreCase(propertySuffix)).findAny(); + if (fieldOptional.isPresent()) { + Field field = fieldOptional.get(); + field.setAccessible(true); + return field.get(propertyObject); + } + } + return null; + } + + /** + * convert data id + * + * @param rawDataId + * @return dataId + */ + private String convertDataId(String rawDataId) { + if (rawDataId.startsWith(SPECIAL_KEY_VGROUP_MAPPING)) { + return StarterConstants.SERVICE_PREFIX + "." + NORMALIZED_KEY_VGROUP_MAPPING; + } + + if (rawDataId.endsWith(SPECIAL_KEY_GROUPLIST)) { + return StarterConstants.SERVICE_PREFIX + "." + NORMALIZED_KEY_GROUPLIST; + } + if (rawDataId.endsWith(SPECIAL_KEY_DATASOURCE_AUTOPROXY)) { + return StarterConstants.SPRING_PREFIX + "." + NORMALIZED_KEY_DATASOURCE_AUTOPROXY; + } + if (rawDataId.startsWith(SPECIAL_KEY_TRANSACTION)) { + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_TRANSACTION); + return StarterConstants.TRANSACTION_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + } + if (rawDataId.startsWith(SPECIAL_KEY_CLIENT_LOCK)) { + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CLIENT_LOCK); + return StarterConstants.LOCK_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + } + if (rawDataId.startsWith(SPECIAL_KEY_CLIENT)) { + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CLIENT); + return StarterConstants.CLIENT_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + } + if (rawDataId.startsWith(SPECIAL_KEY_TRANSPORT_THREAD_FACTORY)) { + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY); + return StarterConstants.THREAD_FACTORY_PREFIX + "." + StringFormatUtils.minusToCamel(suffix); + } + + return StarterConstants.SEATA_PREFIX + "." + rawDataId; + } + + private String getPropertyPrefix(String dataId) { + return StringFormatUtils.underlineToCamel(StringFormatUtils.minusToCamel(StringUtils.substringBeforeLast(dataId, "."))); + } + + private String getPropertySuffix(String dataId) { + return StringUtils.substringAfterLast(dataId, "."); + } + + private Class getPropertyClass(String propertyPrefix) { + Optional> entry = PROPERTY_MAP.entrySet().stream().filter(e -> propertyPrefix.equals(e.getKey())).findAny(); + return entry.map(Map.Entry::getValue).orElse(null); + } + + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/SpringUtils.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/SpringUtils.java new file mode 100644 index 00000000000..bbee6d8328a --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/SpringUtils.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.spring.boot.autoconfigure.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +public class SpringUtils implements ApplicationContextAware { + + private static ApplicationContext applicationContext; + + /** + * get applicationContext + * + * @return applicationContext + */ + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * get by name + * + * @param name + * @return bean + */ + public static Object getBean(String name) { + return getApplicationContext().getBean(name); + } + + /** + * get by class + * + * @param clazz + * @param + * @return bean + */ + public static T getBean(Class clazz) { + return getApplicationContext().getBean(clazz); + } + + /** + * get by name & class + * + * @param name + * @param clazz + * @param + * @return bean + */ + public static T getBean(String name, Class clazz) { + return getApplicationContext().getBean(name, clazz); + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + SpringUtils.applicationContext = applicationContext; + } +} \ No newline at end of file diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/StringFormatUtils.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/StringFormatUtils.java new file mode 100644 index 00000000000..658a9d395ab --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/util/StringFormatUtils.java @@ -0,0 +1,108 @@ +/* + * 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.spring.boot.autoconfigure.util; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/03 + */ +public class StringFormatUtils { + private static final char MINUS = '-'; + private static final char UNDERLINE = '_'; + private static final char DOT = '.'; + + /** + * camelTo underline format + * + * @param param + * @return formatted string + */ + public static String camelToUnderline(String param) { + if (param == null || "".equals(param.trim())) { + return ""; + } + int len = param.length(); + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) { + char c = param.charAt(i); + if (Character.isUpperCase(c)) { + sb.append(UNDERLINE); + sb.append(Character.toLowerCase(c)); + } else { + sb.append(c); + } + } + return sb.toString(); + } + + /** + * underline to camel + * + * @param param + * @return formatted string + */ + public static String underlineToCamel(String param) { + return formatCamel(param, UNDERLINE); + } + + /** + * minus to camel + * + * @param param + * @return formatted string + */ + public static String minusToCamel(String param) { + return formatCamel(param, MINUS); + } + + /** + * dot to camel + * + * @param param + * @return formatted string + */ + public static String dotToCamel(String param) { + return formatCamel(param, DOT); + } + + /** + * format camel + * + * @param param + * @param sign + * @return formatted string + */ + private static String formatCamel(String param, char sign) { + if (param == null || "".equals(param.trim())) { + return ""; + } + int len = param.length(); + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) { + char c = param.charAt(i); + if (c == sign) { + if (++i < len) { + sb.append(Character.toUpperCase(param.charAt(i))); + } + } else { + sb.append(c); + } + } + return sb.toString(); + } + + +} \ No newline at end of file diff --git a/seata-spring-boot-starter/src/main/resources/META-INF/services/io.seata.config.ExtConfigurationProvider b/seata-spring-boot-starter/src/main/resources/META-INF/services/io.seata.config.ExtConfigurationProvider new file mode 100644 index 00000000000..8ee3b2b4f45 --- /dev/null +++ b/seata-spring-boot-starter/src/main/resources/META-INF/services/io.seata.config.ExtConfigurationProvider @@ -0,0 +1 @@ +io.seata.spring.boot.autoconfigure.provider.SpringBootConfigurationProvider \ No newline at end of file diff --git a/seata-spring-boot-starter/src/main/resources/META-INF/spring.factories b/seata-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..f38b1880a78 --- /dev/null +++ b/seata-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +# Auto Configure +org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.seata.spring.boot.autoconfigure.SeataAutoConfiguration diff --git a/spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java b/spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java index 293e2c84e24..3dd5e1f5e79 100644 --- a/spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java +++ b/spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java @@ -317,6 +317,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro if (null != m) { return m.invoke(dataSourceProxy, args); } else { + method.setAccessible(true); return method.invoke(bean, args); } }); From de28a7dfd6282401164f212308a1e67c607dab5f Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 10:52:18 +0800 Subject: [PATCH 02/18] remove unused imports. --- .../boot/autoconfigure/properties/file/SpringProperties.java | 1 - .../boot/autoconfigure/properties/file/SupportProperties.java | 1 - .../boot/autoconfigure/properties/registry/ConfigProperties.java | 1 - .../properties/registry/RegistryFileProperties.java | 1 - .../autoconfigure/properties/registry/RegistryProperties.java | 1 - .../properties/registry/RegistryRedisProperties.java | 1 - .../properties/registry/RegistrySofaProperties.java | 1 - 7 files changed, 7 deletions(-) diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java index 615e4a9e1f5..763a9ce277a 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java @@ -15,7 +15,6 @@ */ package io.seata.spring.boot.autoconfigure.properties.file; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java index fe8b32a569d..8bb15785258 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java @@ -15,7 +15,6 @@ */ package io.seata.spring.boot.autoconfigure.properties.file; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java index 12869951a08..2ef731fa831 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java @@ -16,7 +16,6 @@ package io.seata.spring.boot.autoconfigure.properties.registry; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Component; import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_PREFIX; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java index c99845396aa..f2860336efb 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryFileProperties.java @@ -19,7 +19,6 @@ import org.springframework.stereotype.Component; import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_FILE_PREFIX; -import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_SOFA_PREFIX; /** * @author xingfudeshi@gmail.com diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java index 81c225d4145..2891be9eb25 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryProperties.java @@ -16,7 +16,6 @@ package io.seata.spring.boot.autoconfigure.properties.registry; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Component; import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_PREFIX; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java index ee859fcba28..5cc6dc778e7 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisProperties.java @@ -18,7 +18,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; -import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_EUREKA_PREFIX; import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_REDIS_PREFIX; /** diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java index 380f9b10cd7..b0d6cf16f9d 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaProperties.java @@ -18,7 +18,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; -import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_ETCD3_PREFIX; import static io.seata.spring.boot.autoconfigure.StarterConstants.REGISTRY_SOFA_PREFIX; /** From 7f38d259412a74e3220b1f7638a26b7969eca7c5 Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 11:20:57 +0800 Subject: [PATCH 03/18] add missing properties. --- .../boot/autoconfigure/StarterConstants.java | 32 +++++++++++++- .../registry/ConfigConsulProperties.java | 41 ++++++++++++++++++ .../registry/ConfigEtcd3Properties.java | 42 +++++++++++++++++++ .../registry/ConfigNacosProperties.java | 12 +----- .../registry/RegistryEurekaProperties.java | 2 +- .../registry/RegistryNacosProperties.java | 2 +- 6 files changed, 116 insertions(+), 15 deletions(-) create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigConsulProperties.java create mode 100644 seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigEtcd3Properties.java diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java index ef10cd46e38..08bc8ab08a5 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java @@ -15,6 +15,8 @@ */ package io.seata.spring.boot.autoconfigure; +import java.util.HashMap; + import io.seata.spring.boot.autoconfigure.properties.file.ClientProperties; import io.seata.spring.boot.autoconfigure.properties.file.LockProperties; import io.seata.spring.boot.autoconfigure.properties.file.ServiceProperties; @@ -24,12 +26,22 @@ import io.seata.spring.boot.autoconfigure.properties.file.ThreadFactoryProperties; import io.seata.spring.boot.autoconfigure.properties.file.TransactionProperties; import io.seata.spring.boot.autoconfigure.properties.file.TransportProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigApolloProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigConsulProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigEtcd3Properties; import io.seata.spring.boot.autoconfigure.properties.registry.ConfigFileProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigNacosProperties; import io.seata.spring.boot.autoconfigure.properties.registry.ConfigProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.ConfigZooKeeperProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryConsulProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryEecd3Properties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryEurekaProperties; import io.seata.spring.boot.autoconfigure.properties.registry.RegistryFileProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryNacosProperties; import io.seata.spring.boot.autoconfigure.properties.registry.RegistryProperties; - -import java.util.HashMap; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryRedisProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistrySofaProperties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryZooKeeperProperties; /** * @author xingfudeshi@gmail.com @@ -59,6 +71,8 @@ public class StarterConstants { public static final String CONFIG_PREFIX = SEATA_PREFIX + ".config"; public static final String CONFIG_NACOS_PREFIX = CONFIG_PREFIX + ".nacos"; + public static final String CONFIG_CONSUL_PREFIX = CONFIG_PREFIX + ".consul"; + public static final String CONFIG_ETCD3_PREFIX = CONFIG_PREFIX + ".etcd3"; public static final String CONFIG_APOLLO_PREFIX = CONFIG_PREFIX + ".apollo"; public static final String CONFIG_ZK_PREFIX = CONFIG_PREFIX + ".zk"; public static final String CONFIG_FILE_PREFIX = CONFIG_PREFIX + ".file"; @@ -80,6 +94,20 @@ public class StarterConstants { put(CONFIG_FILE_PREFIX, ConfigFileProperties.class); put(REGISTRY_PREFIX, RegistryProperties.class); put(REGISTRY_FILE_PREFIX, RegistryFileProperties.class); + + put(CONFIG_NACOS_PREFIX, ConfigNacosProperties.class); + put(CONFIG_CONSUL_PREFIX, ConfigConsulProperties.class); + put(CONFIG_ZK_PREFIX, ConfigZooKeeperProperties.class); + put(CONFIG_APOLLO_PREFIX, ConfigApolloProperties.class); + put(CONFIG_ETCD3_PREFIX, ConfigEtcd3Properties.class); + + put(REGISTRY_CONSUL_PREFIX, RegistryConsulProperties.class); + put(REGISTRY_ETCD3_PREFIX, RegistryEecd3Properties.class); + put(REGISTRY_EUREKA_PREFIX, RegistryEurekaProperties.class); + put(REGISTRY_NACOS_PREFIX, RegistryNacosProperties.class); + put(REGISTRY_REDIS_PREFIX, RegistryRedisProperties.class); + put(REGISTRY_SOFA_PREFIX, RegistrySofaProperties.class); + put(REGISTRY_ZK_PREFIX, RegistryZooKeeperProperties.class); } }; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigConsulProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigConsulProperties.java new file mode 100644 index 00000000000..065e10dafa6 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigConsulProperties.java @@ -0,0 +1,41 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_CONSUL_PREFIX; + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/11 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_CONSUL_PREFIX) +public class ConfigConsulProperties { + private String serverAddr = "127.0.0.1:8500"; + + public String getServerAddr() { + return serverAddr; + } + + public ConfigConsulProperties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigEtcd3Properties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigEtcd3Properties.java new file mode 100644 index 00000000000..f3652186a40 --- /dev/null +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigEtcd3Properties.java @@ -0,0 +1,42 @@ +/* + * 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.spring.boot.autoconfigure.properties.registry; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import static io.seata.spring.boot.autoconfigure.StarterConstants.CONFIG_ETCD3_PREFIX; + + +/** + * @author xingfudeshi@gmail.com + * @date 2019/10/11 + */ +@Component +@ConfigurationProperties(prefix = CONFIG_ETCD3_PREFIX) +public class ConfigEtcd3Properties { + private String serverAddr = "http://localhost:2379"; + + public String getServerAddr() { + return serverAddr; + } + + public ConfigEtcd3Properties setServerAddr(String serverAddr) { + this.serverAddr = serverAddr; + return this; + } + +} diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java index bdfb21cdfaf..fae63f5fc61 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigNacosProperties.java @@ -28,8 +28,7 @@ @ConfigurationProperties(prefix = CONFIG_NACOS_PREFIX) public class ConfigNacosProperties { private String serverAddr = "localhost"; - private String namespace = "public"; - private String cluster = "default"; + private String namespace = ""; public String getServerAddr() { return serverAddr; @@ -48,13 +47,4 @@ public ConfigNacosProperties setNamespace(String namespace) { this.namespace = namespace; return this; } - - public String getCluster() { - return cluster; - } - - public ConfigNacosProperties setCluster(String cluster) { - this.cluster = cluster; - return this; - } } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java index 6c5e667e638..faa34b300a7 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaProperties.java @@ -27,7 +27,7 @@ @Component @ConfigurationProperties(prefix = REGISTRY_EUREKA_PREFIX) public class RegistryEurekaProperties { - private String serviceUrl = "http://localhost:1001/eureka"; + private String serviceUrl = "http://localhost:8761/eureka"; private String application = "default"; private String weight = "1"; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java index d7cf5df8d8d..6a2fc77456a 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosProperties.java @@ -28,7 +28,7 @@ @ConfigurationProperties(prefix = REGISTRY_NACOS_PREFIX) public class RegistryNacosProperties { private String serverAddr = "localhost"; - private String namespace = "public"; + private String namespace = ""; private String cluster = "default"; public String getServerAddr() { From 58e57e7b2b879e2923e6d552b0a481c8800d964c Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 11:34:19 +0800 Subject: [PATCH 04/18] config missing properties for config®istry --- all/pom.xml | 1 + .../boot/autoconfigure/StarterConstants.java | 8 +++++ .../SpringBootConfigurationProvider.java | 36 +++++++++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 4e24aca17ff..c15b3cfedba 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -237,6 +237,7 @@ seata-codec-kryo ${project.version} + org.springframework diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java index 08bc8ab08a5..547825dfa93 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java @@ -130,4 +130,12 @@ public class StarterConstants { public static String NORMALIZED_KEY_CLIENT_LOCK = "client.lock."; public static String SPECIAL_KEY_TRANSPORT_THREAD_FACTORY = "transport.thread-factory."; public static String NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY = "transport.thread-factory."; + + public static String SPECIAL_KEY_REGISTRY_ZK="registry.zk."; + public static String NORMALIZED_KEY_REGISTRY_ZK="registry.zk."; + public static String SPECIAL_KEY_CONFIG_ZK="config.zk."; + public static String NORMALIZED_KEY_CONFIG_ZK="config.zk."; + public static String SPECIAL_KEY_CONFIG_APOLLO="config.apollo."; + public static String NORMALIZED_KEY_CONFIG_APOLLO="config.apollo."; + } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java index ab4908299ed..ddc838e571c 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java @@ -33,16 +33,22 @@ import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CLIENT; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CLIENT_LOCK; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CONFIG_APOLLO; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CONFIG_ZK; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_DATASOURCE_AUTOPROXY; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_GROUPLIST; +import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_REGISTRY_ZK; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_TRANSACTION; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_VGROUP_MAPPING; import static io.seata.spring.boot.autoconfigure.StarterConstants.PROPERTY_MAP; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_CLIENT; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_CLIENT_LOCK; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_CONFIG_APOLLO; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_CONFIG_ZK; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_DATASOURCE_AUTOPROXY; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_GROUPLIST; +import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_REGISTRY_ZK; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_TRANSACTION; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_TRANSPORT_THREAD_FACTORY; import static io.seata.spring.boot.autoconfigure.StarterConstants.SPECIAL_KEY_VGROUP_MAPPING; @@ -119,7 +125,6 @@ private String convertDataId(String rawDataId) { if (rawDataId.startsWith(SPECIAL_KEY_VGROUP_MAPPING)) { return StarterConstants.SERVICE_PREFIX + "." + NORMALIZED_KEY_VGROUP_MAPPING; } - if (rawDataId.endsWith(SPECIAL_KEY_GROUPLIST)) { return StarterConstants.SERVICE_PREFIX + "." + NORMALIZED_KEY_GROUPLIST; } @@ -142,22 +147,47 @@ private String convertDataId(String rawDataId) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY); return StarterConstants.THREAD_FACTORY_PREFIX + "." + StringFormatUtils.minusToCamel(suffix); } + if(rawDataId.startsWith(SPECIAL_KEY_REGISTRY_ZK)){ + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_REGISTRY_ZK); + return StarterConstants.REGISTRY_ZK_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + } + if(rawDataId.startsWith(SPECIAL_KEY_CONFIG_ZK)){ + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CONFIG_ZK); + return StarterConstants.CONFIG_ZK_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + } + if(rawDataId.startsWith(SPECIAL_KEY_CONFIG_APOLLO)){ + String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CONFIG_APOLLO); + return StarterConstants.CONFIG_APOLLO_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + } return StarterConstants.SEATA_PREFIX + "." + rawDataId; } + /** + * Get property prefix + * @param dataId + * @return propertyPrefix + */ private String getPropertyPrefix(String dataId) { return StringFormatUtils.underlineToCamel(StringFormatUtils.minusToCamel(StringUtils.substringBeforeLast(dataId, "."))); } + /** + * Get property suffix + * @param dataId + * @return propertySuffix + */ private String getPropertySuffix(String dataId) { return StringUtils.substringAfterLast(dataId, "."); } + /** + * Get property class + * @param propertyPrefix + * @return propertyClass + */ private Class getPropertyClass(String propertyPrefix) { Optional> entry = PROPERTY_MAP.entrySet().stream().filter(e -> propertyPrefix.equals(e.getKey())).findAny(); return entry.map(Map.Entry::getValue).orElse(null); } - - } From a0c7cb209fcaaabeafee13cf38d488c4faaadf21 Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 11:36:38 +0800 Subject: [PATCH 05/18] unify the default port for eureka. --- codec/seata-codec-seata/src/test/resources/registry.conf | 2 +- config/seata-config-core/src/main/resources/registry.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codec/seata-codec-seata/src/test/resources/registry.conf b/codec/seata-codec-seata/src/test/resources/registry.conf index e14f0d88e9d..7070aa6133a 100644 --- a/codec/seata-codec-seata/src/test/resources/registry.conf +++ b/codec/seata-codec-seata/src/test/resources/registry.conf @@ -8,7 +8,7 @@ registry { cluster = "default" } eureka { - serviceUrl = "http://localhost:1001/eureka" + serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } diff --git a/config/seata-config-core/src/main/resources/registry.conf b/config/seata-config-core/src/main/resources/registry.conf index 2f2f2adb301..a0c917f8c8d 100644 --- a/config/seata-config-core/src/main/resources/registry.conf +++ b/config/seata-config-core/src/main/resources/registry.conf @@ -8,7 +8,7 @@ registry { cluster = "default" } eureka { - serviceUrl = "http://localhost:1001/eureka" + serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } From e740cbd303b496a110b560778c2b3d579a7af7ec Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 11:38:40 +0800 Subject: [PATCH 06/18] code format. --- .../boot/autoconfigure/StarterConstants.java | 12 +++++------ .../SpringBootConfigurationProvider.java | 21 +++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java index 547825dfa93..ce070ede5ae 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java @@ -131,11 +131,11 @@ public class StarterConstants { public static String SPECIAL_KEY_TRANSPORT_THREAD_FACTORY = "transport.thread-factory."; public static String NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY = "transport.thread-factory."; - public static String SPECIAL_KEY_REGISTRY_ZK="registry.zk."; - public static String NORMALIZED_KEY_REGISTRY_ZK="registry.zk."; - public static String SPECIAL_KEY_CONFIG_ZK="config.zk."; - public static String NORMALIZED_KEY_CONFIG_ZK="config.zk."; - public static String SPECIAL_KEY_CONFIG_APOLLO="config.apollo."; - public static String NORMALIZED_KEY_CONFIG_APOLLO="config.apollo."; + public static String SPECIAL_KEY_REGISTRY_ZK = "registry.zk."; + public static String NORMALIZED_KEY_REGISTRY_ZK = "registry.zk."; + public static String SPECIAL_KEY_CONFIG_ZK = "config.zk."; + public static String NORMALIZED_KEY_CONFIG_ZK = "config.zk."; + public static String SPECIAL_KEY_CONFIG_APOLLO = "config.apollo."; + public static String NORMALIZED_KEY_CONFIG_APOLLO = "config.apollo."; } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java index ddc838e571c..c512625b2d0 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java @@ -15,6 +15,12 @@ */ package io.seata.spring.boot.autoconfigure.provider; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; + import io.seata.config.Configuration; import io.seata.config.ExtConfigurationProvider; import io.seata.spring.boot.autoconfigure.StarterConstants; @@ -25,12 +31,6 @@ import org.springframework.cglib.proxy.MethodInterceptor; import org.springframework.cglib.proxy.MethodProxy; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Stream; - import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CLIENT; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CLIENT_LOCK; import static io.seata.spring.boot.autoconfigure.StarterConstants.NORMALIZED_KEY_CONFIG_APOLLO; @@ -147,15 +147,15 @@ private String convertDataId(String rawDataId) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_TRANSPORT_THREAD_FACTORY); return StarterConstants.THREAD_FACTORY_PREFIX + "." + StringFormatUtils.minusToCamel(suffix); } - if(rawDataId.startsWith(SPECIAL_KEY_REGISTRY_ZK)){ + if (rawDataId.startsWith(SPECIAL_KEY_REGISTRY_ZK)) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_REGISTRY_ZK); return StarterConstants.REGISTRY_ZK_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); } - if(rawDataId.startsWith(SPECIAL_KEY_CONFIG_ZK)){ + if (rawDataId.startsWith(SPECIAL_KEY_CONFIG_ZK)) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CONFIG_ZK); return StarterConstants.CONFIG_ZK_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); } - if(rawDataId.startsWith(SPECIAL_KEY_CONFIG_APOLLO)){ + if (rawDataId.startsWith(SPECIAL_KEY_CONFIG_APOLLO)) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CONFIG_APOLLO); return StarterConstants.CONFIG_APOLLO_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); } @@ -165,6 +165,7 @@ private String convertDataId(String rawDataId) { /** * Get property prefix + * * @param dataId * @return propertyPrefix */ @@ -174,6 +175,7 @@ private String getPropertyPrefix(String dataId) { /** * Get property suffix + * * @param dataId * @return propertySuffix */ @@ -183,6 +185,7 @@ private String getPropertySuffix(String dataId) { /** * Get property class + * * @param propertyPrefix * @return propertyClass */ From 6ed3448099a5986d951ce894becab447c49eef9e Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 12:43:05 +0800 Subject: [PATCH 07/18] extends from parent. --- bom/pom.xml | 8 +++++++ seata-spring-boot-starter/pom.xml | 38 ++++--------------------------- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index 14afda12444..4e1144172a5 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -106,6 +106,7 @@ 1.0.0 2.9.8 1.72 + 2.1.8.RELEASE 1.8 @@ -427,6 +428,13 @@ h2 ${h2.version} + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml index 616a549b97b..4ffa1a53cf1 100644 --- a/seata-spring-boot-starter/pom.xml +++ b/seata-spring-boot-starter/pom.xml @@ -17,44 +17,16 @@ + + io.seata + seata-parent + ${revision} + 4.0.0 - - io.seata seata-spring-boot-starter - 0.9.0-SNAPSHOT - jar seata-spring-boot-starter ${project.version} - - - 1.8 - 1.8 - UTF-8 - - 2.1.8.RELEASE - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - io.seata - seata-bom - ${project.version} - pom - import - - - - From 0a291e2c44666929bd9552b48fd81ea9dbc6f79c Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 13:07:35 +0800 Subject: [PATCH 08/18] set the capacity for HashMap --- .../io/seata/spring/boot/autoconfigure/StarterConstants.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java index ce070ede5ae..f3220244c51 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java @@ -48,6 +48,7 @@ * @date 2019/09/30 */ public class StarterConstants { + private static final int MAP_CAPACITY = 64; public static final String SEATA_PREFIX = "seata"; public static final String TRANSPORT_PREFIX = SEATA_PREFIX + ".transport"; public static final String THREAD_FACTORY_PREFIX = TRANSPORT_PREFIX + ".thread-factory"; @@ -77,7 +78,7 @@ public class StarterConstants { public static final String CONFIG_ZK_PREFIX = CONFIG_PREFIX + ".zk"; public static final String CONFIG_FILE_PREFIX = CONFIG_PREFIX + ".file"; - public static final HashMap PROPERTY_MAP = new HashMap() { + public static final HashMap PROPERTY_MAP = new HashMap(MAP_CAPACITY) { private static final long serialVersionUID = -8902807645596274597L; { From ff693bdb1251de1c5ca058cac5acac34d54cbe2a Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 13:19:58 +0800 Subject: [PATCH 09/18] fix coverage --- bom/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bom/pom.xml b/bom/pom.xml index 4e1144172a5..c724498b5dd 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -124,8 +124,10 @@ org.springframework spring-framework-bom ${spring.version} + From 7327b911e0e35d2b17b945b8262bc1e6aafd2512 Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 13:26:47 +0800 Subject: [PATCH 10/18] Revert "extends from parent." This reverts commit 6ed34480 --- bom/pom.xml | 8 ------- seata-spring-boot-starter/pom.xml | 38 +++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index c724498b5dd..e453d41e32f 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -106,7 +106,6 @@ 1.0.0 2.9.8 1.72 - 2.1.8.RELEASE 1.8 @@ -430,13 +429,6 @@ h2 ${h2.version} - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml index 4ffa1a53cf1..616a549b97b 100644 --- a/seata-spring-boot-starter/pom.xml +++ b/seata-spring-boot-starter/pom.xml @@ -17,16 +17,44 @@ - - io.seata - seata-parent - ${revision} - 4.0.0 + + io.seata seata-spring-boot-starter + 0.9.0-SNAPSHOT + jar seata-spring-boot-starter ${project.version} + + + 1.8 + 1.8 + UTF-8 + + 2.1.8.RELEASE + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + io.seata + seata-bom + ${project.version} + pom + import + + + + From 7737ec4bc8bc131bf97faa3039ca4f797cb3724c Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 13:34:11 +0800 Subject: [PATCH 11/18] fix coverage --- bom/pom.xml | 2 -- seata-spring-boot-starter/pom.xml | 15 +++++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index e453d41e32f..14afda12444 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -123,10 +123,8 @@ org.springframework spring-framework-bom ${spring.version} - diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml index 616a549b97b..dd3d9dea681 100644 --- a/seata-spring-boot-starter/pom.xml +++ b/seata-spring-boot-starter/pom.xml @@ -17,25 +17,20 @@ + + io.seata + seata-parent + ${revision} + 4.0.0 - - io.seata seata-spring-boot-starter - 0.9.0-SNAPSHOT - jar seata-spring-boot-starter ${project.version} - - 1.8 - 1.8 - UTF-8 - 2.1.8.RELEASE - From f6bb84365fcaa3db6658d7ffec3298214a0a7014 Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 13:41:27 +0800 Subject: [PATCH 12/18] fix coverage --- seata-spring-boot-starter/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml index dd3d9dea681..3f992973ff0 100644 --- a/seata-spring-boot-starter/pom.xml +++ b/seata-spring-boot-starter/pom.xml @@ -40,13 +40,6 @@ pom import - - io.seata - seata-bom - ${project.version} - pom - import - From 1d3f18747fa37f36d8fba3f89816a76cb42dbf32 Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 15:21:18 +0800 Subject: [PATCH 13/18] use seata-all --- seata-spring-boot-starter/pom.xml | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml index 3f992973ff0..bad3c17c616 100644 --- a/seata-spring-boot-starter/pom.xml +++ b/seata-spring-boot-starter/pom.xml @@ -47,32 +47,7 @@ ${project.groupId} - seata-tm - ${project.version} - - - ${project.groupId} - seata-rm-datasource - ${project.version} - - - ${project.groupId} - seata-tcc - ${project.version} - - - ${project.groupId} - seata-rm - ${project.version} - - - ${project.groupId} - seata-codec-all - ${project.version} - - - ${project.groupId} - seata-spring + seata-all ${project.version} From 2c22e2adc1592dff9376fb0239bbd94a3bfd2ca1 Mon Sep 17 00:00:00 2001 From: wu Date: Fri, 11 Oct 2019 15:58:38 +0800 Subject: [PATCH 14/18] degrades the version of spring-boot 1.5.22.RELEASE --- seata-spring-boot-starter/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seata-spring-boot-starter/pom.xml b/seata-spring-boot-starter/pom.xml index bad3c17c616..d55a10ffb8f 100644 --- a/seata-spring-boot-starter/pom.xml +++ b/seata-spring-boot-starter/pom.xml @@ -28,7 +28,7 @@ seata-spring-boot-starter ${project.version} - 2.1.8.RELEASE + 1.5.22.RELEASE From 8fc0f0c0539fb469f3b38223b2a6f626ea94d51b Mon Sep 17 00:00:00 2001 From: wu Date: Sat, 12 Oct 2019 10:58:53 +0800 Subject: [PATCH 15/18] fix reviews. --- .../properties/file/TransactionProperties.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java index 6c6906da285..2b83181fd0a 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/TransactionProperties.java @@ -18,6 +18,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import static io.seata.core.constants.ConfigurationKeys.TRANSACTION_UNDO_LOG_DEFAULT_TABLE; +import static io.seata.core.protocol.transaction.UndoLogDeleteRequest.DEFAULT_SAVE_DAYS; import static io.seata.spring.boot.autoconfigure.StarterConstants.TRANSACTION_PREFIX; /** @@ -29,12 +31,12 @@ public class TransactionProperties { private boolean undoDataValidation = true; private String undoLogSerialization = "jackson"; - private int undoLogSaveDays = 7; + private int undoLogSaveDays = DEFAULT_SAVE_DAYS; /** * schedule delete expired undo_log in milliseconds */ private long undoLogDeletePeriod = 86400000L; - private String undoLogTable = "undo_log"; + private String undoLogTable = TRANSACTION_UNDO_LOG_DEFAULT_TABLE; public boolean isUndoDataValidation() { return undoDataValidation; From f030d19731b723acf48477760e47304bbd54af87 Mon Sep 17 00:00:00 2001 From: wu Date: Tue, 22 Oct 2019 11:34:49 +0800 Subject: [PATCH 16/18] fix reviews and add missing configurations. --- .../src/test/resources/file.conf | 7 +++-- .../io/seata/config/ConfigurationFactory.java | 6 ++-- .../src/main/resources/file.conf | 5 ++-- .../boot/autoconfigure/StarterConstants.java | 4 +-- .../properties/file/ClientProperties.java | 28 +++++++++++++++++++ .../properties/file/LockProperties.java | 10 +++++++ .../properties/file/ServiceProperties.java | 13 ++++----- .../properties/registry/ConfigProperties.java | 2 +- ...ties.java => RegistryEtcd3Properties.java} | 6 ++-- .../SpringBootConfigurationProvider.java | 2 +- server/src/main/resources/file.conf | 4 +-- test/src/test/resources/file.conf | 7 +++-- 12 files changed, 69 insertions(+), 25 deletions(-) rename seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/{RegistryEecd3Properties.java => RegistryEtcd3Properties.java} (89%) diff --git a/codec/seata-codec-seata/src/test/resources/file.conf b/codec/seata-codec-seata/src/test/resources/file.conf index 2a62dd98f98..e92a43ff133 100644 --- a/codec/seata-codec-seata/src/test/resources/file.conf +++ b/codec/seata-codec-seata/src/test/resources/file.conf @@ -33,8 +33,8 @@ service { default.grouplist = "127.0.0.1:8091" #degrade current not support enableDegrade = false - #disable - disable = false + #disable globaltransaction + disableGlobalTransaction = false } client { @@ -42,10 +42,13 @@ client { lock { retry.internal = 10 retry.times = 30 + retry.policy.branch-rollback-on-conflict = true } report.retry.count = 5 tm.commit.retry.count = 1 tm.rollback.retry.count = 1 + #schedule check table meta + table.meta.check.enable = true } transaction { 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 852ab633edc..54afae9e32c 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 @@ -100,10 +100,10 @@ private static Configuration buildConfiguration() { + NAME_KEY; String name = CURRENT_FILE_INSTANCE.getConfig(pathDataId); Configuration configuration = new FileConfiguration(name); - Configuration extConfiguration=null; + Configuration extConfiguration = null; try { - extConfiguration=EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - }catch (Exception ignore){ + extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); + } catch (Exception ignore) { } diff --git a/config/seata-config-core/src/main/resources/file.conf b/config/seata-config-core/src/main/resources/file.conf index beeea0272d6..e92a43ff133 100644 --- a/config/seata-config-core/src/main/resources/file.conf +++ b/config/seata-config-core/src/main/resources/file.conf @@ -33,8 +33,8 @@ service { default.grouplist = "127.0.0.1:8091" #degrade current not support enableDegrade = false - #disable - disable = false + #disable globaltransaction + disableGlobalTransaction = false } client { @@ -42,6 +42,7 @@ client { lock { retry.internal = 10 retry.times = 30 + retry.policy.branch-rollback-on-conflict = true } report.retry.count = 5 tm.commit.retry.count = 1 diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java index f3220244c51..91490e2a0b8 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java @@ -34,7 +34,7 @@ import io.seata.spring.boot.autoconfigure.properties.registry.ConfigProperties; import io.seata.spring.boot.autoconfigure.properties.registry.ConfigZooKeeperProperties; import io.seata.spring.boot.autoconfigure.properties.registry.RegistryConsulProperties; -import io.seata.spring.boot.autoconfigure.properties.registry.RegistryEecd3Properties; +import io.seata.spring.boot.autoconfigure.properties.registry.RegistryEtcd3Properties; import io.seata.spring.boot.autoconfigure.properties.registry.RegistryEurekaProperties; import io.seata.spring.boot.autoconfigure.properties.registry.RegistryFileProperties; import io.seata.spring.boot.autoconfigure.properties.registry.RegistryNacosProperties; @@ -103,7 +103,7 @@ public class StarterConstants { put(CONFIG_ETCD3_PREFIX, ConfigEtcd3Properties.class); put(REGISTRY_CONSUL_PREFIX, RegistryConsulProperties.class); - put(REGISTRY_ETCD3_PREFIX, RegistryEecd3Properties.class); + put(REGISTRY_ETCD3_PREFIX, RegistryEtcd3Properties.class); put(REGISTRY_EUREKA_PREFIX, RegistryEurekaProperties.class); put(REGISTRY_NACOS_PREFIX, RegistryNacosProperties.class); put(REGISTRY_REDIS_PREFIX, RegistryRedisProperties.class); diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java index e25ea51a3a5..d8b588b52af 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ClientProperties.java @@ -29,6 +29,9 @@ public class ClientProperties { private int asyncCommitBufferLimit = 10000; private int reportRetryCount = 5; + private int tmCommitRetryCount = 5; + private int tmRollbackRetryCount = 1; + private boolean tableMetaCheckEnable = true; public int getAsyncCommitBufferLimit() { return asyncCommitBufferLimit; @@ -48,5 +51,30 @@ public ClientProperties setReportRetryCount(int reportRetryCount) { return this; } + public int getTmCommitRetryCount() { + return tmCommitRetryCount; + } + + public ClientProperties setTmCommitRetryCount(int tmCommitRetryCount) { + this.tmCommitRetryCount = tmCommitRetryCount; + return this; + } + public int getTmRollbackRetryCount() { + return tmRollbackRetryCount; + } + + public ClientProperties setTmRollbackRetryCount(int tmRollbackRetryCount) { + this.tmRollbackRetryCount = tmRollbackRetryCount; + return this; + } + + public boolean isTableMetaCheckEnable() { + return tableMetaCheckEnable; + } + + public ClientProperties setTableMetaCheckEnable(boolean tableMetaCheckEnable) { + this.tableMetaCheckEnable = tableMetaCheckEnable; + return this; + } } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java index 91d203dc159..a2b4d3f2a60 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LockProperties.java @@ -29,6 +29,7 @@ public class LockProperties { private int lockRetryInterval = 10; private int lockRetryTimes = 30; + private boolean lockRetryPolicyBranchRollbackOnConflict = true; public int getLockRetryInterval() { return lockRetryInterval; @@ -47,4 +48,13 @@ public LockProperties setLockRetryTimes(int lockRetryTimes) { this.lockRetryTimes = lockRetryTimes; return this; } + + public boolean isLockRetryPolicyBranchRollbackOnConflict() { + return lockRetryPolicyBranchRollbackOnConflict; + } + + public LockProperties setLockRetryPolicyBranchRollbackOnConflict(boolean lockRetryPolicyBranchRollbackOnConflict) { + this.lockRetryPolicyBranchRollbackOnConflict = lockRetryPolicyBranchRollbackOnConflict; + return this; + } } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java index dc9cd8338d8..039173705ef 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/ServiceProperties.java @@ -40,9 +40,9 @@ public class ServiceProperties { */ private boolean enableDegrade = false; /** - * disable + * disable globalTransaction */ - private boolean disable = false; + private boolean disableGlobalTransaction = false; public String getVgroupMapping() { return vgroupMapping; @@ -71,13 +71,12 @@ public ServiceProperties setEnableDegrade(boolean enableDegrade) { return this; } - public boolean isDisable() { - return disable; + public boolean isDisableGlobalTransaction() { + return disableGlobalTransaction; } - public ServiceProperties setDisable(boolean disable) { - this.disable = disable; + public ServiceProperties setDisableGlobalTransaction(boolean disableGlobalTransaction) { + this.disableGlobalTransaction = disableGlobalTransaction; return this; } - } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java index 2ef731fa831..7454ad85a16 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/ConfigProperties.java @@ -28,7 +28,7 @@ @ConfigurationProperties(prefix = CONFIG_PREFIX) public class ConfigProperties { /** - * file、nacos 、apollo、zk + * file、nacos、apollo、zk、consul、etcd3 */ private String type = "file"; diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3Properties.java similarity index 89% rename from seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java rename to seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3Properties.java index cc028e4b0f2..7293614cfaf 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEecd3Properties.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3Properties.java @@ -26,7 +26,7 @@ */ @Component @ConfigurationProperties(prefix = REGISTRY_ETCD3_PREFIX) -public class RegistryEecd3Properties { +public class RegistryEtcd3Properties { private String cluster = "default"; private String serverAddr = "http://localhost:2379"; @@ -34,7 +34,7 @@ public String getCluster() { return cluster; } - public RegistryEecd3Properties setCluster(String cluster) { + public RegistryEtcd3Properties setCluster(String cluster) { this.cluster = cluster; return this; } @@ -43,7 +43,7 @@ public String getServerAddr() { return serverAddr; } - public RegistryEecd3Properties setServerAddr(String serverAddr) { + public RegistryEtcd3Properties setServerAddr(String serverAddr) { this.serverAddr = serverAddr; return this; } diff --git a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java index c512625b2d0..5b973e9b762 100644 --- a/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java +++ b/seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringBootConfigurationProvider.java @@ -137,7 +137,7 @@ private String convertDataId(String rawDataId) { } if (rawDataId.startsWith(SPECIAL_KEY_CLIENT_LOCK)) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CLIENT_LOCK); - return StarterConstants.LOCK_PREFIX + "." + StringFormatUtils.dotToCamel(suffix); + return StarterConstants.LOCK_PREFIX + "." + StringFormatUtils.minusToCamel(StringFormatUtils.dotToCamel(suffix)); } if (rawDataId.startsWith(SPECIAL_KEY_CLIENT)) { String suffix = StringUtils.removeStart(rawDataId, NORMALIZED_KEY_CLIENT); diff --git a/server/src/main/resources/file.conf b/server/src/main/resources/file.conf index 9967e90aad6..6baf229ca95 100644 --- a/server/src/main/resources/file.conf +++ b/server/src/main/resources/file.conf @@ -33,8 +33,8 @@ service { default.grouplist = "127.0.0.1:8091" #degrade current not support enableDegrade = false - #disable - disable = false + #disable globaltransaction + disableGlobalTransaction = false #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent max.commit.retry.timeout = "-1" max.rollback.retry.timeout = "-1" diff --git a/test/src/test/resources/file.conf b/test/src/test/resources/file.conf index 4fe50f1a002..b6e9da2dc21 100644 --- a/test/src/test/resources/file.conf +++ b/test/src/test/resources/file.conf @@ -33,8 +33,8 @@ service { default.grouplist = "127.0.0.1:8091" #degrade current not support enableDegrade = false - #disable - disable = false + #disable globaltransaction + disableGlobalTransaction = false } client { @@ -42,10 +42,13 @@ client { lock { retry.internal = 10 retry.times = 30 + retry.policy.branch-rollback-on-conflict = true } report.retry.count = 5 tm.commit.retry.count = 1 tm.rollback.retry.count = 1 + #schedule check table meta + table.meta.check.enable = true } transaction { undo.data.validation = true From efe00eaa29202d6b1804c281cc6c8cccf2769b2f Mon Sep 17 00:00:00 2001 From: wu Date: Thu, 24 Oct 2019 15:34:11 +0800 Subject: [PATCH 17/18] update codecov.yml --- codecov.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/codecov.yml b/codecov.yml index 6af58aab0f7..6a4e2cc7f58 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,20 +2,21 @@ codecov: require_ci_to_pass: yes coverage: status: - patch: + patch: no + project: default: threshold: 1% - project: yes + if_not_found: success changes: no precision: 2 range: "50...100" ignore: -- "codec/seata-codec-protobuf/src/main/java/io/seata/codec/protobuf/generated" -- "test/.*" -- ".github/.*" -- ".mvn/.*" -- ".style/.*" -- "*.md" + - "codec/seata-codec-protobuf/src/main/java/io/seata/codec/protobuf/generated" + - "test/.*" + - ".github/.*" + - ".mvn/.*" + - ".style/.*" + - "*.md" comment: layout: "reach,diff,flags,tree" behavior: default From f0ba5b1d2f34e5b9d4a3256363bd7b1065183fe8 Mon Sep 17 00:00:00 2001 From: wu Date: Thu, 24 Oct 2019 16:57:21 +0800 Subject: [PATCH 18/18] Revert "update codecov.yml" This reverts commit efe00eaa --- codecov.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/codecov.yml b/codecov.yml index 6a4e2cc7f58..6af58aab0f7 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,21 +2,20 @@ codecov: require_ci_to_pass: yes coverage: status: - patch: no - project: + patch: default: threshold: 1% - if_not_found: success + project: yes changes: no precision: 2 range: "50...100" ignore: - - "codec/seata-codec-protobuf/src/main/java/io/seata/codec/protobuf/generated" - - "test/.*" - - ".github/.*" - - ".mvn/.*" - - ".style/.*" - - "*.md" +- "codec/seata-codec-protobuf/src/main/java/io/seata/codec/protobuf/generated" +- "test/.*" +- ".github/.*" +- ".mvn/.*" +- ".style/.*" +- "*.md" comment: layout: "reach,diff,flags,tree" behavior: default