Skip to content

Commit

Permalink
optimize: optimize read of storage configuration (apache#4936)
Browse files Browse the repository at this point in the history
  • Loading branch information
slievrly committed Sep 28, 2022
1 parent 141d855 commit 5f2acb5
Show file tree
Hide file tree
Showing 30 changed files with 309 additions and 250 deletions.
4 changes: 4 additions & 0 deletions changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#4543](https://github.com/seata/seata/pull/4543)] fix support Oracle nclob types
- [[#4915](https://github.com/seata/seata/pull/4915)] fix failed to get server recovery properties
- [[#4919](https://github.com/seata/seata/pull/4919)] fix XID port and address null:0 before coordinator.init
- [[#4928](https://github.com/seata/seata/pull/4928)] fix rpcContext.getClientRMHolderMap NPE


### optimize:
Expand All @@ -37,6 +38,9 @@ Add changes here for all PR submitted to the develop branch.
- [[#4917](https://github.com/seata/seata/pull/4917)] upgrade package-lock.json fix vulnerabilities
- [[#4924](https://github.com/seata/seata/pull/4924)] optimize pom dependencies
- [[#4932](https://github.com/seata/seata/pull/4932)] extract the default values for some properties
- [[#4925](https://github.com/seata/seata/pull/4925)] optimize java doc warning
- [[#4921](https://github.com/seata/seata/pull/4921)] fix some vulnerabilities in console and upgrade skywalking-eyes
- [[#4936](https://github.com/seata/seata/pull/4936)] optimize read of storage configuration
- [[#4946](https://github.com/seata/seata/pull/4946)] pass the sqlexception to client when get lock
- [[#4962](https://github.com/seata/seata/pull/4962)] optimize build and fix the base image

Expand Down
4 changes: 4 additions & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [[#4543](https://github.com/seata/seata/pull/4543)] 修复对 Oracle 数据类型nclob的支持
- [[#4915](https://github.com/seata/seata/pull/4915)] 修复获取不到ServerRecoveryProperties属性的问题
- [[#4919](https://github.com/seata/seata/pull/4919)] 修复XID的port和address出现null:0的情况
- [[#4928](https://github.com/seata/seata/pull/4928)] 修复 rpcContext.getClientRMHolderMap NPE 问题

### optimize:
- [[#4774](https://github.com/seata/seata/pull/4774)] 优化 seataio/seata-server 镜像中的 mysql8 依赖
Expand All @@ -36,6 +37,9 @@
- [[#4917](https://github.com/seata/seata/pull/4917)] 升级 package-lock.json 修复漏洞
- [[#4924](https://github.com/seata/seata/pull/4924)] 优化 pom 依赖
- [[#4932](https://github.com/seata/seata/pull/4932)] 抽取部分配置的默认值
- [[#4925](https://github.com/seata/seata/pull/4925)] 优化 javadoc 注释
- [[#4921](https://github.com/seata/seata/pull/4921)] 修复控制台模块安全漏洞和升级 skywalking-eyes 版本
- [[#4936](https://github.com/seata/seata/pull/4936)] 优化存储配置的读取
- [[#4946](https://github.com/seata/seata/pull/4946)] 将获取锁时遇到的sql异常传递给客户端
- [[#4962](https://github.com/seata/seata/pull/4962)] 优化构建配置,并修正docker镜像的基础镜像

Expand Down
36 changes: 0 additions & 36 deletions core/src/main/java/io/seata/core/lock/LockMode.java

This file was deleted.

77 changes: 0 additions & 77 deletions core/src/main/java/io/seata/core/store/StoreMode.java

This file was deleted.

14 changes: 12 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<apache-zookeeper.version>3.5.9</apache-zookeeper.version>
<curator-test.version>2.9.1</curator-test.version>
<spring-context-support.version>1.0.2</spring-context-support.version>
<apollo-client.version>1.6.0</apollo-client.version>
<apollo-client.version>2.0.1</apollo-client.version>
<mock-jedis.version>0.1.16</mock-jedis.version>
<eureka-clients.version>1.10.17</eureka-clients.version>
<consul-clients.version>1.4.2</consul-clients.version>
Expand All @@ -63,7 +63,7 @@
<jcommander.version>1.72</jcommander.version>
<xz.version>1.8</xz.version>
<commons-compress.version>1.19</commons-compress.version>
<ant.version>1.10.6</ant.version>
<ant.version>1.10.12</ant.version>
<lz4.version>1.7.1</lz4.version>

<protobuf.version>3.7.1</protobuf.version>
Expand Down Expand Up @@ -295,6 +295,12 @@
<groupId>com.alipay.sofa</groupId>
<artifactId>registry-client-all</artifactId>
<version>${sofa.registry.version}</version>
<exclusions>
<exclusion>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
Expand Down Expand Up @@ -353,6 +359,10 @@
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.andrewoma.dexx</groupId>
<artifactId>dexx-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Import(SpringApplicationContextProvider.class)
class ApolloPropertiesTest extends BasePropertiesTest {

@Bean
@Bean("testConfigApolloProperties")
public ConfigApolloProperties configApolloProperties() {
return new ConfigApolloProperties().setApolloMeta(STR_TEST_AAA).setApolloAccessKeySecret(STR_TEST_BBB).setAppId(
STR_TEST_CCC).setNamespace(STR_TEST_DDD).setCluster(STR_TEST_EEE).setApolloConfigService(STR_TEST_FFF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@org.springframework.context.annotation.Configuration
@Import(SpringApplicationContextProvider.class)
public class ConfigPropertiesTest extends BasePropertiesTest {
@Bean
@Bean("testConfigProperties")
public ConfigProperties configProperties() {
return new ConfigProperties().setType(STR_TEST_AAA).setDataType(STR_TEST_BBB);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@org.springframework.context.annotation.Configuration
@Import(SpringApplicationContextProvider.class)
public class ConsulPropertiesTest extends BasePropertiesTest {
@Bean
@Bean("testConfigConsulProperties")
public ConfigConsulProperties configConsulProperties() {
return new ConfigConsulProperties().setServerAddr(STR_TEST_AAA).setAclToken(STR_TEST_BBB).setKey(STR_TEST_CCC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Import(SpringApplicationContextProvider.class)
public class CustomPropertiesTest extends BasePropertiesTest {

@Bean
@Bean("testConfigCustomProperties")
public ConfigCustomProperties configCustomProperties() {
return new ConfigCustomProperties().setName(STR_TEST_AAA);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@org.springframework.context.annotation.Configuration
@Import(SpringApplicationContextProvider.class)
public class Etcd3PropertiesTest extends BasePropertiesTest {
@Bean
@Bean("testConfigEtcd3Properties")
public ConfigEtcd3Properties configEtcd3Properties() {
return new ConfigEtcd3Properties().setServerAddr(STR_TEST_AAA).setKey(STR_TEST_BBB);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@org.springframework.context.annotation.Configuration
@Import(SpringApplicationContextProvider.class)
public class FilePropertiesTest extends BasePropertiesTest {
@Bean
@Bean("testConfigFileProperties")
public ConfigFileProperties configFileProperties() {
return new ConfigFileProperties().setName(STR_TEST_AAA);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@org.springframework.context.annotation.Configuration
@Import(SpringApplicationContextProvider.class)
public class NacosPropertiesTest extends BasePropertiesTest {
@Bean
@Bean("testConfigNacosProperties")
public ConfigNacosProperties configNacosProperties() {
return new ConfigNacosProperties().setServerAddr(STR_TEST_AAA).setDataId(STR_TEST_BBB).setGroup(STR_TEST_CCC).setNamespace(STR_TEST_DDD).setUsername(STR_TEST_EEE).setPassword(STR_TEST_FFF);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@org.springframework.context.annotation.Configuration
@Import(SpringApplicationContextProvider.class)
public class ZooKeeperPropertiesTest extends BasePropertiesTest {
@Bean
@Bean("testConfigZooKeeperProperties")
public ConfigZooKeeperProperties configZooKeeperProperties() {
return new ConfigZooKeeperProperties().setNodePath(STR_TEST_AAA).setServerAddr(STR_TEST_BBB).setUsername(STR_TEST_CCC).setPassword(STR_TEST_DDD).setConnectTimeout(LONG_TEST_ONE).setSessionTimeout(LONG_TEST_TWO);
}
Expand Down
30 changes: 8 additions & 22 deletions server/src/main/java/io/seata/server/ParameterParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
import io.seata.common.util.StringUtils;
import io.seata.config.Configuration;
import io.seata.config.ConfigurationFactory;
import io.seata.core.constants.ConfigurationKeys;
import io.seata.server.env.ContainerHelper;
import io.seata.server.store.StoreConfig;

import static io.seata.common.DefaultValues.SERVER_DEFAULT_STORE_MODE;
import static io.seata.config.ConfigurationFactory.ENV_PROPERTY_KEY;

/**
Expand Down Expand Up @@ -67,22 +66,18 @@ public ParameterParser(String... args) {
this.init(args);
}

/**
* startup args > docker env
* @param args
*/
private void init(String[] args) {
try {
getCommandParameters(args);
getEnvParameters();
if (StringUtils.isNotBlank(seataEnv)) {
System.setProperty(ENV_PROPERTY_KEY, seataEnv);
}
if (StringUtils.isBlank(storeMode)) {
storeMode = CONFIG.getConfig(ConfigurationKeys.STORE_MODE, SERVER_DEFAULT_STORE_MODE);
}
if (StringUtils.isBlank(sessionStoreMode)) {
sessionStoreMode = CONFIG.getConfig(ConfigurationKeys.STORE_SESSION_MODE, storeMode);
}
if (StringUtils.isBlank(lockStoreMode)) {
lockStoreMode = CONFIG.getConfig(ConfigurationKeys.STORE_LOCK_MODE, storeMode);
}
StoreConfig.setStartupParameter(storeMode, sessionStoreMode, lockStoreMode);
} catch (ParameterException e) {
printError(e);
}
Expand Down Expand Up @@ -112,15 +107,6 @@ private void getEnvParameters() {
if (serverNode == null) {
serverNode = ContainerHelper.getServerNode();
}
if (StringUtils.isBlank(storeMode)) {
storeMode = ContainerHelper.getStoreMode();
}
if (StringUtils.isBlank(sessionStoreMode)) {
sessionStoreMode = ContainerHelper.getSessionStoreMode();
}
if (StringUtils.isBlank(lockStoreMode)) {
lockStoreMode = ContainerHelper.getLockStoreMode();
}
}

private void printError(ParameterException e) {
Expand Down Expand Up @@ -163,7 +149,7 @@ public String getStoreMode() {
* @return the store mode
*/
public String getLockStoreMode() {
return StringUtils.isNotEmpty(lockStoreMode) ? lockStoreMode : storeMode;
return lockStoreMode;
}

/**
Expand All @@ -172,7 +158,7 @@ public String getLockStoreMode() {
* @return the store mode
*/
public String getSessionStoreMode() {
return StringUtils.isNotEmpty(sessionStoreMode) ? sessionStoreMode : storeMode;
return sessionStoreMode;
}

/**
Expand Down
7 changes: 2 additions & 5 deletions server/src/main/java/io/seata/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.seata.common.util.NetUtil;
import io.seata.common.util.StringUtils;
import io.seata.config.ConfigurationFactory;
import io.seata.core.constants.ConfigurationKeys;
import io.seata.core.rpc.netty.NettyRemotingServer;
import io.seata.core.rpc.netty.NettyServerConfig;
import io.seata.server.coordinator.DefaultCoordinator;
Expand Down Expand Up @@ -60,8 +59,6 @@ public static void start(String[] args) {
//initialize the metrics
MetricsManager.get().init();

System.setProperty(ConfigurationKeys.STORE_MODE, parameterParser.getStoreMode());

ThreadPoolExecutor workingThreads = new ThreadPoolExecutor(NettyServerConfig.getMinServerPoolSize(),
NettyServerConfig.getMaxServerPoolSize(), NettyServerConfig.getKeepAliveTime(), TimeUnit.SECONDS,
new LinkedBlockingQueue<>(NettyServerConfig.getMaxTaskQueueSize()),
Expand All @@ -83,8 +80,8 @@ public static void start(String[] args) {
XID.setPort(nettyRemotingServer.getListenPort());
UUIDGenerator.init(parameterParser.getServerNode());
//log store mode : file, db, redis
SessionHolder.init(parameterParser.getSessionStoreMode());
LockerManagerFactory.init(parameterParser.getLockStoreMode());
SessionHolder.init();
LockerManagerFactory.init();
DefaultCoordinator coordinator = DefaultCoordinator.getInstance(nettyRemotingServer);
coordinator.init();
nettyRemotingServer.setHandler(coordinator);
Expand Down
Loading

0 comments on commit 5f2acb5

Please sign in to comment.