未验证 提交 75824a28 编写于 作者: L Liang Zhang 提交者: GitHub

Unify properties and props (#6019)

* Unify properties and props

* Unify properties and props

* Merge branch 'master' into dev

# Conflicts:
#	shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/ModuloShardingAlgorithm.java
#	shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java
#	shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
上级 7c02d596
......@@ -125,7 +125,7 @@ Apache ShardingSphere 接收到该 SQL,通过用户提供的加密配置,发
plainColumn: pwd
cipherColumn: pwd_cipher
encryptorName: aes_encryptor
properties:
props:
query.with.cipher.column: false
```
......@@ -179,7 +179,7 @@ properties:
pwd: # pwd 与 pwd_cipher 的转换映射
cipherColumn: pwd_cipher
encryptorName: aes_encryptor
properties:
props:
query.with.cipher.column: true
```
......
......@@ -163,7 +163,7 @@ In addition, demonstrate a set of encryption configuration rules, as follows:
plainColumn: pwd
cipherColumn: pwd_cipher
encryptorName: aes_encryptor
properties:
props:
query.with.cipher.column: false
```
......@@ -229,7 +229,7 @@ So the encryption configuration after migration is:
pwd: # pwd与pwd_cipher的转换映射
cipherColumn: pwd_cipher
encryptorName: aes_encryptor
properties:
props:
query.with.cipher.column: true
```
......
......@@ -51,7 +51,7 @@ sql.show: true
```yaml
ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
properties:
props:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
password: null
maxPoolSize: 50
......@@ -63,7 +63,7 @@ ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourc
maxLifetimeMilliseconds: 1800000
ds_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
properties:
props:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
password: null
maxPoolSize: 50
......
......@@ -51,7 +51,7 @@ A collection of multiple database connection pools, whose properties (e.g. DBCP,
```yaml
ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
properties:
props:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
password: null
maxPoolSize: 50
......@@ -63,7 +63,7 @@ ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourc
maxLifetimeMilliseconds: 1800000
ds_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
properties:
props:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
password: null
maxPoolSize: 50
......
......@@ -33,7 +33,7 @@ curl -X POST \
-H 'content-type: application/json' \
-d '{
"ruleConfiguration": {
"sourceDatasource": "ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n properties:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\'keyGenerateStrategy
"sourceDatasource": "ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n props:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\'keyGenerateStrategy
```
更多管理接口详情请参见[使用手册](/cn/user-manual/shardingsphere-scaling/usage/)
......@@ -33,7 +33,7 @@ curl -X POST \
-H 'content-type: application/json' \
-d '{
"ruleConfiguration": {
"sourceDatasource": "ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n properties:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\'keyGenerateStrategy
"sourceDatasource": "ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n props:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\'keyGenerateStrategy
```
Please refer to [Configuration Manual](/en/user-manual/shardingsphere-scaling/usage/) for more details.
......@@ -57,7 +57,7 @@ shardingRule:
type: SNOWFLAKE
column: order_id
properties:
props:
sql.show: true
```
......@@ -88,7 +88,7 @@ masterSlaveRule:
- ds_slave0
- ds_slave1
properties:
props:
sql.show: true
```
......@@ -118,7 +118,7 @@ encryptRule:
order_id:
cipherColumn: order_cipher
encryptorName: md5_encryptor
properties:
props:
query.with.cipher.column: true #是否使用密文列查询
```
......@@ -207,7 +207,7 @@ shardingRule:
- ds1_slave0
- ds1_slave1
loadBalanceAlgorithmType: ROUND_ROBIN
properties:
props:
sql.show: true
```
......@@ -271,7 +271,7 @@ shardingRule:
cipherColumn: order_cipher
encryptorName: aes_encryptor
properties:
props:
sql.show: true
```
......@@ -286,7 +286,7 @@ orchestration:
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration
properties:
props:
overwrite: true
```
......@@ -326,7 +326,7 @@ shardingRule:
keyGenerateStrategy:
column: #自增列名称,缺省表示不使用自增主键生成器
type: #自增列值生成器类型,缺省表示使用默认自增列值生成器。可使用用户自定义的列值生成器或选择内置类型:SNOWFLAKE/UUID
properties: #属性配置, 注意:使用SNOWFLAKE算法,需要配置worker.id与max.tolerate.time.difference.milliseconds属性。若使用此算法生成值作分片值,建议配置max.vibration.offset属性
props: #属性配置, 注意:使用SNOWFLAKE算法,需要配置worker.id与max.tolerate.time.difference.milliseconds属性。若使用此算法生成值作分片值,建议配置max.vibration.offset属性
<property-name>: 属性名称
bindingTables: #绑定表规则列表
......@@ -343,7 +343,7 @@ shardingRule:
defaultTableStrategy: #默认表分片策略,同分库策略
defaultKeyGenerateStrategy: #默认的主键生成算法 如果没有设置,默认为SNOWFLAKE算法
type: #默认自增列值生成器类型,缺省将使用org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator。可使用用户自定义的列值生成器或选择内置类型:SNOWFLAKE/UUID
properties:
props:
<property-name>: #自增列值生成器属性配置, 比如SNOWFLAKE算法的worker.id与max.tolerate.time.difference.milliseconds
masterSlaveRules: #读写分离规则,详见读写分离部分
......@@ -351,10 +351,10 @@ shardingRule:
masterDataSourceName: #详见读写分离部分
slaveDataSourceNames: #详见读写分离部分
loadBalanceAlgorithmType: #详见读写分离部分
properties: #读写分离负载算法的属性配置
props: #读写分离负载算法的属性配置
<property-name>: #属性值
properties: #属性配置
props: #属性配置
sql.show: #是否开启SQL显示,默认值: false
executor.size: #工作线程数量,默认值: CPU核数
max.connections.size.per.query: # 每个查询可以打开的最大连接数量,默认为1
......@@ -374,7 +374,7 @@ masterSlaveRule:
- <data_source_name2>
- <data_source_name_x>
loadBalanceAlgorithmType: #从库负载均衡算法类型,可选值:ROUND_ROBIN,RANDOM。若`loadBalanceAlgorithmClassName`存在则忽略该配置
properties: #读写分离负载算法的属性配置
props: #读写分离负载算法的属性配置
<property-name>: #属性值
```
......@@ -413,7 +413,7 @@ orchestration:
instanceType: #配置/注册/元数据中心类型。如:zookeeper
serverLists: #连接配置/注册/元数据中心服务器的列表。包括IP地址和端口号。多个地址用逗号分隔。如: host1:2181,host2:2181
namespace: #配置/注册/元数据中心的命名空间
properties: #其它配置
props: #其它配置
overwrite: #本地配置是否覆盖配置中心配置。如果可覆盖,每次启动都以本地配置为准
digest: #连接注册中心的权限令牌。缺省为不需要权限验证
operationTimeoutMilliseconds: #操作超时的毫秒数,默认500毫秒
......
......@@ -57,7 +57,7 @@ shardingRule:
type: SNOWFLAKE
column: order_id
properties:
props:
sql.show: true
```
......@@ -88,7 +88,7 @@ masterSlaveRule:
- ds_slave0
- ds_slave1
properties:
props:
sql.show: true
```
......@@ -119,7 +119,7 @@ encryptRule:
order_id:
cipherColumn: order_cipher
encryptorName: md5_encryptor
properties:
props:
query.with.cipher.column: true
```
......@@ -208,7 +208,7 @@ shardingRule:
- ds1_slave0
- ds1_slave1
loadBalanceAlgorithmType: ROUND_ROBIN
properties:
props:
sql.show: true
```
......@@ -272,7 +272,7 @@ shardingRule:
cipherColumn: order_cipher
encryptorName: aes_encryptor
properties:
props:
sql.show: true
```
......@@ -287,7 +287,7 @@ orchestration:
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration
properties:
props:
overwrite: true
```
......@@ -327,7 +327,7 @@ shardingRule:
keyGenerateStrategy:
column: #Column name of key generator
type: #Type of key generator, use default key generator if absent, and there are three types to choose, that is, SNOWFLAKE/UUID
properties: #Properties, Notice: when use SNOWFLAKE, `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE` need to be set. To use the generated value of this algorithm as sharding value, it is recommended to configure `max.vibration.offset`
props: #Properties, Notice: when use SNOWFLAKE, `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE` need to be set. To use the generated value of this algorithm as sharding value, it is recommended to configure `max.vibration.offset`
bindingTables: #Binding table rule configurations
- <logic_table_name1, logic_table_name2, ...>
......@@ -344,17 +344,17 @@ shardingRule:
defaultKeyGenerateStrategy:
type: #Type of default key generator, use user-defined ones or built-in ones, e.g. SNOWFLAKE, UUID. Default key generator is `org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator`
column: #Column name of default key generator
properties: #Properties of default key generator, e.g. `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE`
props: #Properties of default key generator, e.g. `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE`
masterSlaveRules: #Read-write splitting rule configuration, more details can reference Read-write splitting part
<data_source_name>: #Data sources configuration, need consist with data source map, multiple `data_source_name` available
masterDataSourceName: #more details can reference Read-write splitting part
slaveDataSourceNames: #more details can reference Read-write splitting part
loadBalanceAlgorithmType: #more details can reference Read-write splitting part
properties: #Properties configuration of load balance algorithm
<property-name>: #property key value pair
props: #Properties configuration of load balance algorithm
<property-name>: #property key value pair
properties: #Properties
props: #Properties
sql.show: #To show SQLS or not, default value: false
executor.size: #The number of working threads, default value: CPU count
check.table.metadata.enabled: #To check the metadata consistency of all the tables or not, default value : false
......@@ -374,10 +374,10 @@ masterSlaveRule:
- <data_source_name2>
- <data_source_name_x>
loadBalanceAlgorithmType: #Slave database load balance algorithm type; optional value, ROUND_ROBIN and RANDOM, can be omitted if `loadBalanceAlgorithmClassName` exists
properties: #Properties configuration of load balance algorithm
<property-name>: #property key value pair
props: #Properties configuration of load balance algorithm
<property-name>: #property key value pair
properties: #Property configuration
props: #Property configuration
sql.show: #Show SQL or not; default value: false
executor.size: #Executing thread number; default value: CPU core number
check.table.metadata.enabled: # Whether to check table metadata consistency when it initializes; default value: false
......@@ -418,7 +418,7 @@ orchestration:
instanceType: #Center instance type. Example:zookeeper
serverLists: #The list of servers that connect to registry center, including IP and port number; use commas to seperate addresses, such as: host1:2181,host2:2181
namespace: #Center namespace
properties: #Other properties
props: #Other properties
overwrite: #Whether to overwrite local configurations with config center configurations; if it can, each initialization should refer to local configurations
digest: #The token that connects to the center; default means there is no need for authentication
operationTimeoutMilliseconds: #Default value: 500 milliseconds
......
......@@ -24,9 +24,9 @@ Map<String, DataSource> dataSourceMap = // ...
Collection<RuleConfiguration> configurations = // ...
// 构建属性配置
Properties properties = // ...
Properties props = // ...
DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, properties);
DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props);
```
### 创建携带治理功能的数据源
......@@ -41,12 +41,12 @@ Map<String, DataSource> dataSourceMap = // ...
Collection<RuleConfiguration> configurations = // ...
// 构建属性配置
Properties properties = // ...
Properties props = // ...
// 构建注册中心配置对象
OrchestrationConfiguration orchestrationConfig = // ...
DataSource dataSource = OrchestrationShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, properties, orchestrationConfig);
DataSource dataSource = OrchestrationShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props, orchestrationConfig);
```
### 使用数据源
......
......@@ -25,9 +25,9 @@ Map<String, DataSource> dataSourceMap = // ...
Collection<RuleConfiguration> configurations = // ...
// Build properties
Properties properties = // ...
Properties props = // ...
DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, properties);
DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props);
```
### Create Orchestration DataSource
......@@ -43,12 +43,12 @@ Map<String, DataSource> dataSourceMap = // ...
Collection<RuleConfiguration> configurations = // ...
// Build properties
Properties properties = // ...
Properties props = // ...
// Build orchestration configuration
OrchestrationConfiguration orchestrationConfig = // ...
DataSource dataSource = OrchestrationShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, properties, orchestrationConfig);
DataSource dataSource = OrchestrationShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props, orchestrationConfig);
```
### Use DataSource
......
......@@ -36,9 +36,9 @@ weight = 1
// ...
// 配置配置/注册/元数据中心
Properties properties = new Properties();
properties.setProperty("overwrite", overwrite);
CenterConfiguration centerConfiguration = new CenterConfiguration("zookeeper", properties);
Properties props = new Properties();
props.setProperty("overwrite", overwrite);
CenterConfiguration centerConfiguration = new CenterConfiguration("zookeeper", props);
centerConfiguration.setServerLists("localhost:2181");
centerConfiguration.setNamespace("shardingsphere-orchestration");
centerConfiguration.setOrchestrationType("registry_center,config_center,metadata_center");
......
......@@ -36,9 +36,9 @@ Using ZooKeeper as config center and registry center for example.
// ...
// Configure config/registry/metadata center
Properties properties = new Properties();
properties.setProperty("overwrite", overwrite);
CenterConfiguration centerConfiguration = new CenterConfiguration("zookeeper", properties);
Properties props = new Properties();
props.setProperty("overwrite", overwrite);
CenterConfiguration centerConfiguration = new CenterConfiguration("zookeeper", props);
centerConfiguration.setServerLists("localhost:2181");
centerConfiguration.setNamespace("shardingsphere-orchestration");
centerConfiguration.setOrchestrationType("registry_center,config_center,metadata_center");
......
......@@ -38,7 +38,7 @@ orchestration:
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration
properties:
props:
overwrite: true
```
......
......@@ -38,7 +38,7 @@ orchestration:
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration
properties:
props:
overwrite: true
```
......
......@@ -42,7 +42,7 @@ rules:
type: SNOWFLAKE
column: order_id
properties:
props:
sql.show: true
```
......
......@@ -42,7 +42,7 @@ rules:
type: SNOWFLAKE
column: order_id
properties:
props:
sql.show: true
```
......
......@@ -46,7 +46,7 @@ ShardingTableRuleConfiguration orderTableRuleConfig = new ShardingTableRuleConfi
StandardShardingAlgorithm dbShardingAlgorithm = new InlineShardingAlgorithm();
Properties dbProps = new Properties();
dbProps.setProperty(InlineShardingAlgorithm.ALGORITHM_EXPRESSION, "ds${user_id % 2}");
dbShardingAlgorithm.setProperties(dbProps);
dbShardingAlgorithm.setProps(dbProps);
StandardShardingStrategyConfiguration dbShardingStrategyConfig = new StandardShardingStrategyConfiguration("user_id", dbShardingAlgorithm);
orderTableRuleConfig.setDatabaseShardingStrategy(dbShardingStrategyConfig);
......@@ -54,7 +54,7 @@ orderTableRuleConfig.setDatabaseShardingStrategy(dbShardingStrategyConfig);
StandardShardingAlgorithm tableShardingAlgorithm = new InlineShardingAlgorithm();
Properties tableProps = new Properties();
tableProps.setProperty(InlineShardingAlgorithm.ALGORITHM_EXPRESSION, "t_order${order_id % 2}");
tableShardingAlgorithm.setProperties(tableProps);
tableShardingAlgorithm.setProps(tableProps);
StandardShardingStrategyConfiguration tableShardingStrategy = new StandardShardingStrategyConfiguration("order_id", tableShardingAlgorithm);
orderTableRuleConfig.setTableShardingStrategy(tableShardingStrategy);
......
......@@ -47,7 +47,7 @@ ShardingTableRuleConfiguration orderTableRuleConfig = new ShardingTableRuleConfi
StandardShardingAlgorithm dbShardingAlgorithm = new InlineShardingAlgorithm();
Properties dbProps = new Properties();
dbProps.setProperty(InlineShardingAlgorithm.ALGORITHM_EXPRESSION, "ds${user_id % 2}");
dbShardingAlgorithm.setProperties(dbProps);
dbShardingAlgorithm.setProps(dbProps);
StandardShardingStrategyConfiguration dbShardingStrategyConfig = new StandardShardingStrategyConfiguration("user_id", dbShardingAlgorithm);
orderTableRuleConfig.setDatabaseShardingStrategy(dbShardingStrategyConfig);
......@@ -55,7 +55,7 @@ orderTableRuleConfig.setDatabaseShardingStrategy(dbShardingStrategyConfig);
StandardShardingAlgorithm tableShardingAlgorithm = new InlineShardingAlgorithm();
Properties tableProps = new Properties();
tableProps.setProperty(InlineShardingAlgorithm.ALGORITHM_EXPRESSION, "t_order${order_id % 2}");
tableShardingAlgorithm.setProperties(tableProps);
tableShardingAlgorithm.setProps(tableProps);
StandardShardingStrategyConfiguration tableShardingStrategy = new StandardShardingStrategyConfiguration("order_id", tableShardingAlgorithm);
orderTableRuleConfig.setTableShardingStrategy(tableShardingStrategy);
......
......@@ -47,7 +47,7 @@ rules:
shardingColumn: user_id
shardingAlgorithm:
type: INLINE
properties:
props:
algorithm.expression: ds${user_id % 2}
# 配置分表策略
tableStrategy:
......@@ -55,7 +55,7 @@ rules:
shardingColumn: order_id
shardingAlgorithm:
type: INLINE
properties:
props:
algorithm.expression: t_order${order_id % 2}
t_order_item:
# 省略配置 t_order_item 表规则...
......
......@@ -48,7 +48,7 @@ rules:
shardingColumn: user_id
shardingAlgorithm:
type: INLINE
properties:
props:
algorithm.expression: ds${user_id % 2}
# Configure table sharding strategy
tableStrategy:
......@@ -56,7 +56,7 @@ rules:
shardingColumn: order_id
shardingAlgorithm:
type: INLINE
properties:
props:
algorithm.expression: t_order${order_id % 2}
t_order_item:
# Omit t_order_item table rule configuration ...
......
......@@ -339,7 +339,7 @@ orchestration:
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration
properties:
props:
overwrite: true
```
......@@ -358,7 +358,7 @@ authentication:
### 公用属性
```yaml
properties:
props:
executor.size: 16
sql.show: false
```
......@@ -411,7 +411,7 @@ encryptRule:
cipherColumn: #存储密文的字段
assistedQueryColumn: #辅助查询字段,针对 QueryAssistedEncryptAlgorithm 类型的加解密算法进行辅助查询
encryptorName: #加密算法名称
properties:
props:
query.with.cipher.column: true #是否使用密文列查询
```
......@@ -424,8 +424,8 @@ properties:
### Proxy属性
```yaml
#省略与ShardingSphere-JDBC一致的配置属性
properties:
#省略与 ShardingSphere-JDBC 一致的配置属性
props:
acceptor.size: #用于设置接收客户端请求的工作线程个数,默认为CPU核数*2
proxy.transaction.type: #默认为LOCAL事务,允许LOCAL,XA,BASE三个值,XA采用Atomikos作为事务管理器,BASE类型需要拷贝实现ShardingTransactionManager的接口的jar包至lib目录中
proxy.opentracing.enabled: #是否开启链路追踪功能,默认为不开启。详情请参见[链路追踪](/cn/features/orchestration/apm/)
......
......@@ -338,7 +338,7 @@ orchestration:
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration
properties:
props:
overwrite: true
```
......@@ -357,7 +357,7 @@ authentication:
### Common property
```yaml
properties:
props:
executor.size: 16
sql.show: false
```
......@@ -410,7 +410,7 @@ encryptRule:
cipherColumn: #ciphertext column name
assistedQueryColumn: #AssistedColumns for query,when use QueryAssistedEncryptAlgorithm, it can help query encrypted data
encryptorName: #encrypt algorithm name
properties:
props:
query.with.cipher.column: true #Whether use cipherColumn to query or not
```
......@@ -424,7 +424,7 @@ It is the same with ShardingSphere-JDBC configuration.
```yaml
#Omit configurations that are the same with ShardingSphere-JDBC
properties:
props:
acceptor.size: #The thread number of accept connection; default to be 2 times of cpu core
proxy.transaction.type: #Support LOCAL, XA, BASE; Default is LOCAL transaction, for BASE type you should copy ShardingTransactionManager associated jar to lib directory
proxy.opentracing.enabled: #Whether to enable opentracing, default not to enable; refer to [APM](/en/features/orchestration/apm/) for more details
......
......@@ -72,7 +72,7 @@ curl -X POST \
-H 'content-type: application/json' \
-d '{
"ruleConfiguration": {
"sourceDatasource": "ds_0: !!YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n properties:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\''\n connectionTimeout: 30000\n idleTimeout: 60000\n maxLifetime: 1800000\n maxPoolSize: 50\n minPoolSize: 1\n maintenanceIntervalMilliseconds: 30000\n readOnly: false\n",
"sourceDatasource": "ds_0: !!YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n props:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\''\n connectionTimeout: 30000\n idleTimeout: 60000\n maxLifetime: 1800000\n maxPoolSize: 50\n minPoolSize: 1\n maintenanceIntervalMilliseconds: 30000\n readOnly: false\n",
"sourceRule": "defaultDatabaseStrategy:\n inline:\n algorithmExpression: ds_${user_id % 2}\n shardingColumn: user_id\ntables:\n t1:\n actualDataNodes: ds_0.t1\n keyGenerateStrategy:\n column: order_id\n type: SNOWFLAKE\n logicTable: t1\n tableStrategy:\n inline:\n algorithmExpression: t1\n shardingColumn: order_id\n t2:\n actualDataNodes: ds_0.t2\n keyGenerateStrategy:\n column: order_item_id\n type: SNOWFLAKE\n logicTable: t2\n tableStrategy:\n inline:\n algorithmExpression: t2\n shardingColumn: order_id\n",
"destinationDataSources": {
"name": "dt_0",
......
......@@ -72,7 +72,7 @@ curl -X POST \
-H 'content-type: application/json' \
-d '{
"ruleConfiguration": {
"sourceDatasource": "ds_0: !!org.apache.shardingsphere.orchestration.yaml.config.YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n properties:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\''\n connectionTimeout: 30000\n idleTimeout: 60000\n maxLifetime: 1800000\n maxPoolSize: 50\n minPoolSize: 1\n maintenanceIntervalMilliseconds: 30000\n readOnly: false\n",
"sourceDatasource": "ds_0: !!org.apache.shardingsphere.orchestration.yaml.config.YamlDataSourceConfiguration\n dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n props:\n jdbcUrl: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false\n username: root\n password: '\''123456'\''\n connectionTimeout: 30000\n idleTimeout: 60000\n maxLifetime: 1800000\n maxPoolSize: 50\n minPoolSize: 1\n maintenanceIntervalMilliseconds: 30000\n readOnly: false\n",
"sourceRule": "defaultDatabaseStrategy:\n inline:\n algorithmExpression: ds_${user_id % 2}\n shardingColumn: user_id\ntables:\n t1:\n actualDataNodes: ds_0.t1\n keyGenerateStrategy:\n column: order_id\n type: SNOWFLAKE\n logicTable: t1\n tableStrategy:\n inline:\n algorithmExpression: t1\n shardingColumn: order_id\n t2:\n actualDataNodes: ds_0.t2\n keyGenerateStrategy:\n column: order_item_id\n type: SNOWFLAKE\n logicTable: t2\n tableStrategy:\n inline:\n algorithmExpression: t2\n shardingColumn: order_id\n",
"destinationDataSources": {
"name": "dt_0",
......
......@@ -72,11 +72,11 @@ public final class StandardModuloShardingDatabaseAlgorithm implements StandardSh
}
@Override
public Properties getProperties() {
public Properties getProps() {
return new Properties();
}
@Override
public void setProperties(final Properties properties) {
public void setProps(final Properties props) {
}
}
......@@ -64,11 +64,11 @@ public final class StandardModuloShardingTableAlgorithm implements StandardShard
}
@Override
public Properties getProperties() {
public Properties getProps() {
return new Properties();
}
@Override
public void setProperties(final Properties properties) {
public void setProps(final Properties props) {
}
}
......@@ -23,39 +23,39 @@ import java.util.Properties;
public final class TestQueryAssistedShardingEncryptAlgorithm implements QueryAssistedEncryptAlgorithm {
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public String getType() {
return "assistedTest";
public void init() {
}
@Override
public Properties getProperties() {
return properties;
public String encrypt(final Object plaintext) {
return "encryptValue";
}
@Override
public void setProperties(final Properties properties) {
this.properties = properties;
public Object decrypt(final String ciphertext) {
return "decryptValue";
}
@Override
public void init() {
public String queryAssistedEncrypt(final String plaintext) {
return "assistedEncryptValue";
}
@Override
public String encrypt(final Object plaintext) {
return "encryptValue";
public String getType() {
return "assistedTest";
}
@Override
public Object decrypt(final String ciphertext) {
return "decryptValue";
public Properties getProps() {
return props;
}
@Override
public String queryAssistedEncrypt(final String plaintext) {
return "assistedEncryptValue";
public void setProps(final Properties props) {
this.props = props;
}
}
......@@ -34,33 +34,33 @@ public class RegistryCenterConfigurationUtil {
private static final String NACOS_NAMESPACE = "";
public static Map<String, CenterConfiguration> getZooKeeperConfiguration(String overwrite, ShardingType shardingType) {
Map<String, CenterConfiguration> instanceConfigurationMap = new HashMap<String, CenterConfiguration>();
Properties properties = new Properties();
properties.setProperty("overwrite", overwrite);
CenterConfiguration result = new CenterConfiguration("zookeeper", properties);
result.setServerLists(ZOOKEEPER_CONNECTION_STRING);
result.setNamespace(NAMESPACE);
result.setOrchestrationType("registry_center,config_center,metadata_center");
public static Map<String, CenterConfiguration> getZooKeeperConfiguration(final String overwrite, final ShardingType shardingType) {
Map<String, CenterConfiguration> result = new HashMap<>();
Properties props = new Properties();
props.setProperty("overwrite", overwrite);
CenterConfiguration centerConfiguration = new CenterConfiguration("zookeeper", props);
centerConfiguration.setServerLists(ZOOKEEPER_CONNECTION_STRING);
centerConfiguration.setNamespace(NAMESPACE);
centerConfiguration.setOrchestrationType("registry_center,config_center,metadata_center");
switch (shardingType) {
case SHARDING_DATABASES_AND_TABLES:
instanceConfigurationMap.put("orchestration-sharding-data-source", result);
result.put("orchestration-sharding-data-source", centerConfiguration);
break;
case MASTER_SLAVE:
instanceConfigurationMap.put("orchestration-ms-data-source", result);
result.put("orchestration-ms-data-source", centerConfiguration);
break;
case ENCRYPT:
instanceConfigurationMap.put("orchestration-encrypt-data-source", result);
result.put("orchestration-encrypt-data-source", centerConfiguration);
break;
case SHADOW:
instanceConfigurationMap.put("orchestration-shadow-data-source", result);
result.put("orchestration-shadow-data-source", centerConfiguration);
break;
}
return instanceConfigurationMap;
return result;
}
public static Map<String, CenterConfiguration> getNacosConfiguration(String overwrite, ShardingType shardingType) {
Map<String, CenterConfiguration> instanceConfigurationMap = new HashMap<String, CenterConfiguration>();
public static Map<String, CenterConfiguration> getNacosConfiguration(final String overwrite, final ShardingType shardingType) {
Map<String, CenterConfiguration> result = new HashMap<>();
Properties nacosProperties = new Properties();
nacosProperties.setProperty("group", "SHARDING_SPHERE_DEFAULT_GROUP");
nacosProperties.setProperty("timeout", "3000");
......@@ -77,22 +77,22 @@ public class RegistryCenterConfigurationUtil {
zookeeperResult.setOrchestrationType("registry_center,metadata_center");
switch (shardingType) {
case SHARDING_DATABASES_AND_TABLES:
instanceConfigurationMap.put("orchestration-sharding-data-source", nacosResult);
instanceConfigurationMap.put("orchestration-zookeeper-sharding-data-source", zookeeperResult);
result.put("orchestration-sharding-data-source", nacosResult);
result.put("orchestration-zookeeper-sharding-data-source", zookeeperResult);
break;
case MASTER_SLAVE:
instanceConfigurationMap.put("orchestration-ms-data-source", nacosResult);
instanceConfigurationMap.put("orchestration-zookeeper-ms-data-source", zookeeperResult);
result.put("orchestration-ms-data-source", nacosResult);
result.put("orchestration-zookeeper-ms-data-source", zookeeperResult);
break;
case ENCRYPT:
instanceConfigurationMap.put("orchestration-encrypt-data-source", nacosResult);
instanceConfigurationMap.put("orchestration-zookeeper-encrypt-data-source", zookeeperResult);
result.put("orchestration-encrypt-data-source", nacosResult);
result.put("orchestration-zookeeper-encrypt-data-source", zookeeperResult);
break;
case SHADOW:
instanceConfigurationMap.put("orchestration-shadow-data-source", nacosResult);
instanceConfigurationMap.put("orchestration-zookeeper-shadow-data-source", zookeeperResult);
result.put("orchestration-shadow-data-source", nacosResult);
result.put("orchestration-zookeeper-shadow-data-source", zookeeperResult);
break;
}
return instanceConfigurationMap;
return result;
}
}
......@@ -62,8 +62,8 @@ public final class LocalEncryptConfiguration implements ExampleConfiguration {
}
private EncryptAlgorithmConfiguration createEncryptAlgorithmConfiguration() {
Properties properties = new Properties();
properties.setProperty("aes.key.value", "123456");
return new EncryptAlgorithmConfiguration("AES", properties);
Properties props = new Properties();
props.setProperty("aes.key.value", "123456");
return new EncryptAlgorithmConfiguration("AES", props);
}
}
......@@ -62,7 +62,7 @@ public final class LocalShardingDatabasesAndTablesConfiguration implements Examp
result.getBindingTableGroups().add("t_order, t_order_item");
result.getBroadcastTables().add("t_address");
InlineShardingAlgorithm shardingAlgorithm = new InlineShardingAlgorithm();
shardingAlgorithm.getProperties().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
shardingAlgorithm.getProps().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", shardingAlgorithm));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", new StandardModuloShardingTableAlgorithm()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
......
......@@ -27,8 +27,6 @@ import org.apache.shardingsphere.sharding.api.config.algorithm.KeyGenerateAlgori
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.strategy.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.strategy.algorithm.sharding.inline.InlineShardingAlgorithm;
import javax.sql.DataSource;
......@@ -63,9 +61,9 @@ public final class LocalShardingDatabasesConfiguration implements ExampleConfigu
result.getBindingTableGroups().add("t_order, t_order_item");
result.getBroadcastTables().add("t_address");
InlineShardingAlgorithm shardingAlgorithm = new InlineShardingAlgorithm();
shardingAlgorithm.getProperties().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
shardingAlgorithm.getProps().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", shardingAlgorithm));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProps()));
return result;
}
......@@ -86,13 +84,7 @@ public final class LocalShardingDatabasesConfiguration implements ExampleConfigu
return result;
}
private static KeyGenerateAlgorithm getSnowflakeKeyGenerateAlgorithm() {
KeyGenerateAlgorithm result = new SnowflakeKeyGenerateAlgorithm();
result.setProperties(getProperties());
return result;
}
private static Properties getProperties() {
private static Properties getProps() {
Properties result = new Properties();
result.setProperty("worker.id", "123");
return result;
......
......@@ -51,7 +51,7 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
spring.shardingsphere.orchestration.demo_spring_boot_ds_sharding.orchestration-type=config_center
spring.shardingsphere.orchestration.demo_spring_boot_ds_sharding.instance-type=nacos
......
......@@ -51,7 +51,7 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
spring.shardingsphere.orchestration.demo_spring_boot_ds_sharding.orchestration-type=registry_center,config_center,metadata_center
spring.shardingsphere.orchestration.demo_spring_boot_ds_sharding.instance-type=zookeeper
......
......@@ -37,18 +37,18 @@ public final class EncryptDatabasesConfiguration implements ExampleConfiguration
@Override
public DataSource getDataSource() {
Properties properties = new Properties();
properties.setProperty("aes.key.value", "123456");
properties.setProperty("query.with.cipher.column", "true");
Properties props = new Properties();
props.setProperty("aes.key.value", "123456");
props.setProperty("query.with.cipher.column", "true");
EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("user_name", "user_name", "", "user_name_plain", "name_encryptor");
EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "", "pwd_encryptor");
EncryptTableRuleConfiguration encryptTableRuleConfiguration = new EncryptTableRuleConfiguration("t_user", Arrays.asList(columnConfigAes, columnConfigTest));
Map<String, EncryptAlgorithmConfiguration> encryptAlgorithmConfigurations = new LinkedHashMap<>(2, 1);
encryptAlgorithmConfigurations.put("name_encryptor", new EncryptAlgorithmConfiguration("AES", properties));
encryptAlgorithmConfigurations.put("pwd_encryptor", new EncryptAlgorithmConfiguration("assistedTest", properties));
encryptAlgorithmConfigurations.put("name_encryptor", new EncryptAlgorithmConfiguration("AES", props));
encryptAlgorithmConfigurations.put("pwd_encryptor", new EncryptAlgorithmConfiguration("assistedTest", props));
EncryptRuleConfiguration encryptRuleConfiguration = new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfiguration), encryptAlgorithmConfigurations);
try {
return ShardingSphereDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), Collections.singleton(encryptRuleConfiguration), properties);
return ShardingSphereDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), Collections.singleton(encryptRuleConfiguration), props);
} catch (final SQLException ex) {
ex.printStackTrace();
return null;
......
......@@ -49,11 +49,11 @@ public final class ModuloHintShardingAlgorithm implements HintShardingAlgorithm<
}
@Override
public Properties getProperties() {
public Properties getProps() {
return new Properties();
}
@Override
public void setProperties(final Properties properties) {
public void setProps(final Properties props) {
}
}
......@@ -63,7 +63,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -45,11 +45,11 @@ public final class EncryptShadowDatabasesConfiguration implements ExampleConfigu
dataSourceMap.put("ds", DataSourceUtil.createDataSource("demo_ds"));
dataSourceMap.put("ds_0", DataSourceUtil.createDataSource("shadow_demo_ds"));
EncryptRuleConfiguration encryptRuleConfiguration = new EncryptRuleConfiguration(getEncryptTableRuleConfigurations(), getEncryptAlgorithmConfigurations());
Properties properties = new Properties();
properties.setProperty("sql.show", "true");
properties.setProperty("query.with.cipher.column", "true");
Properties props = new Properties();
props.setProperty("sql.show", "true");
props.setProperty("query.with.cipher.column", "true");
ShadowRuleConfiguration shadowRuleConfiguration = new ShadowRuleConfiguration("shadow", Collections.singletonMap("ds", "ds_0"));
return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Arrays.asList(shadowRuleConfiguration, encryptRuleConfiguration), properties);
return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Arrays.asList(shadowRuleConfiguration, encryptRuleConfiguration), props);
}
private Collection<EncryptTableRuleConfiguration> getEncryptTableRuleConfigurations() {
......@@ -63,9 +63,9 @@ public final class EncryptShadowDatabasesConfiguration implements ExampleConfigu
private Map<String, EncryptAlgorithmConfiguration> getEncryptAlgorithmConfigurations() {
Map<String, EncryptAlgorithmConfiguration> result = new LinkedHashMap<>(2, 1);
Properties properties = new Properties();
properties.setProperty("aes.key.value", "123456");
result.put("name_encryptor", new EncryptAlgorithmConfiguration("AES", properties));
Properties props = new Properties();
props.setProperty("aes.key.value", "123456");
result.put("name_encryptor", new EncryptAlgorithmConfiguration("AES", props));
result.put("pwd_encryptor", new EncryptAlgorithmConfiguration("assistedTest", null));
return result;
}
......
......@@ -47,10 +47,10 @@ public final class ShardingShadowDatabasesConfiguration implements ExampleConfig
dataSourceMap.put("shadow_ds_1", DataSourceUtil.createDataSource("shadow_demo_ds_1"));
ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
shardingRuleConfiguration.getTables().add(getUserTableConfiguration());
Properties properties = new Properties();
properties.setProperty("sql.show", "true");
Properties props = new Properties();
props.setProperty("sql.show", "true");
ShadowRuleConfiguration shadowRuleConfiguration = new ShadowRuleConfiguration("shadow", shadowMappings);
return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Arrays.asList(shadowRuleConfiguration, shardingRuleConfiguration), properties);
return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Arrays.asList(shadowRuleConfiguration, shardingRuleConfiguration), props);
}
private ShardingTableRuleConfiguration getUserTableConfiguration() {
......@@ -62,13 +62,13 @@ public final class ShardingShadowDatabasesConfiguration implements ExampleConfig
private StandardShardingStrategyConfiguration getTableStandardShardingStrategyConfiguration() {
InlineShardingAlgorithm inlineShardingAlgorithm = new InlineShardingAlgorithm();
inlineShardingAlgorithm.getProperties().setProperty("algorithm.expression", "t_user");
inlineShardingAlgorithm.getProps().setProperty("algorithm.expression", "t_user");
return new StandardShardingStrategyConfiguration("user_id", inlineShardingAlgorithm);
}
private StandardShardingStrategyConfiguration getDatabaseStandardShardingStrategyConfiguration() {
InlineShardingAlgorithm inlineShardingAlgorithm = new InlineShardingAlgorithm();
inlineShardingAlgorithm.getProperties().setProperty("algorithm.expression", "ds_${user_id % 2}");
inlineShardingAlgorithm.getProps().setProperty("algorithm.expression", "ds_${user_id % 2}");
return new StandardShardingStrategyConfiguration("user_id", inlineShardingAlgorithm);
}
}
......@@ -44,4 +44,4 @@ spring.shardingsphere.rules.sharding.tables.t_shadow_user.key-generate-strategy.
spring.shardingsphere.rules.sharding.tables.t_shadow_user.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -49,7 +49,7 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa
result.getBindingTableGroups().add("t_order, t_order_item");
result.getBroadcastTables().add("t_address");
InlineShardingAlgorithm shardingAlgorithm = new InlineShardingAlgorithm();
shardingAlgorithm.getProperties().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
shardingAlgorithm.getProps().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", shardingAlgorithm));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", new StandardModuloShardingTableAlgorithm()));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
......
......@@ -47,7 +47,7 @@ public final class ShardingDatabasesConfigurationPrecise implements ExampleConfi
result.getTables().add(getOrderItemTableRuleConfiguration());
result.getBroadcastTables().add("t_address");
InlineShardingAlgorithm shardingAlgorithm = new InlineShardingAlgorithm();
shardingAlgorithm.getProperties().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
shardingAlgorithm.getProps().setProperty("algorithm.expression", "demo_ds_${user_id % 2}");
result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", shardingAlgorithm));
result.getKeyGenerators().put("snowflake", new KeyGenerateAlgorithmConfiguration("SNOWFLAKE", getProperties()));
return result;
......
......@@ -55,7 +55,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -65,7 +65,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -71,7 +71,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -57,7 +57,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -83,7 +83,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
- !MASTER_SLAVE
......
......@@ -89,7 +89,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
- !MASTER_SLAVE
......
......@@ -53,7 +53,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -57,7 +57,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -49,4 +49,4 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -42,4 +42,4 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -51,7 +51,7 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
spring.shardingsphere.rules.master-slaves.ds_0.master-data-source-name=ds_master_0
spring.shardingsphere.rules.master-slaves.ds_0.slave-data-source-names=ds_master_0_slave_0, ds_master_0_slave_1
......
......@@ -44,4 +44,4 @@ spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
spring.shardingsphere.rules.sharding.broadcast-tables=t_address
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -49,4 +49,4 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -43,4 +43,4 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generator.column=or
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.tables.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.tables.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.tables.snowflake.props.worker.id=123
......@@ -54,7 +54,7 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.c
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
spring.shardingsphere.rules.master-slave.data-sources.ds_0.master-data-source-name=ds_master_0
spring.shardingsphere.rules.master-slave.data-sources.ds_0.slave-data-source-names=ds_master_0_slave_0, ds_master_0_slave_1
......
......@@ -43,4 +43,4 @@ spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
spring.shardingsphere.rules.sharding.broadcast-tables=t_address
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -57,7 +57,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -37,4 +37,4 @@ spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column
spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -35,4 +35,4 @@ spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column
spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -31,4 +31,4 @@ spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column
spring.shardingsphere.rules.sharding.tables.t_order.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -56,7 +56,7 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
props:
......
......@@ -37,4 +37,4 @@ spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column
spring.shardingsphere.rules.sharding.tables.t_order.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -35,4 +35,4 @@ spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column
spring.shardingsphere.rules.sharding.tables.t_order.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -31,4 +31,4 @@ spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column
spring.shardingsphere.rules.sharding.tables.t_order.key-generator-name=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.key-generators.snowflake.properties.worker.id=123
\ No newline at end of file
spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
......@@ -87,5 +87,5 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
......@@ -27,7 +27,7 @@
# instanceType: zookeeper
# serverLists: localhost:2181
# namespace: orchestration
# properties:
# props:
# overwrite: false
# retryIntervalMilliseconds: 500
# timeToLiveSeconds: 60
......
......@@ -49,11 +49,11 @@ public final class ModuloHintShardingAlgorithm implements HintShardingAlgorithm<
}
@Override
public Properties getProperties() {
public Properties getProps() {
return new Properties();
}
@Override
public void setProperties(final Properties properties) {
public void setProps(final Properties props) {
}
}
......@@ -69,5 +69,5 @@ rules:
keyGenerators:
snowflake:
type: SNOWFLAKE
properties:
props:
worker.id: 123
......@@ -27,7 +27,7 @@
# instanceType: zookeeper
# serverLists: localhost:2181
# namespace: orchestration
# properties:
# props:
# overwrite: false
# retryIntervalMilliseconds: 500
# timeToLiveSeconds: 60
......
......@@ -31,16 +31,14 @@ public final class FirstMetricsTrackerManagerFixture implements MetricsTrackerMa
private final MetricsTrackerFactory metricsTrackerFactory = new FirstMetricsTrackerFactoryFixture();
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public void start(final MetricsConfiguration metricsConfiguration) {
}
@Override
public void stop() {
}
@Override
......
......@@ -31,16 +31,14 @@ public final class SecondMetricsTrackerManagerFixture implements MetricsTrackerM
private MetricsTrackerFactory metricsTrackerFactory = new SecondMetricsTrackerFactoryFixture();
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public void start(final MetricsConfiguration metricsConfiguration) {
}
@Override
public void stop() {
}
@Override
......
......@@ -42,7 +42,7 @@ public final class PrometheusMetricsTrackerManager implements MetricsTrackerMana
private final MetricsTrackerFactory metricsTrackerFactory = new PrometheusMetricsTrackerFactory();
private Properties properties = new Properties();
private Properties props = new Properties();
private HTTPServer server;
......
......@@ -45,7 +45,7 @@ public final class CenterConfiguration extends TypedSPIConfiguration {
*/
private String namespace;
public CenterConfiguration(final String type, final Properties properties) {
super(type, properties);
public CenterConfiguration(final String type, final Properties props) {
super(type, props);
}
}
......@@ -35,10 +35,10 @@ public final class CenterConfigurationTest {
@Test
public void assertConstructorWithTypeAndProperties() {
String type = "zookeeper";
Properties properties = new Properties();
CenterConfiguration configuration = new CenterConfiguration(type, properties);
Properties props = new Properties();
CenterConfiguration configuration = new CenterConfiguration(type, props);
assertThat(configuration.getType(), is(type));
assertThat(configuration.getProperties(), is(properties));
assertThat(configuration.getProps(), is(props));
}
@Test
......
......@@ -28,11 +28,11 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
@Getter
@Setter
public final class FirstTestCenterRepository implements ConfigCenterRepository {
@Getter
@Setter
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public void init(final CenterConfiguration config) {
......
......@@ -52,11 +52,11 @@ public final class ApolloCenterRepository implements ConfigCenterRepository {
@Getter
@Setter
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public void init(final CenterConfiguration config) {
ApolloProperties apolloProperties = new ApolloProperties(properties);
ApolloProperties apolloProperties = new ApolloProperties(props);
configWrapper = new ApolloConfigWrapper(config, apolloProperties);
openApiWrapper = new ApolloOpenApiWrapper(config, apolloProperties);
}
......
......@@ -38,10 +38,10 @@ public final class ApolloConfigWrapper {
private final Config apolloConfig;
public ApolloConfigWrapper(final CenterConfiguration config, final ApolloProperties properties) {
String appId = properties.getValue(ApolloPropertyKey.APP_ID);
String env = properties.getValue(ApolloPropertyKey.ENV);
String clusterName = properties.getValue(ApolloPropertyKey.CLUSTER_NAME);
public ApolloConfigWrapper(final CenterConfiguration config, final ApolloProperties props) {
String appId = props.getValue(ApolloPropertyKey.APP_ID);
String env = props.getValue(ApolloPropertyKey.ENV);
String clusterName = props.getValue(ApolloPropertyKey.CLUSTER_NAME);
System.setProperty(APOLLO_KEY_APP_ID, appId);
System.setProperty(APOLLO_KEY_ENV, env);
System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, clusterName);
......
......@@ -41,16 +41,16 @@ public final class ApolloOpenApiWrapper {
private final String administrator;
public ApolloOpenApiWrapper(final CenterConfiguration config, final ApolloProperties properties) {
public ApolloOpenApiWrapper(final CenterConfiguration config, final ApolloProperties props) {
namespace = config.getNamespace();
appId = properties.getValue(ApolloPropertyKey.APP_ID);
env = properties.getValue(ApolloPropertyKey.ENV);
clusterName = properties.getValue(ApolloPropertyKey.CLUSTER_NAME);
administrator = properties.getValue(ApolloPropertyKey.ADMINISTRATOR);
String apolloToken = properties.getValue(ApolloPropertyKey.TOKEN);
String portalUrl = properties.getValue(ApolloPropertyKey.PORTAL_URL);
Integer connectTimeout = properties.getValue(ApolloPropertyKey.CONNECT_TIMEOUT);
Integer readTimeout = properties.getValue(ApolloPropertyKey.READ_TIMEOUT);
appId = props.getValue(ApolloPropertyKey.APP_ID);
env = props.getValue(ApolloPropertyKey.ENV);
clusterName = props.getValue(ApolloPropertyKey.CLUSTER_NAME);
administrator = props.getValue(ApolloPropertyKey.ADMINISTRATOR);
String apolloToken = props.getValue(ApolloPropertyKey.TOKEN);
String portalUrl = props.getValue(ApolloPropertyKey.PORTAL_URL);
Integer connectTimeout = props.getValue(ApolloPropertyKey.CONNECT_TIMEOUT);
Integer readTimeout = props.getValue(ApolloPropertyKey.READ_TIMEOUT);
client = ApolloOpenApiClient.newBuilder().withPortalUrl(portalUrl).withConnectTimeout(connectTimeout).withReadTimeout(readTimeout).withToken(apolloToken).build();
}
......
......@@ -67,12 +67,12 @@ public final class ApolloCenterRepositoryTest {
CenterConfiguration configuration = new CenterConfiguration("apollo", new Properties());
configuration.setServerLists("http://config-service-url");
configuration.setNamespace("orchestration");
Properties properties = new Properties();
properties.setProperty(ApolloPropertyKey.PORTAL_URL.getKey(), PORTAL_URL);
properties.setProperty(ApolloPropertyKey.TOKEN.getKey(), TOKEN);
REPOSITORY.setProperties(properties);
Properties props = new Properties();
props.setProperty(ApolloPropertyKey.PORTAL_URL.getKey(), PORTAL_URL);
props.setProperty(ApolloPropertyKey.TOKEN.getKey(), TOKEN);
REPOSITORY.setProps(props);
REPOSITORY.init(configuration);
ApolloConfigWrapper configWrapper = new ApolloConfigWrapper(configuration, new ApolloProperties(properties));
ApolloConfigWrapper configWrapper = new ApolloConfigWrapper(configuration, new ApolloProperties(props));
FieldSetter.setField(REPOSITORY, ApolloCenterRepository.class.getDeclaredField("configWrapper"), configWrapper);
FieldSetter.setField(REPOSITORY, ApolloCenterRepository.class.getDeclaredField("openApiWrapper"), OPEN_API_WRAPPER);
}
......
......@@ -54,8 +54,7 @@ public final class ApolloConfigWrapperTest {
CenterConfiguration configuration = new CenterConfiguration("apollo", new Properties());
configuration.setServerLists("http://config-service-url");
configuration.setNamespace("orchestration");
Properties properties = new Properties();
configWrapper = new ApolloConfigWrapper(configuration, new ApolloProperties(properties));
configWrapper = new ApolloConfigWrapper(configuration, new ApolloProperties(new Properties()));
}
@Test
......
......@@ -61,10 +61,10 @@ public final class ApolloOpenApiWrapperTest {
@SneakyThrows({NoSuchFieldException.class, SecurityException.class})
@Before
public void setUp() {
Properties properties = new Properties();
properties.setProperty(ApolloPropertyKey.PORTAL_URL.getKey(), PORTAL_URL);
properties.setProperty(ApolloPropertyKey.TOKEN.getKey(), TOKEN);
apolloOpenApiWrapper = new ApolloOpenApiWrapper(new CenterConfiguration("apollo", new Properties()), new ApolloProperties(properties));
Properties props = new Properties();
props.setProperty(ApolloPropertyKey.PORTAL_URL.getKey(), PORTAL_URL);
props.setProperty(ApolloPropertyKey.TOKEN.getKey(), TOKEN);
apolloOpenApiWrapper = new ApolloOpenApiWrapper(new CenterConfiguration("apollo", new Properties()), new ApolloProperties(props));
FieldSetter.setField(apolloOpenApiWrapper, ApolloOpenApiWrapper.class.getDeclaredField("client"), client);
FieldSetter.setField(apolloOpenApiWrapper, ApolloOpenApiWrapper.class.getDeclaredField("namespace"), NAME_SPACE);
FieldSetter.setField(apolloOpenApiWrapper, ApolloOpenApiWrapper.class.getDeclaredField("appId"), ApolloPropertyKey.APP_ID.getDefaultValue());
......
......@@ -33,7 +33,7 @@ public final class CenterRepositoryConfigurationYamlSwapper implements YamlSwapp
result.setInstanceType(configuration.getType());
result.setServerLists(configuration.getServerLists());
result.setNamespace(configuration.getNamespace());
result.setProps(configuration.getProperties());
result.setProps(configuration.getProps());
return result;
}
......
......@@ -17,9 +17,10 @@
package org.apache.shardingsphere.orchestration.center.yaml.config;
import java.util.Properties;
import org.junit.Test;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
......@@ -58,10 +59,10 @@ public class YamlCenterRepositoryConfigurationTest {
}
@Test
public void assertProperties() {
Properties properties = new Properties();
public void assertGetProps() {
Properties props = new Properties();
YamlCenterRepositoryConfiguration yamlInstanceConfiguration = new YamlCenterRepositoryConfiguration();
yamlInstanceConfiguration.setProps(properties);
assertThat(yamlInstanceConfiguration.getProps(), is(properties));
yamlInstanceConfiguration.setProps(props);
assertThat(yamlInstanceConfiguration.getProps(), is(props));
}
}
......@@ -17,11 +17,12 @@
package org.apache.shardingsphere.orchestration.center.yaml.swapper;
import java.util.Properties;
import org.apache.shardingsphere.orchestration.center.yaml.config.YamlCenterRepositoryConfiguration;
import org.apache.shardingsphere.orchestration.center.config.CenterConfiguration;
import org.apache.shardingsphere.orchestration.center.yaml.config.YamlCenterRepositoryConfiguration;
import org.junit.Test;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
......@@ -35,7 +36,7 @@ public class CenterRepositoryConfigurationYamlSwapperTest {
assertThat(yamlConfiguration.getInstanceType(), is(configuration.getType()));
assertThat(yamlConfiguration.getServerLists(), is(configuration.getServerLists()));
assertThat(yamlConfiguration.getNamespace(), is(configuration.getNamespace()));
assertThat(yamlConfiguration.getProps(), is(configuration.getProperties()));
assertThat(yamlConfiguration.getProps(), is(configuration.getProps()));
}
private CenterConfiguration getConfiguration() {
......@@ -54,7 +55,7 @@ public class CenterRepositoryConfigurationYamlSwapperTest {
assertThat(instanceConfiguration.getType(), is(yamlConfiguration.getInstanceType()));
assertThat(instanceConfiguration.getServerLists(), is(yamlConfiguration.getServerLists()));
assertThat(instanceConfiguration.getNamespace(), is(yamlConfiguration.getNamespace()));
assertThat(instanceConfiguration.getProperties(), is(yamlConfiguration.getProps()));
assertThat(instanceConfiguration.getProps(), is(yamlConfiguration.getProps()));
}
private YamlCenterRepositoryConfiguration getYamlInstanceConfiguration() {
......
......@@ -40,16 +40,11 @@ public final class OrchestrationConfigurationYamlSwapperTest {
YamlOrchestrationConfiguration result = new OrchestrationConfigurationYamlSwapper().swap(data);
for (String each : result.getCenterRepositoryConfigurationMap().keySet()) {
assertNotNull(result.getCenterRepositoryConfigurationMap().get(each));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getOrchestrationType(),
is(data.getInstanceConfigurationMap().get(each).getOrchestrationType()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getInstanceType(),
is(data.getInstanceConfigurationMap().get(each).getType()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getNamespace(),
is(data.getInstanceConfigurationMap().get(each).getNamespace()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getServerLists(),
is(data.getInstanceConfigurationMap().get(each).getServerLists()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getProps(),
is(data.getInstanceConfigurationMap().get(each).getProperties()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getOrchestrationType(), is(data.getInstanceConfigurationMap().get(each).getOrchestrationType()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getInstanceType(), is(data.getInstanceConfigurationMap().get(each).getType()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getNamespace(), is(data.getInstanceConfigurationMap().get(each).getNamespace()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getServerLists(), is(data.getInstanceConfigurationMap().get(each).getServerLists()));
assertThat(result.getCenterRepositoryConfigurationMap().get(each).getProps(), is(data.getInstanceConfigurationMap().get(each).getProps()));
}
}
......@@ -59,16 +54,11 @@ public final class OrchestrationConfigurationYamlSwapperTest {
OrchestrationConfiguration result = new OrchestrationConfigurationYamlSwapper().swap(data);
for (String each : result.getInstanceConfigurationMap().keySet()) {
assertNotNull(result.getInstanceConfigurationMap().get(each));
assertThat(result.getInstanceConfigurationMap().get(each).getOrchestrationType(),
is(data.getCenterRepositoryConfigurationMap().get(each).getOrchestrationType()));
assertThat(result.getInstanceConfigurationMap().get(each).getType(),
is(data.getCenterRepositoryConfigurationMap().get(each).getInstanceType()));
assertThat(result.getInstanceConfigurationMap().get(each).getNamespace(),
is(data.getCenterRepositoryConfigurationMap().get(each).getNamespace()));
assertThat(result.getInstanceConfigurationMap().get(each).getServerLists(),
is(data.getCenterRepositoryConfigurationMap().get(each).getServerLists()));
assertThat(result.getInstanceConfigurationMap().get(each).getProperties(),
is(data.getCenterRepositoryConfigurationMap().get(each).getProps()));
assertThat(result.getInstanceConfigurationMap().get(each).getOrchestrationType(), is(data.getCenterRepositoryConfigurationMap().get(each).getOrchestrationType()));
assertThat(result.getInstanceConfigurationMap().get(each).getType(), is(data.getCenterRepositoryConfigurationMap().get(each).getInstanceType()));
assertThat(result.getInstanceConfigurationMap().get(each).getNamespace(), is(data.getCenterRepositoryConfigurationMap().get(each).getNamespace()));
assertThat(result.getInstanceConfigurationMap().get(each).getServerLists(), is(data.getCenterRepositoryConfigurationMap().get(each).getServerLists()));
assertThat(result.getInstanceConfigurationMap().get(each).getProps(), is(data.getCenterRepositoryConfigurationMap().get(each).getProps()));
}
}
......
......@@ -51,13 +51,13 @@ public final class EtcdCenterRepository implements ConfigCenterRepository, Regis
@Getter
@Setter
private Properties properties;
private Properties props = new Properties();
private EtcdProperties etcdProperties;
@Override
public void init(final CenterConfiguration config) {
this.etcdProperties = new EtcdProperties(this.properties);
this.etcdProperties = new EtcdProperties(props);
client = Client.builder().endpoints(Util.toURIs(Splitter.on(",").trimResults().splitToList(config.getServerLists()))).build();
}
......
......@@ -225,9 +225,9 @@ public final class EtcdCenterRepositoryTest {
public void assertProperties() {
CenterConfiguration configuration = new CenterConfiguration(CENTER_TYPE, new Properties());
configuration.setServerLists("127.0.0.1");
Properties properties = new Properties();
centerRepository.setProperties(properties);
assertThat(centerRepository.getProperties(), is(properties));
Properties props = new Properties();
centerRepository.setProps(props);
assertThat(centerRepository.getProps(), is(props));
}
@Test
......
......@@ -47,7 +47,7 @@ public final class NacosCenterRepository implements ConfigCenterRepository {
@Getter
@Setter
private Properties properties = new Properties();
private Properties props = new Properties();
/**
* Initialize nacos instance.
......@@ -57,11 +57,11 @@ public final class NacosCenterRepository implements ConfigCenterRepository {
@Override
public void init(final CenterConfiguration config) {
try {
nacosProperties = new NacosProperties(properties);
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, config.getServerLists());
properties.put(PropertyKeyConst.NAMESPACE, null == config.getNamespace() ? "" : config.getNamespace());
configService = NacosFactory.createConfigService(properties);
nacosProperties = new NacosProperties(props);
Properties props = new Properties();
props.put(PropertyKeyConst.SERVER_ADDR, config.getServerLists());
props.put(PropertyKeyConst.NAMESPACE, null == config.getNamespace() ? "" : config.getNamespace());
configService = NacosFactory.createConfigService(props);
} catch (final NacosException ex) {
log.error("Init nacos config center exception for: {}", ex.toString());
}
......
......@@ -57,10 +57,10 @@ public final class NacosCenterRepositoryTest {
@Before
public void init() {
Properties properties = new Properties();
properties.setProperty("group", group);
properties.setProperty("timeout", "3000");
CenterConfiguration configuration = new CenterConfiguration(REPOSITORY.getType(), properties);
Properties props = new Properties();
props.setProperty("group", group);
props.setProperty("timeout", "3000");
CenterConfiguration configuration = new CenterConfiguration(REPOSITORY.getType(), props);
configuration.setServerLists("127.0.0.1:8848");
REPOSITORY.init(configuration);
setConfigService(configService);
......@@ -176,10 +176,10 @@ public final class NacosCenterRepositoryTest {
}
@Test
public void assertProperties() {
Properties properties = new Properties();
REPOSITORY.setProperties(properties);
assertThat(REPOSITORY.getProperties(), is(properties));
public void assertProps() {
Properties props = new Properties();
REPOSITORY.setProps(props);
assertThat(REPOSITORY.getProps(), is(props));
}
@Test
......
......@@ -59,11 +59,11 @@ public final class CuratorZookeeperCenterRepository implements ConfigCenterRepos
@Getter
@Setter
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public void init(final CenterConfiguration config) {
ZookeeperProperties zookeeperProperties = new ZookeeperProperties(properties);
ZookeeperProperties zookeeperProperties = new ZookeeperProperties(props);
client = buildCuratorClient(config, zookeeperProperties);
initCuratorClient(zookeeperProperties);
}
......
......@@ -26,7 +26,7 @@ import java.util.Properties;
*/
public final class ZookeeperProperties extends TypedProperties<ZookeeperPropertyKey> {
public ZookeeperProperties(final Properties properties) {
super(ZookeeperPropertyKey.class, properties);
public ZookeeperProperties(final Properties props) {
super(ZookeeperPropertyKey.class, props);
}
}
......@@ -83,7 +83,7 @@ public final class CuratorZookeeperCenterRepositoryTest {
public void assertWatchUpdatedChangedType() throws Exception {
REPOSITORY.persist("/test/children_updated/1", "value1");
AtomicReference<DataChangedEvent> dataChangedEventActual = new AtomicReference<>();
REPOSITORY.watch("/test/children_updated", dataChangedEvent -> dataChangedEventActual.set(dataChangedEvent));
REPOSITORY.watch("/test/children_updated", dataChangedEventActual::set);
REPOSITORY.persist("/test/children_updated/1", "value2");
Thread.sleep(50L);
DataChangedEvent dataChangedEvent = dataChangedEventActual.get();
......@@ -101,7 +101,7 @@ public final class CuratorZookeeperCenterRepositoryTest {
field.setAccessible(true);
CuratorFramework client = (CuratorFramework) field.get(REPOSITORY);
AtomicReference<DataChangedEvent> dataChangedEventActual = new AtomicReference<>();
REPOSITORY.watch("/test/children_deleted/5", dataChangedEvent -> dataChangedEventActual.set(dataChangedEvent));
REPOSITORY.watch("/test/children_deleted/5", dataChangedEventActual::set);
client.delete().forPath("/test/children_deleted/5");
Thread.sleep(50L);
DataChangedEvent dataChangedEvent = dataChangedEventActual.get();
......@@ -132,19 +132,19 @@ public final class CuratorZookeeperCenterRepositoryTest {
@Test
public void assertBuildCuratorClientWithCustomConfig() {
final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository();
Properties properties = new Properties();
properties.setProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey(), "1000");
properties.setProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey(), "1");
properties.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "1000");
properties.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "1000");
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey(), "1000");
props.setProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey(), "1");
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "1000");
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "1000");
CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties());
configuration.setServerLists(serverLists);
customCenterRepository.setProperties(properties);
customCenterRepository.setProps(props);
customCenterRepository.init(configuration);
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey()), is("1000"));
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey()), is("1"));
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey()), is("1000"));
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("1000"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey()), is("1000"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey()), is("1"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey()), is("1000"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("1000"));
customCenterRepository.persist("/test/children/build/1", "value1");
assertThat(customCenterRepository.get("/test/children/build/1"), is("value1"));
}
......@@ -152,13 +152,13 @@ public final class CuratorZookeeperCenterRepositoryTest {
@Test
public void assertBuildCuratorClientWithTimeToLiveSecondsEqualsZero() {
final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository();
Properties properties = new Properties();
properties.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "0");
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "0");
CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties());
configuration.setServerLists(serverLists);
customCenterRepository.setProperties(properties);
customCenterRepository.setProps(props);
customCenterRepository.init(configuration);
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey()), is("0"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey()), is("0"));
customCenterRepository.persist("/test/children/build/2", "value1");
assertThat(customCenterRepository.get("/test/children/build/2"), is("value1"));
}
......@@ -166,13 +166,13 @@ public final class CuratorZookeeperCenterRepositoryTest {
@Test
public void assertBuildCuratorClientWithOperationTimeoutMillisecondsEqualsZero() {
final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository();
Properties properties = new Properties();
properties.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0");
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0");
CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties());
configuration.setServerLists(serverLists);
customCenterRepository.setProperties(properties);
customCenterRepository.setProps(props);
customCenterRepository.init(configuration);
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("0"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("0"));
customCenterRepository.persist("/test/children/build/3", "value1");
assertThat(customCenterRepository.get("/test/children/build/3"), is("value1"));
}
......@@ -180,13 +180,13 @@ public final class CuratorZookeeperCenterRepositoryTest {
@Test
public void assertBuildCuratorClientWithDigest() {
final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository();
Properties properties = new Properties();
properties.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "any");
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "any");
CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties());
configuration.setServerLists(serverLists);
customCenterRepository.setProperties(properties);
customCenterRepository.setProps(props);
customCenterRepository.init(configuration);
assertThat(customCenterRepository.getProperties().getProperty(ZookeeperPropertyKey.DIGEST.getKey()), is("any"));
assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.DIGEST.getKey()), is("any"));
customCenterRepository.persist("/test/children/build/4", "value1");
assertThat(customCenterRepository.get("/test/children/build/4"), is("value1"));
}
......@@ -201,19 +201,18 @@ public final class CuratorZookeeperCenterRepositoryTest {
assertNull(REPOSITORY.get("/test/children/1"));
assertNull(REPOSITORY.get("/test/children/2"));
}
@Test
public void assertZKCloseAndException() {
final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository();
CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties());
Properties properties = new Properties();
properties.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "digest");
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "digest");
configuration.setServerLists(serverLists);
customCenterRepository.setProperties(properties);
customCenterRepository.setProps(props);
customCenterRepository.init(configuration);
customCenterRepository.close();
try {
customCenterRepository.get("/test/children/1");
fail("must be failed after close.");
......@@ -222,7 +221,7 @@ public final class CuratorZookeeperCenterRepositoryTest {
// CHECKSTYLE:ON
Assert.assertTrue(ex instanceof OrchestrationException);
}
try {
customCenterRepository.persist("/test/children/01", "value1");
fail("must be failed after close.");
......@@ -231,7 +230,7 @@ public final class CuratorZookeeperCenterRepositoryTest {
// CHECKSTYLE:ON
Assert.assertTrue(ex instanceof OrchestrationException);
}
try {
customCenterRepository.delete("/test/children/02");
fail("must be failed after close.");
......@@ -240,7 +239,7 @@ public final class CuratorZookeeperCenterRepositoryTest {
// CHECKSTYLE:ON
Assert.assertTrue(ex instanceof OrchestrationException);
}
try {
customCenterRepository.persistEphemeral("/test/children/03", "value1");
fail("must be failed after close.");
......@@ -249,7 +248,7 @@ public final class CuratorZookeeperCenterRepositoryTest {
// CHECKSTYLE:ON
Assert.assertTrue(ex instanceof OrchestrationException);
}
try {
customCenterRepository.getChildrenKeys("/test/children");
fail("must be failed after close.");
......
......@@ -28,13 +28,13 @@ public final class ZookeeperPropertiesTest {
@Test
public void assertGetValue() {
Properties properties = new Properties();
properties.setProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey(), "3000");
properties.setProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey(), "2");
properties.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "600");
properties.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "6000");
properties.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "any");
ZookeeperProperties actual = new ZookeeperProperties(properties);
Properties props = new Properties();
props.setProperty(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS.getKey(), "3000");
props.setProperty(ZookeeperPropertyKey.MAX_RETRIES.getKey(), "2");
props.setProperty(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS.getKey(), "600");
props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "6000");
props.setProperty(ZookeeperPropertyKey.DIGEST.getKey(), "any");
ZookeeperProperties actual = new ZookeeperProperties(props);
assertThat(actual.getValue(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS), is(3000));
assertThat(actual.getValue(ZookeeperPropertyKey.MAX_RETRIES), is(2));
assertThat(actual.getValue(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS), is(600));
......@@ -44,8 +44,8 @@ public final class ZookeeperPropertiesTest {
@Test
public void assertGetDefaultValue() {
Properties properties = new Properties();
ZookeeperProperties actual = new ZookeeperProperties(properties);
Properties props = new Properties();
ZookeeperProperties actual = new ZookeeperProperties(props);
assertThat(actual.getValue(ZookeeperPropertyKey.RETRY_INTERVAL_MILLISECONDS), is(500));
assertThat(actual.getValue(ZookeeperPropertyKey.MAX_RETRIES), is(3));
assertThat(actual.getValue(ZookeeperPropertyKey.TIME_TO_LIVE_SECONDS), is(60));
......
......@@ -66,13 +66,13 @@ public final class ConfigCenterTest {
private static final String DATA_SOURCE_YAML = ""
+ "ds_0: !!" + YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+ " properties:\n"
+ " props:\n"
+ " driverClassName: com.mysql.jdbc.Driver\n"
+ " url: jdbc:mysql://localhost:3306/ds_0\n"
+ " username: root\n" + " password: root\n"
+ "ds_1: !!" + YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+ " properties:\n"
+ " props:\n"
+ " driverClassName: com.mysql.jdbc.Driver\n"
+ " url: jdbc:mysql://localhost:3306/ds_1\n"
+ " username: root\n"
......@@ -193,7 +193,7 @@ public final class ConfigCenterTest {
private static final String DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQLS = ""
+ "ds_0: !!" + YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+ " properties:\n"
+ " props:\n"
+ " driverClassName: com.mysql.jdbc.Driver\n"
+ " url: jdbc:mysql://localhost:3306/ds_0\n"
+ " username: root\n"
......@@ -203,7 +203,7 @@ public final class ConfigCenterTest {
+ " - set names utf8;\n"
+ "ds_1: !!" + YamlDataSourceConfiguration.class.getName() + "\n"
+ " dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+ " properties:\n"
+ " props:\n"
+ " driverClassName: com.mysql.jdbc.Driver\n"
+ " url: jdbc:mysql://localhost:3306/ds_1\n"
+ " username: root\n"
......@@ -451,9 +451,9 @@ public final class ConfigCenterTest {
private void assertDataSourceConfiguration(final DataSourceConfiguration actual, final DataSourceConfiguration expected) {
assertThat(actual.getDataSourceClassName(), is(expected.getDataSourceClassName()));
assertThat(actual.getProperties().get("url"), is(expected.getProperties().get("url")));
assertThat(actual.getProperties().get("username"), is(expected.getProperties().get("username")));
assertThat(actual.getProperties().get("password"), is(expected.getProperties().get("password")));
assertThat(actual.getProps().get("url"), is(expected.getProps().get("url")));
assertThat(actual.getProps().get("username"), is(expected.getProps().get("username")));
assertThat(actual.getProps().get("password"), is(expected.getProps().get("password")));
}
@Test
......@@ -472,7 +472,7 @@ public final class ConfigCenterTest {
assertThat(encryptRuleConfiguration.getEncryptors().size(), is(2));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = encryptRuleConfiguration.getEncryptors().get("aes_encryptor");
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
assertThat(encryptAlgorithmConfiguration.getProperties().get("aes.key.value").toString(), is("123456abcd"));
assertThat(encryptAlgorithmConfiguration.getProps().get("aes.key.value").toString(), is("123456abcd"));
}
}
}
......@@ -507,7 +507,7 @@ public final class ConfigCenterTest {
assertThat(actual.getEncryptors().size(), is(1));
EncryptAlgorithmConfiguration encryptAlgorithmConfiguration = actual.getEncryptors().get("order_encryptor");
assertThat(encryptAlgorithmConfiguration.getType(), is("AES"));
assertThat(encryptAlgorithmConfiguration.getProperties().get("aes.key.value").toString(), is("123456"));
assertThat(encryptAlgorithmConfiguration.getProps().get("aes.key.value").toString(), is("123456"));
}
@Test
......@@ -581,9 +581,9 @@ public final class ConfigCenterTest {
private void assertDataSourceConfigurationWithConnectionInitSqls(final DataSourceConfiguration actual, final DataSourceConfiguration expected) {
assertThat(actual.getDataSourceClassName(), is(expected.getDataSourceClassName()));
assertThat(actual.getProperties().get("url"), is(expected.getProperties().get("url")));
assertThat(actual.getProperties().get("username"), is(expected.getProperties().get("username")));
assertThat(actual.getProperties().get("password"), is(expected.getProperties().get("password")));
assertThat(actual.getProperties().get("connectionInitSqls"), is(expected.getProperties().get("connectionInitSqls")));
assertThat(actual.getProps().get("url"), is(expected.getProps().get("url")));
assertThat(actual.getProps().get("username"), is(expected.getProps().get("username")));
assertThat(actual.getProps().get("password"), is(expected.getProps().get("password")));
assertThat(actual.getProps().get("connectionInitSqls"), is(expected.getProps().get("connectionInitSqls")));
}
}
......@@ -27,11 +27,11 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
@Getter
@Setter
public final class FirstTestConfigCenterRepository implements ConfigCenterRepository {
@Getter
@Setter
private Properties properties = new Properties();
private Properties props = new Properties();
@Override
public void init(final CenterConfiguration config) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册