You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/05/07 16:13:39 UTC
[shardingsphere] branch master updated: Remove `incremental-task-idle-minute-threshold` config item from IdleRuleAlteredJobCompletionDetectAlgorithm (#17430)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 47640f39b94 Remove `incremental-task-idle-minute-threshold` config item from IdleRuleAlteredJobCompletionDetectAlgorithm (#17430)
47640f39b94 is described below
commit 47640f39b94b3d664d7bf6a7a8e2c39b197f1d5e
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 8 00:13:33 2022 +0800
Remove `incremental-task-idle-minute-threshold` config item from IdleRuleAlteredJobCompletionDetectAlgorithm (#17430)
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
* Refactor IdleRuleAlteredJobCompletionDetectAlgorithm
---
.../syntax/rdl/rule-definition/sharding.cn.md | 2 +-
.../syntax/rdl/rule-definition/sharding.en.md | 2 +-
.../distsql/syntax/rql/rule-query/sharding.cn.md | 2 +-
.../distsql/syntax/rql/rule-query/sharding.en.md | 2 +-
.../user-manual/shardingsphere-scaling/build.cn.md | 6 +-
.../user-manual/shardingsphere-scaling/build.en.md | 6 +-
.../shardingsphere-proxy/conf/config-sharding.yaml | 2 +-
.../DatabaseDiscoveryProviderAlgorithmFactory.java | 4 +-
.../encrypt/factory/EncryptAlgorithmFactory.java | 4 +-
.../resources/yaml/encrypt-dataConverters.yaml | 2 +-
.../ReplicaLoadBalanceAlgorithmFactory.java | 4 +-
.../shadow/factory/ShadowAlgorithmFactory.java | 4 +-
.../factory/KeyGenerateAlgorithmFactory.java | 4 +-
.../sharding/factory/ShardingAlgorithmFactory.java | 4 +-
.../src/test/resources/yaml/sharding-rule.yaml | 2 +-
.../src/test/resources/yaml/sharding-scaling.yaml | 2 +-
.../ShardingScalingRulesQueryResultSetTest.java | 4 +-
...eAlteredActionConfigurationYamlSwapperTest.java | 2 +-
.../api/task/progress/IncrementalTaskProgress.java | 4 -
.../JobCompletionDetectAlgorithmFactory.java | 4 +-
.../channel/PipelineChannelCreatorFactory.java | 4 +-
.../ratelimit/JobRateLimitAlgorithmFactory.java | 4 +-
...dleRuleAlteredJobCompletionDetectAlgorithm.java | 32 ++++----
.../traffic/factory/TrafficAlgorithmFactory.java | 4 +-
.../TrafficLoadBalanceAlgorithmFactory.java | 4 +-
.../resources/conf/import/config-sharding.yaml | 2 +-
.../src/main/resources/conf/config-sharding.yaml | 4 +-
.../spi/type/typed/TypedSPIRegistry.java | 4 +-
.../impl/OracleDDLStatementSQLVisitor.java | 2 +-
.../src/main/resources/case/rdl/create.xml | 32 ++++----
.../main/resources/sql/supported/rdl/create.xml | 4 +-
...uleAlteredJobCompletionDetectAlgorithmTest.java | 86 +++++++---------------
32 files changed, 95 insertions(+), 153 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
index 1878481f7af..54bf8d35017 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
@@ -300,7 +300,7 @@ OUTPUT(
BATCH_SIZE=1000
),
STREAM_CHANNEL(TYPE(NAME=MEMORY, PROPERTIES("block-queue-size"=10000))),
-COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-minute-threshold"=30))),
+COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-seconds-threshold"=1800))),
DATA_CONSISTENCY_CHECKER(TYPE(NAME=DATA_MATCH, PROPERTIES("chunk-size"=1000)))
);
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
index aa5dcc63a30..2fb5d0893be 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
@@ -298,7 +298,7 @@ OUTPUT(
BATCH_SIZE=1000
),
STREAM_CHANNEL(TYPE(NAME=MEMORY, PROPERTIES("block-queue-size"=10000))),
-COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-minute-threshold"=30))),
+COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-seconds-threshold"=1800))),
DATA_CONSISTENCY_CHECKER(TYPE(NAME=DATA_MATCH, PROPERTIES("chunk-size"=1000)))
);
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
index ddb8d3b32da..89bc2fdb3f8 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
@@ -285,7 +285,7 @@ mysql> SHOW SHARDING SCALING RULES;
+------------------+----------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+--------------------------------------------------------+-------------------------------------------------------------------------+-----------------------------------------------------+
| name | input | output | stream_channel | completion_detector | data_consistency_checker |
+------------------+----------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+--------------------------------------------------------+-------------------------------------------------------------------------+-----------------------------------------------------+
-| sharding_scaling | {"workerThread":40,"batchSize":1000} | {"workerThread":40,"batchSize":1000} | {"type":"MEMORY","props":{"block-queue-size":"10000"}} | {"type":"IDLE","props":{"incremental-task-idle-minute-threshold":"30"}} | {"type":"DATA_MATCH","props":{"chunk-size":"1000"}} |
+| sharding_scaling | {"workerThread":40,"batchSize":1000} | {"workerThread":40,"batchSize":1000} | {"type":"MEMORY","props":{"block-queue-size":"10000"}} | {"type":"IDLE","props":{"incremental-task-idle-seconds-threshold":"1800"}} | {"type":"DATA_MATCH","props":{"chunk-size":"1000"}} |
+------------------+----------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+--------------------------------------------------------+-------------------------------------------------------------------------+-----------------------------------------------------+
1 row in set (0.00 sec)
```
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
index ec0c724e395..5c7bfef54c8 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
@@ -285,7 +285,7 @@ mysql> SHOW SHARDING SCALING RULES;
+------------------+----------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+--------------------------------------------------------+-------------------------------------------------------------------------+-----------------------------------------------------+
| name | input | output | stream_channel | completion_detector | data_consistency_checker |
+------------------+----------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+--------------------------------------------------------+-------------------------------------------------------------------------+-----------------------------------------------------+
-| sharding_scaling | {"workerThread":40,"batchSize":1000} | {"workerThread":40,"batchSize":1000} | {"type":"MEMORY","props":{"block-queue-size":"10000"}} | {"type":"IDLE","props":{"incremental-task-idle-minute-threshold":"30"}} | {"type":"DATA_MATCH","props":{"chunk-size":"1000"}} |
+| sharding_scaling | {"workerThread":40,"batchSize":1000} | {"workerThread":40,"batchSize":1000} | {"type":"MEMORY","props":{"block-queue-size":"10000"}} | {"type":"IDLE","props":{"incremental-task-idle-seconds-threshold":"1800"}} | {"type":"DATA_MATCH","props":{"chunk-size":"1000"}} |
+------------------+----------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+--------------------------------------------------------+-------------------------------------------------------------------------+-----------------------------------------------------+
1 row in set (0.00 sec)
```
diff --git a/docs/document/content/user-manual/shardingsphere-scaling/build.cn.md b/docs/document/content/user-manual/shardingsphere-scaling/build.cn.md
index 51b685095eb..5de5f3d2a48 100644
--- a/docs/document/content/user-manual/shardingsphere-scaling/build.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-scaling/build.cn.md
@@ -74,7 +74,7 @@ rules:
completionDetector: # 作业是否接近完成检测算法。如果不配置则无法自动进行后续步骤,可以通过 DistSQL 手动操作。
type: # 算法类型。可选项:IDLE
props: # 算法属性
- incremental-task-idle-minute-threshold: # 如果增量同步任务不再活动超过一定时间,那么可以认为增量同步任务接近完成。适用算法类型:IDLE
+ incremental-task-idle-seconds-threshold: # 如果增量同步任务不再活动超过一定时间,那么可以认为增量同步任务接近完成。适用算法类型:IDLE
dataConsistencyChecker: # 数据一致性校验算法。如果不配置则跳过这个步骤。
type: # 算法类型。可选项:DATA_MATCH, CRC32_MATCH
props: # 算法属性
@@ -107,7 +107,7 @@ rules:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 30
+ incremental-task-idle-seconds-threshold: 1800
dataConsistencyChecker:
type: DATA_MATCH
props:
@@ -153,7 +153,7 @@ OUTPUT(
BATCH_SIZE=1000
),
STREAM_CHANNEL(TYPE(NAME=MEMORY, PROPERTIES("block-queue-size"=10000))),
-COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-minute-threshold"=30))),
+COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-seconds-threshold"=1800))),
DATA_CONSISTENCY_CHECKER(TYPE(NAME=DATA_MATCH, PROPERTIES("chunk-size"=1000)))
);
```
diff --git a/docs/document/content/user-manual/shardingsphere-scaling/build.en.md b/docs/document/content/user-manual/shardingsphere-scaling/build.en.md
index 6e902c4fc99..4feee8d2655 100644
--- a/docs/document/content/user-manual/shardingsphere-scaling/build.en.md
+++ b/docs/document/content/user-manual/shardingsphere-scaling/build.en.md
@@ -73,7 +73,7 @@ rules:
completionDetector: # Completion detect algorithm. If it's not configured, then system won't continue to do next steps automatically.
type: # Algorithm type. Options: IDLE
props: # Algorithm properties
- incremental-task-idle-minute-threshold: # If incremental tasks is idle more than so much minutes, then it could be considered as almost completed. Available for types: IDLE
+ incremental-task-idle-seconds-threshold: # If incremental tasks is idle more than so much seconds, then it could be considered as almost completed. Available for types: IDLE
dataConsistencyChecker: # Data consistency check algorithm. If it's not configured, then system will skip this step.
type: # Algorithm type. Options: DATA_MATCH, CRC32_MATCH
props: # Algorithm properties
@@ -106,7 +106,7 @@ rules:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 30
+ incremental-task-idle-seconds-threshold: 1800
dataConsistencyChecker:
type: DATA_MATCH
props:
@@ -152,7 +152,7 @@ OUTPUT(
BATCH_SIZE=1000
),
STREAM_CHANNEL(TYPE(NAME=MEMORY, PROPERTIES("block-queue-size"=10000))),
-COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-minute-threshold"=30))),
+COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-seconds-threshold"=1800))),
DATA_CONSISTENCY_CHECKER(TYPE(NAME=DATA_MATCH, PROPERTIES("chunk-size"=1000)))
);
```
diff --git a/shardingsphere-charts/shardingsphere-proxy/conf/config-sharding.yaml b/shardingsphere-charts/shardingsphere-proxy/conf/config-sharding.yaml
index 367a6eabbf7..2f12f2b7dcb 100644
--- a/shardingsphere-charts/shardingsphere-proxy/conf/config-sharding.yaml
+++ b/shardingsphere-charts/shardingsphere-proxy/conf/config-sharding.yaml
@@ -81,7 +81,7 @@ rules:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 30
+ incremental-task-idle-seconds-threshold: 1800
dataConsistencyChecker:
type: DATA_MATCH
props:
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java
index c0c103d2473..4d69b52bf02 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java
@@ -25,8 +25,6 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Database discovery provider algorithm factory.
*/
@@ -54,6 +52,6 @@ public final class DatabaseDiscoveryProviderAlgorithmFactory {
* @return contains database discovery provider algorithm or not
*/
public static boolean contains(final String databaseDiscoveryProviderAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(DatabaseDiscoveryProviderAlgorithm.class, databaseDiscoveryProviderAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(DatabaseDiscoveryProviderAlgorithm.class, databaseDiscoveryProviderAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java
index 88494b2a7e8..4dd7c191cdc 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java
@@ -25,8 +25,6 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Encrypt algorithm factory.
*/
@@ -56,6 +54,6 @@ public final class EncryptAlgorithmFactory {
* @return contains encrypt algorithm or not
*/
public static boolean contains(final String encryptAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(EncryptAlgorithm.class, encryptAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(EncryptAlgorithm.class, encryptAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/resources/yaml/encrypt-dataConverters.yaml b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/resources/yaml/encrypt-dataConverters.yaml
index c474379e0d7..3e2e163afbf 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/resources/yaml/encrypt-dataConverters.yaml
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/resources/yaml/encrypt-dataConverters.yaml
@@ -31,7 +31,7 @@ dataConverters:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 1
+ incremental-task-idle-seconds-threshold: 60
dataConsistencyChecker:
type: DATA_MATCH
props:
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java
index cb69ff5dbf9..39f5054baa6 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java
@@ -26,8 +26,6 @@ import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.required.RequiredSPIRegistry;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Replica load-balance algorithm factory.
*/
@@ -64,6 +62,6 @@ public final class ReplicaLoadBalanceAlgorithmFactory {
* @return contains replica load-balance algorithm or not
*/
public static boolean contains(final String replicaLoadBalanceAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(ReplicaLoadBalanceAlgorithm.class, replicaLoadBalanceAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(ReplicaLoadBalanceAlgorithm.class, replicaLoadBalanceAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java
index 9d810f9956a..e74b0fbbd0e 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java
@@ -25,8 +25,6 @@ import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Shadow algorithm factory.
*/
@@ -54,6 +52,6 @@ public final class ShadowAlgorithmFactory {
* @return contains shadow algorithm or not
*/
public static boolean contains(final String shadowAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(ShadowAlgorithm.class, shadowAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(ShadowAlgorithm.class, shadowAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java
index f46080caf10..a97ba303951 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java
@@ -26,8 +26,6 @@ import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.required.RequiredSPIRegistry;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Key generate algorithm factory.
*/
@@ -64,6 +62,6 @@ public final class KeyGenerateAlgorithmFactory {
* @return contains key generate algorithm or not
*/
public static boolean contains(final String keyGenerateAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(KeyGenerateAlgorithm.class, keyGenerateAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(KeyGenerateAlgorithm.class, keyGenerateAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java
index 6d8d876087b..a48d46348f9 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java
@@ -25,8 +25,6 @@ import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Sharding algorithm factory.
*/
@@ -54,6 +52,6 @@ public final class ShardingAlgorithmFactory {
* @return contains sharding algorithm or not
*/
public static boolean contains(final String shardingAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(ShardingAlgorithm.class, shardingAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(ShardingAlgorithm.class, shardingAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-rule.yaml b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-rule.yaml
index 4c53423fef3..6ea46f2de27 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-rule.yaml
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-rule.yaml
@@ -107,7 +107,7 @@ rules:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 30
+ incremental-task-idle-seconds-threshold: 1800
dataConsistencyChecker:
type: DATA_MATCH
props:
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-scaling.yaml b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-scaling.yaml
index 0af8c08116d..8cb794a0eca 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-scaling.yaml
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/sharding-scaling.yaml
@@ -31,7 +31,7 @@ scaling:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 30
+ incremental-task-idle-seconds-threshold: 1800
dataConsistencyChecker:
type: DATA_MATCH
props:
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java
index 2443c5d4ebf..b6dcfaa81e0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java
@@ -59,7 +59,7 @@ public final class ShardingScalingRulesQueryResultSetTest {
assertThat(actual.get(2).toString(), containsString("\"batchSize\":100"));
assertThat(actual.get(2).toString(), containsString("\"rateLimiter\":{\"type\":\"TPS\",\"props\":{\"tps\":\"2000\"}}"));
assertThat(actual.get(3).toString(), containsString("\"type\":\"MEMORY\",\"props\":{\"block-queue-size\":\"10000\"}"));
- assertThat(actual.get(4).toString(), containsString("\"type\":\"IDLE\",\"props\":{\"incremental-task-idle-minute-threshold\":\"30\"}"));
+ assertThat(actual.get(4).toString(), containsString("\"type\":\"IDLE\",\"props\":{\"incremental-task-idle-seconds-threshold\":\"1800\"}"));
assertThat(actual.get(5).toString(), containsString("\"type\":\"DATA_MATCH\",\"props\":{\"chunk-size\":\"1000\"}"));
}
@@ -75,7 +75,7 @@ public final class ShardingScalingRulesQueryResultSetTest {
InputConfiguration inputConfig = createInputConfiguration("QPS", newProperties("qps", "50"));
OutputConfiguration outputConfig = createOutputConfiguration("TPS", newProperties("tps", "2000"));
ShardingSphereAlgorithmConfiguration streamChannel = createAlgorithm("MEMORY", newProperties("block-queue-size", "10000"));
- ShardingSphereAlgorithmConfiguration completionDetector = createAlgorithm("IDLE", newProperties("incremental-task-idle-minute-threshold", "30"));
+ ShardingSphereAlgorithmConfiguration completionDetector = createAlgorithm("IDLE", newProperties("incremental-task-idle-seconds-threshold", "1800"));
ShardingSphereAlgorithmConfiguration dataConsistencyChecker = createAlgorithm("DATA_MATCH", newProperties("chunk-size", "1000"));
return new OnRuleAlteredActionConfiguration(inputConfig, outputConfig, streamChannel, completionDetector, dataConsistencyChecker);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/rulealtered/OnRuleAlteredActionConfigurationYamlSwapperTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/rulealtered/OnRuleAlteredActionConfigurationYamlSwapperTest.java
index e8b0a676711..e5f359d1c65 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/rulealtered/OnRuleAlteredActionConfigurationYamlSwapperTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/rulealtered/OnRuleAlteredActionConfigurationYamlSwapperTest.java
@@ -55,7 +55,7 @@ public final class OnRuleAlteredActionConfigurationYamlSwapperTest {
streamChannelProps.setProperty("block-queue-size", "10000");
yamlConfig.setStreamChannel(new YamlShardingSphereAlgorithmConfiguration("MEMORY", streamChannelProps));
Properties completionDetectorProps = new Properties();
- completionDetectorProps.setProperty("incremental-task-idle-minute-threshold", "30");
+ completionDetectorProps.setProperty("incremental-task-idle-seconds-threshold", "1800");
yamlConfig.setCompletionDetector(new YamlShardingSphereAlgorithmConfiguration("IDLE", completionDetectorProps));
Properties dataConsistencyCheckerProps = new Properties();
dataConsistencyCheckerProps.setProperty("chunk-size", "1000");
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/task/progress/IncrementalTaskProgress.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/task/progress/IncrementalTaskProgress.java
index 8c923d27b68..d8eb199e8e0 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/task/progress/IncrementalTaskProgress.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/task/progress/IncrementalTaskProgress.java
@@ -37,8 +37,4 @@ public final class IncrementalTaskProgress implements TaskProgress {
private volatile IngestPosition<?> position;
private IncrementalTaskDelay incrementalTaskDelay = new IncrementalTaskDelay();
-
- public IncrementalTaskProgress(final IngestPosition<?> position) {
- this.position = position;
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java
index 8caac585975..b50637f5995 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java
@@ -24,8 +24,6 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Job completion detect algorithm factory.
*/
@@ -54,6 +52,6 @@ public final class JobCompletionDetectAlgorithmFactory {
* @return contains job completion detect algorithm or not
*/
public static boolean contains(final String jobCompletionDetectAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(JobCompletionDetectAlgorithm.class, jobCompletionDetectAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(JobCompletionDetectAlgorithm.class, jobCompletionDetectAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java
index 8dbd013edf4..4d01b3fa2c1 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java
@@ -24,8 +24,6 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Pipeline channel creator factory.
*/
@@ -53,6 +51,6 @@ public final class PipelineChannelCreatorFactory {
* @return contains pipeline channel creator or not
*/
public static boolean contains(final String pipelineChannelCreatorType) {
- return TypedSPIRegistry.findRegisteredService(PipelineChannelCreator.class, pipelineChannelCreatorType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(PipelineChannelCreator.class, pipelineChannelCreatorType, null).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java
index 1fcc5f225f3..e65d2396178 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java
@@ -24,8 +24,6 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Properties;
-
/**
* Job rate limit algorithm factory.
*/
@@ -53,6 +51,6 @@ public final class JobRateLimitAlgorithmFactory {
* @return contains job rate limit algorithm or not
*/
public static boolean contains(final String jobRateLimitAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(JobRateLimitAlgorithm.class, jobRateLimitAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(JobRateLimitAlgorithm.class, jobRateLimitAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java
index 7f6601c5dd2..f0dcb8c3483 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/IdleRuleAlteredJobCompletionDetectAlgorithm.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.data.pipeline.scenario.rulealtered.spi;
import com.google.common.base.Preconditions;
import lombok.Getter;
+import lombok.Setter;
import org.apache.shardingsphere.data.pipeline.api.detect.RuleAlteredJobAlmostCompletedParameter;
import org.apache.shardingsphere.data.pipeline.api.ingest.position.FinishedPosition;
import org.apache.shardingsphere.data.pipeline.api.job.progress.JobProgress;
@@ -35,27 +36,25 @@ import java.util.stream.Collectors;
*/
public final class IdleRuleAlteredJobCompletionDetectAlgorithm implements JobCompletionDetectAlgorithm<RuleAlteredJobAlmostCompletedParameter> {
- public static final String IDLE_MINUTE_THRESHOLD_KEY = "incremental-task-idle-minute-threshold";
+ private static final String IDLE_SECOND_THRESHOLD_KEY = "incremental-task-idle-seconds-threshold";
- public static final String IDLE_SECOND_THRESHOLD_KEY = "incremental-task-idle-second-threshold";
-
- public static final long DEFAULT_IDLE_SECOND_THRESHOLD = TimeUnit.MINUTES.toSeconds(30);
+ private static final long DEFAULT_IDLE_SECONDS_THRESHOLD = 1800L;
+ @Getter
+ @Setter
private Properties props;
- @Getter
- private long incrementalTaskIdleSecondThreshold = DEFAULT_IDLE_SECOND_THRESHOLD;
+ private volatile long incrementalTaskIdleSecondsThreshold;
@Override
public void init(final Properties props) {
- this.props = props;
- Preconditions.checkArgument(props.containsKey(IDLE_MINUTE_THRESHOLD_KEY) || props.containsKey(IDLE_SECOND_THRESHOLD_KEY), "incremental task idle threshold can not be null.");
- if (props.containsKey(IDLE_SECOND_THRESHOLD_KEY)) {
- incrementalTaskIdleSecondThreshold = Long.parseLong(props.getProperty(IDLE_SECOND_THRESHOLD_KEY));
- } else {
- incrementalTaskIdleSecondThreshold = TimeUnit.MINUTES.toSeconds(Long.parseLong(props.getProperty(IDLE_MINUTE_THRESHOLD_KEY)));
- }
- Preconditions.checkArgument(incrementalTaskIdleSecondThreshold > 0, "incremental task idle threshold must be positive.");
+ incrementalTaskIdleSecondsThreshold = getIncrementalTaskIdleSecondsThreshold(props);
+ }
+
+ private long getIncrementalTaskIdleSecondsThreshold(final Properties props) {
+ long result = Long.parseLong(props.getOrDefault(IDLE_SECOND_THRESHOLD_KEY, DEFAULT_IDLE_SECONDS_THRESHOLD).toString());
+ Preconditions.checkArgument(result > 0, "Incremental task idle threshold seconds must be positive.");
+ return result;
}
@Override
@@ -69,12 +68,11 @@ public final class IdleRuleAlteredJobCompletionDetectAlgorithm implements JobCom
return false;
}
Collection<Long> incrementalTasksIdleSeconds = getIncrementalTasksIdleSeconds(jobProgresses);
- return incrementalTasksIdleSeconds.stream().allMatch(each -> each >= incrementalTaskIdleSecondThreshold);
+ return incrementalTasksIdleSeconds.stream().allMatch(each -> each >= incrementalTaskIdleSecondsThreshold);
}
private static boolean isAllProgressesFilled(final int jobShardingCount, final Collection<JobProgress> jobProgresses) {
- return jobShardingCount == jobProgresses.size()
- && jobProgresses.stream().allMatch(Objects::nonNull);
+ return jobShardingCount == jobProgresses.size() && jobProgresses.stream().allMatch(Objects::nonNull);
}
private static boolean isAllInventoryTasksCompleted(final Collection<JobProgress> jobProgresses) {
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
index 5cbfb01aa31..80fd3722a43 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
@@ -25,8 +25,6 @@ import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
-import java.util.Properties;
-
/**
* Traffic algorithm factory.
*/
@@ -54,6 +52,6 @@ public final class TrafficAlgorithmFactory {
* @return contains traffic algorithm or not
*/
public static boolean contains(final String trafficAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, trafficAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, trafficAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
index e4f76021536..7b842fe804f 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
@@ -25,8 +25,6 @@ import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
-import java.util.Properties;
-
/**
* Traffic load balance algorithm factory.
*/
@@ -54,6 +52,6 @@ public final class TrafficLoadBalanceAlgorithmFactory {
* @return contains traffic load balance algorithm or not
*/
public static boolean contains(final String trafficLoadBalanceAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, trafficLoadBalanceAlgorithmType, new Properties()).isPresent();
+ return TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, trafficLoadBalanceAlgorithmType, null).isPresent();
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml
index a3c786f5dee..bc9985c7e6e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/conf/import/config-sharding.yaml
@@ -101,7 +101,7 @@ rules:
completionDetector:
type: IDLE
props:
- incremental-task-idle-minute-threshold: 30
+ incremental-task-idle-seconds-threshold: 1800
dataConsistencyChecker:
type: DATA_MATCH
props:
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
index 77d463fde29..29612d1b95e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
@@ -108,7 +108,7 @@
# completionDetector:
# type: IDLE
# props:
-# incremental-task-idle-minute-threshold: 30
+# incremental-task-idle-seconds-threshold: 1800
# dataConsistencyChecker:
# type: DATA_MATCH
# props:
@@ -206,7 +206,7 @@
# completionDetector:
# type: IDLE
# props:
-# incremental-task-idle-minute-threshold: 30
+# incremental-task-idle-seconds-threshold: 1800
# dataConsistencyChecker:
# type: DATA_MATCH
# props:
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
index e7ee2e01b28..9deb2378eb5 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
@@ -62,8 +62,8 @@ public final class TypedSPIRegistry {
public static <T extends TypedSPI> Optional<T> findRegisteredService(final Class<T> spiClass, final String type, final Properties props) {
for (T each : ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
if (matchesType(type, each)) {
- // TODO for contains judge only, should fix here
- if (null != props && !props.isEmpty() && each instanceof SPIPostProcessor) {
+ // TODO for AlgorithmFactory contains judge only, should fix here
+ if (null != props && each instanceof SPIPostProcessor) {
init((SPIPostProcessor) each, props);
}
if (each instanceof SPIPropertiesAware) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
index 6427423bd2e..2d9f7e66873 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
@@ -680,7 +680,7 @@ public final class OracleDDLStatementSQLVisitor extends OracleStatementSQLVisito
public ASTNode visitCreateFunction(final CreateFunctionContext ctx) {
return new OracleCreateFunctionStatement();
}
-
+
@Override
public ASTNode visitDropEdition(final DropEditionContext ctx) {
return new OracleDropEditionStatement();
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/create.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/create.xml
index e5432a57716..7d8fd88bacf 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/create.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/create.xml
@@ -108,49 +108,49 @@
<create-sharding-table-rule sql-case-id="create-sharding-table-rule">
<rule name="t_order" key-generate-strategy-column="another_id">
<data-source>ms_group_${0..1}</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
- <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline"></database-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
+ <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline" />
<key-generate-strategy algorithm-name="snowflake" />
</rule>
<rule name="t_order_item" key-generate-strategy-column="another_id">
<data-source>ms_group_${0..1}</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
- <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline"></database-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
+ <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline" />
</rule>
</create-sharding-table-rule>
<create-sharding-table-rule sql-case-id="create-sharding-table-rule-with-enum-inline-expression">
<rule name="t_order" key-generate-strategy-column="another_id">
<data-source>ms_group_${['abc','ac']}.table</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
- <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline"></database-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
+ <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline" />
<key-generate-strategy algorithm-name="snowflake" />
</rule>
<rule name="t_order_item" key-generate-strategy-column="another_id">
<data-source>ms_group_${0..1}</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
- <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline"></database-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
+ <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline" />
</rule>
</create-sharding-table-rule>
<create-sharding-table-rule sql-case-id="create-sharding-table-rule-complex">
<rule name="t_order" key-generate-strategy-column="another_id">
<data-source>ms_group_${0..1}</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
- <database-strategy type="complex" sharding-column="order_id,user_id" sharding-algorithm-name="database_inline"></database-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
+ <database-strategy type="complex" sharding-column="order_id,user_id" sharding-algorithm-name="database_inline" />
<key-generate-strategy algorithm-name="snowflake" />
</rule>
<rule name="t_order_item" key-generate-strategy-column="another_id">
<data-source>ms_group_${0..1}</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
- <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline"></database-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
+ <database-strategy type="standard" sharding-column="order_id" sharding-algorithm-name="database_inline" />
</rule>
</create-sharding-table-rule>
<create-sharding-table-rule sql-case-id="create-sharding-table-rule-with-auto-create-algorithm">
<rule name="t_order" key-generate-strategy-column="another_id">
<data-source>ms_group_${0..1}</data-source>
- <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline"></table-strategy>
+ <table-strategy type="standard" sharding-column="user_id" sharding-algorithm-name="table_inline" />
<database-strategy type="standard" sharding-column="order_id">
<algorithm-segment algorithm-name="inline">
<properties>
@@ -444,12 +444,12 @@
<configuration>
<completion-detector algorithm-name="IDLE">
<properties>
- <property key="incremental-task-idle-minute-threshold" value="30"/>
+ <property key="incremental-task-idle-seconds-threshold" value="1800" />
</properties>
</completion-detector>
<data-consistency-checker algorithm-name="DATA_MATCH">
<properties>
- <property key="chunk-size" value="1000"/>
+ <property key="chunk-size" value="1000" />
</properties>
</data-consistency-checker>
</configuration>
@@ -478,7 +478,7 @@
</stream-channel>
<completion-detector algorithm-name="IDLE">
<properties>
- <property key="incremental-task-idle-minute-threshold" value="30"/>
+ <property key="incremental-task-idle-seconds-threshold" value="1800" />
</properties>
</completion-detector>
<data-consistency-checker algorithm-name="DATA_MATCH">
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/create.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/create.xml
index 971120cfab2..b3e65e2a549 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/create.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/create.xml
@@ -62,7 +62,7 @@
<distsql-case id="create-shadow-rule-with-quota" value="CREATE SHADOW RULE `shadow_rule`(SOURCE=demo_ds,SHADOW=demo_ds_shadow,t_order((TYPE(NAME=REGEX_MATCH,PROPERTIES('operation'='insert','column'='user_id','regex'='[1]'))),(simple_hint_algorithm,TYPE(NAME=SIMPLE_HINT,PROPERTIES('shadow'='true',foo='bar')))))" />
<distsql-case id="create-sharding-key-generator" value="CREATE SHARDING KEY GENERATOR uuid_key_generator(TYPE(NAME=uuid))" />
<distsql-case id="create-sharding-scaling-rule-without-configuration" value="CREATE SHARDING SCALING RULE default_scaling" />
- <distsql-case id="create-sharding-scaling-rule-with-minimal-auto-configuration" value="CREATE SHARDING SCALING RULE default_scaling (COMPLETION_DETECTOR (TYPE(NAME=IDLE,PROPERTIES('incremental-task-idle-minute-threshold'=30))),DATA_CONSISTENCY_CHECKER (TYPE(NAME=DATA_MATCH,PROPERTIES ('chunk-size'=1000))))" />
- <distsql-case id="create-sharding-scaling-rule-with-complete-auto-configuration" value="CREATE SHARDING SCALING RULE default_scaling (INPUT (WORKER_THREAD=40,BATCH_SIZE=1000,RATE_LIMITER (TYPE(NAME=QPS,PROPERTIES ('qps'=50)))),OUTPUT (WORKER_THREAD=40,BATCH_SIZE=1000,RATE_LIMITER (TYPE(NAME=TPS,PROPERTIES ('tps'=2000)))),STREAM_CHANNEL (TYPE (NAME=MEMORY,PROPERTIES ('block-queue-size'=10000))),COMPLETION_DETECTOR (TYPE (NAME=IDLE,PROPERTIES ('incremental-task-idle-minute-threshold'=3 [...]
+ <distsql-case id="create-sharding-scaling-rule-with-minimal-auto-configuration" value="CREATE SHARDING SCALING RULE default_scaling (COMPLETION_DETECTOR (TYPE(NAME=IDLE,PROPERTIES('incremental-task-idle-seconds-threshold'=1800))),DATA_CONSISTENCY_CHECKER (TYPE(NAME=DATA_MATCH,PROPERTIES ('chunk-size'=1000))))" />
+ <distsql-case id="create-sharding-scaling-rule-with-complete-auto-configuration" value="CREATE SHARDING SCALING RULE default_scaling (INPUT (WORKER_THREAD=40,BATCH_SIZE=1000,RATE_LIMITER (TYPE(NAME=QPS,PROPERTIES ('qps'=50)))),OUTPUT (WORKER_THREAD=40,BATCH_SIZE=1000,RATE_LIMITER (TYPE(NAME=TPS,PROPERTIES ('tps'=2000)))),STREAM_CHANNEL (TYPE (NAME=MEMORY,PROPERTIES ('block-queue-size'=10000))),COMPLETION_DETECTOR (TYPE (NAME=IDLE,PROPERTIES ('incremental-task-idle-seconds-threshold'= [...]
<distsql-case id="create-sharding-scaling-rule-with-manual-configuration" value="CREATE SHARDING SCALING RULE default_scaling (INPUT (WORKER_THREAD=40,BATCH_SIZE=1000,RATE_LIMITER (TYPE(NAME=QPS,PROPERTIES ('qps'=50)))),OUTPUT (WORKER_THREAD=40,BATCH_SIZE=1000,RATE_LIMITER (TYPE (NAME=TPS,PROPERTIES ('tps'=2000)))),STREAM_CHANNEL (TYPE (NAME=MEMORY,PROPERTIES ('block-queue-size'=10000))))" />
</sql-cases>
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java
index e59888d395f..f90b0a62f74 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java
@@ -23,13 +23,9 @@ import org.apache.shardingsphere.data.pipeline.api.ingest.position.PlaceholderPo
import org.apache.shardingsphere.data.pipeline.api.job.progress.JobProgress;
import org.apache.shardingsphere.data.pipeline.api.task.progress.IncrementalTaskProgress;
import org.apache.shardingsphere.data.pipeline.api.task.progress.InventoryTaskProgress;
-import org.apache.shardingsphere.data.pipeline.core.util.ReflectionUtil;
-import org.apache.shardingsphere.data.pipeline.scenario.rulealtered.spi.IdleRuleAlteredJobCompletionDetectAlgorithm;
-import org.junit.Before;
+import org.apache.shardingsphere.data.pipeline.spi.detect.JobCompletionDetectAlgorithmFactory;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import java.util.Collection;
import java.util.Collections;
@@ -41,99 +37,73 @@ import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public final class IdleRuleAlteredJobCompletionDetectAlgorithmTest {
- @Mock
- private Properties props;
-
- private final IdleRuleAlteredJobCompletionDetectAlgorithm detectAlgorithm = new IdleRuleAlteredJobCompletionDetectAlgorithm();
-
- @Before
- public void setup() throws Exception {
- ReflectionUtil.setFieldValue(detectAlgorithm, "props", props);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertInitFailNoIdleThresholdKey() {
- when(props.containsKey(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn(false);
- detectAlgorithm.init(props);
- }
-
@Test(expected = IllegalArgumentException.class)
public void assertInitFailInvalidIdleThresholdKey() {
- when(props.containsKey(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn(true);
- when(props.getProperty(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn("@");
- detectAlgorithm.init(props);
+ Properties props = new Properties();
+ props.setProperty("incremental-task-idle-seconds-threshold", "invalid_value");
+ JobCompletionDetectAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("IDLE", props));
}
@Test(expected = IllegalArgumentException.class)
public void assertInitFailNegativeIdleThresholdKey() {
- when(props.containsKey(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn(true);
- when(props.getProperty(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn("-8");
- detectAlgorithm.init(props);
- }
-
- @Test
- public void assertInitSuccess() {
- when(props.containsKey(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn(true);
- when(props.getProperty(IdleRuleAlteredJobCompletionDetectAlgorithm.IDLE_MINUTE_THRESHOLD_KEY)).thenReturn("4");
- detectAlgorithm.init(props);
+ Properties props = new Properties();
+ props.setProperty("incremental-task-idle-seconds-threshold", "-8");
+ JobCompletionDetectAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("IDLE", props));
}
+ @SuppressWarnings("unchecked")
@Test
public void assertFalseOnFewJobProgresses() {
int jobShardingCount = 2;
Collection<JobProgress> jobProgresses = Collections.singleton(new JobProgress());
RuleAlteredJobAlmostCompletedParameter parameter = new RuleAlteredJobAlmostCompletedParameter(jobShardingCount, jobProgresses);
- assertFalse(detectAlgorithm.isAlmostCompleted(parameter));
+ assertFalse(JobCompletionDetectAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("IDLE", new Properties())).isAlmostCompleted(parameter));
}
+ @SuppressWarnings("unchecked")
@Test
public void assertFalseOnUnFinishedPosition() {
int jobShardingCount = 1;
JobProgress jobProgress = new JobProgress();
Map<String, InventoryTaskProgress> inventoryTaskProgressMap = new LinkedHashMap<>();
jobProgress.setInventoryTaskProgressMap(inventoryTaskProgressMap);
- inventoryTaskProgressMap.put("ds_0", new InventoryTaskProgress(new PlaceholderPosition()));
+ inventoryTaskProgressMap.put("foo_ds", new InventoryTaskProgress(new PlaceholderPosition()));
Collection<JobProgress> jobProgresses = Collections.singleton(jobProgress);
RuleAlteredJobAlmostCompletedParameter parameter = new RuleAlteredJobAlmostCompletedParameter(jobShardingCount, jobProgresses);
- assertFalse(detectAlgorithm.isAlmostCompleted(parameter));
+ assertFalse(JobCompletionDetectAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("IDLE", new Properties())).isAlmostCompleted(parameter));
}
+ @SuppressWarnings("unchecked")
@Test
public void assertTrueWhenIdleMinutesNotReach() {
int jobShardingCount = 1;
- long latestActiveTimeMillis = System.currentTimeMillis() - ThreadLocalRandom.current().nextLong(1, detectAlgorithm.getIncrementalTaskIdleSecondThreshold());
+ long latestActiveTimeMillis = System.currentTimeMillis() - ThreadLocalRandom.current().nextLong(1, 1800L);
JobProgress jobProgress = createJobProgress(latestActiveTimeMillis);
Collection<JobProgress> jobProgresses = Collections.singleton(jobProgress);
RuleAlteredJobAlmostCompletedParameter parameter = new RuleAlteredJobAlmostCompletedParameter(jobShardingCount, jobProgresses);
- assertFalse(detectAlgorithm.isAlmostCompleted(parameter));
- }
-
- private JobProgress createJobProgress(final long latestActiveTimeMillis) {
- JobProgress result = new JobProgress();
- Map<String, InventoryTaskProgress> inventoryTaskProgressMap = new LinkedHashMap<>();
- result.setInventoryTaskProgressMap(inventoryTaskProgressMap);
- inventoryTaskProgressMap.put("ds_0", new InventoryTaskProgress(new FinishedPosition()));
- Map<String, IncrementalTaskProgress> incrementalTaskProgressMap = new LinkedHashMap<>();
- result.setIncrementalTaskProgressMap(incrementalTaskProgressMap);
- IncrementalTaskProgress incrementalTaskProgress = new IncrementalTaskProgress();
- incrementalTaskProgress.getIncrementalTaskDelay().setLatestActiveTimeMillis(latestActiveTimeMillis);
- incrementalTaskProgressMap.put("ds_0", incrementalTaskProgress);
- return result;
+ assertFalse(JobCompletionDetectAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("IDLE", new Properties())).isAlmostCompleted(parameter));
}
+ @SuppressWarnings("unchecked")
@Test
public void assertTrueWhenJobAlmostCompleted() {
int jobShardingCount = 1;
- long latestActiveTimeMillis = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(detectAlgorithm.getIncrementalTaskIdleSecondThreshold()
- + IdleRuleAlteredJobCompletionDetectAlgorithm.DEFAULT_IDLE_SECOND_THRESHOLD);
+ long latestActiveTimeMillis = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(1800L + 1800L);
JobProgress jobProgress = createJobProgress(latestActiveTimeMillis);
Collection<JobProgress> jobProgresses = Collections.singleton(jobProgress);
RuleAlteredJobAlmostCompletedParameter parameter = new RuleAlteredJobAlmostCompletedParameter(jobShardingCount, jobProgresses);
- assertTrue(detectAlgorithm.isAlmostCompleted(parameter));
+ assertTrue(JobCompletionDetectAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("IDLE", new Properties())).isAlmostCompleted(parameter));
+ }
+
+ private JobProgress createJobProgress(final long latestActiveTimeMillis) {
+ JobProgress result = new JobProgress();
+ result.setInventoryTaskProgressMap(Collections.singletonMap("foo_ds", new InventoryTaskProgress(new FinishedPosition())));
+ IncrementalTaskProgress incrementalTaskProgress = new IncrementalTaskProgress();
+ incrementalTaskProgress.getIncrementalTaskDelay().setLatestActiveTimeMillis(latestActiveTimeMillis);
+ result.setIncrementalTaskProgressMap(Collections.singletonMap("foo_ds", incrementalTaskProgress));
+ return result;
}
}