提交 953682de 编写于 作者: T tristaZero

add worker.id setting

上级 9f2f2ee1
......@@ -49,6 +49,7 @@ public final class SnowflakeShardingKeyGeneratorTest {
ExecutorService executor = Executors.newFixedThreadPool(threadNumber);
int taskNumber = threadNumber << 2;
final SnowflakeShardingKeyGenerator keyGenerator = new SnowflakeShardingKeyGenerator();
keyGenerator.setProperties(new Properties());
Set<Comparable<?>> actual = new HashSet<>();
for (int i = 0; i < taskNumber; i++) {
......
......@@ -81,6 +81,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: order_id
props:
worker.id: 123
logicIndex: order_index
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
......
......@@ -42,6 +42,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: order_id
props:
worker.id: 123
logicIndex: order_index
t_encrypt:
actualDataNodes: ds_${0..1}.t_encrypt_${0..1}
......@@ -56,6 +58,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: order_id
props:
worker.id: 123
t_encrypt_query:
actualDataNodes: ds_${0..1}.t_encrypt_query${0..1}
databaseStrategy:
......@@ -69,6 +73,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: order_id
props:
worker.id: 123
encryptRule:
encryptors:
t_encryptor:
......
......@@ -45,6 +45,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: item_id
props:
worker.id: 123
t_place:
actualDataNodes: db${0..1}.t_place
tableStrategy:
......
......@@ -34,6 +34,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: id
props:
worker.id: 123
logicIndex: logic_index
table_y:
actualDataNodes: db${0..1}.table_y
......@@ -47,6 +49,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: id
props:
worker.id: 123
bindingTables:
- table_x, table_y
encryptRule:
......
......@@ -42,6 +42,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: order_id
props:
worker.id: 123
t_order_item:
actualDataNodes: ds_ms.t_order_item_${0..1}
tableStrategy:
......@@ -51,6 +53,8 @@ shardingRule:
keyGenerator:
type: SNOWFLAKE
column: order_item_id
props:
worker.id: 123
bindingTables:
- t_order,t_order_item
masterSlaveRules:
......
......@@ -37,7 +37,7 @@ public final class RegistryCenterServiceLoader extends TypeBasedSPIServiceLoader
NewInstanceServiceLoader.register(RegistryCenter.class);
}
RegistryCenterServiceLoader() {
public RegistryCenterServiceLoader() {
super(RegistryCenter.class);
}
......
......@@ -45,11 +45,13 @@ spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-col
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_${order_id % 2}
spring.shardingsphere.sharding.tables.t_order.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id
spring.shardingsphere.sharding.tables.t_order.key-generator.props.worker.id=123
spring.shardingsphere.sharding.tables.t_order_item.actual-data-nodes=ds_${0..1}.t_order_item_${0..1}
spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.sharding-column=order_id
spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression=t_order_item_${order_id % 2}
spring.shardingsphere.sharding.tables.t_order_item.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.t_order_item.key-generator.column=order_item_id
spring.shardingsphere.sharding.tables.t_order_item.key-generator.props.worker.id=123
spring.shardingsphere.sharding.binding-tables=t_order,t_order_item
spring.shardingsphere.sharding.broadcast-tables=t_config
......
......@@ -45,11 +45,13 @@ spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-col
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_${order_id % 2}
spring.shardingsphere.sharding.tables.t_order.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id
spring.shardingsphere.sharding.tables.t_order.key-generator.props.worker.id=123
spring.shardingsphere.sharding.tables.t_order_item.actual-data-nodes=ds_${0..1}.t_order_item_${0..1}
spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.sharding-column=order_id
spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression=t_order_item_${order_id % 2}
spring.shardingsphere.sharding.tables.t_order_item.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.t_order_item.key-generator.column=order_item_id
spring.shardingsphere.sharding.tables.t_order_item.key-generator.props.worker.id=123
spring.shardingsphere.sharding.binding-tables=t_order,t_order_item
spring.shardingsphere.sharding.broadcast-tables=t_config
spring.shardingsphere.sharding.encryptRule.encryptors.order_encrypt.qualifiedColumns=t_order.pwd1,t_order.pwd2
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册