-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize: refactor loadBalance config from registry.conf to file.conf. #3248
Conversation
|
处理一下ci的报错 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, please in server/file. Conf. Example, script/server/conf and client/conf&spring, add configuration information
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; | ||
import io.seata.spring.boot.autoconfigure.properties.registry.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- is not allowed
@@ -1,8 +1,7 @@ | |||
registry { | |||
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa | |||
type = "file" | |||
loadBalance = "RandomLoadBalance" | |||
loadBalanceVirtualNodes = 10 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank lines can be removed
@ph3636 PTAL |
Codecov Report
@@ Coverage Diff @@
## develop #3248 +/- ##
=============================================
- Coverage 51.54% 51.53% -0.01%
+ Complexity 3376 3375 -1
=============================================
Files 617 618 +1
Lines 20474 20477 +3
Branches 2567 2567
=============================================
Hits 10553 10553
- Misses 8861 8862 +1
- Partials 1060 1062 +2
|
Search it according to the keyword (loadBalanceVirtualNodes), or check it through git records, there are still many places that have not been changed. |
@ph3636 好的, 修改了。 |
I think this configuration is more appropriate to put in the client, the server will not use this configuration |
有道理阿, 只有TM,RM才需要负载均衡。 TC都知道发给谁了,就不用均衡了。 那我在改改 |
Change these files No configuration in these files There are some other details, such as wrong name, extra blank lines, etc. |
private static final String VIRTUAL_NODES = FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + "loadBalanceVirtualNodes"; | ||
private static final int VIRTUAL_NODES_NUM = ConfigurationFactory.CURRENT_FILE_INSTANCE.getInt(VIRTUAL_NODES, VIRTUAL_NODES_DEFAULT); | ||
/** | ||
* The constant LOAD_BALANCE_TYPE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this name
改一下这个名字
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the name or delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一直以为改了,今天核对才发现没改。 刚刚改掉了
script/server/config/file.properties
Outdated
@@ -25,3 +25,5 @@ store.redis.database=0 | |||
store.redis.minConn=1 | |||
store.redis.maxConn=10 | |||
store.redis.queryLimit=100 | |||
loadBalance.type=RandomLoadBalance | |||
loadBalance.consistentHash.virtualNodes=10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are redundant
这些是多余
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多余的删掉了
script/server/config/file.yml
Outdated
loadBalance: | ||
type: RandomLoadBalance | ||
consistentHash: | ||
virtualNodes: 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are redundant
这些是多余
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多谢大神, 已将多余的部分删除。 将loadBalance的 type 和 visualNodes 区分开了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
private static final String VIRTUAL_NODES = FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + "loadBalanceVirtualNodes"; | ||
private static final int VIRTUAL_NODES_NUM = ConfigurationFactory.CURRENT_FILE_INSTANCE.getInt(VIRTUAL_NODES, VIRTUAL_NODES_DEFAULT); | ||
/** | ||
* The constant LOAD_BALANCE_TYPE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the name or delete it
…_1101 # Conflicts: # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
请解决代码冲突 |
b4f8a11
to
f645e9f
Compare
…balance_1101 # Conflicts: # discovery/seata-discovery-core/src/main/java/io/seata/discovery/loadbalance/ConsistentHashLoadBalance.java # script/client/conf/file.conf # script/client/spring/application.properties # script/client/spring/application.yml # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -59,7 +59,7 @@ | |||
- [[#3420](https://github.com/seata/seata/pull/3420)] optimize enumerated classes and add unit tests | |||
- [[#3436](https://github.com/seata/seata/pull/3436)] optimize typo in SQLType class | |||
- [[#3439](https://github.com/seata/seata/pull/3439)] adjust the order of springApplicationContextProvider | |||
|
|||
- [[#3248](https://github.com/seata/seata/pull/3248)] optimize the config of load-balance migration to belong the client node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migrate instead of migration, migration is not a verb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
/** | ||
* The constant LOAD_BALANCE_CONSISTENT_HASH_VISUAL_NODES. | ||
*/ | ||
public static final String LOAD_BALANCE_CONSISTENT_HASH_VISUAL_NODES = LOAD_BALANCE_PREFIX + "visualNodes"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xingfudeshi
配置名 visualNodes
与 LoadBalanceProperties
类里的field virtualNodes
名不一致,导致在 SpringBootConfigurationProvider
下,获取字段时不存在,导致返回配置值为 null
。
也就是说在springboot下,配置了seata.client.load-balance.visual-nodes
或 seata.client.load-balance.virtual-nodes
都会导致配置读取不到。
public class SpringBootConfigurationProvider implements ExtConfigurationProvider {
....
private Object getFieldValue(Object object, String fieldName, String dataId) throws IllegalAccessException {
Optional<Field> fieldOptional = Stream.of(object.getClass().getDeclaredFields())
.filter(f -> f.getName().equalsIgnoreCase(fieldName)).findAny();
if (fieldOptional.isPresent()) {
Field field = fieldOptional.get();
if (Objects.equals(field.getType(), Map.class)) {
return getConfig(dataId, null, String.class);
}
field.setAccessible(true);
Object defaultValue = field.get(object);
return getConfig(dataId, defaultValue, field.getType());
}
return null;
}
....
}
Ⅰ. Describe what this PR did
loadbalance
的配置在registry.conf
文件, 这个文件属于配置中心的基础配置, 除了指定方式和基础信息以外,其他信息不应该在这个文件。 把loadBalance
改到核心配置文件中(file.conf).例如随机负载均衡
还有一致性hash负载均衡
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews