This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 4d7c66a8b67 Refactor StatisticsCollectJobWorker (#37061)
4d7c66a8b67 is described below
commit 4d7c66a8b67f1bdb5ce4cde611bec636a507cfa8
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Nov 10 01:14:41 2025 +0800
Refactor StatisticsCollectJobWorker (#37061)
* Refactor StatisticsCollectJobWorker
* Refactor StatisticsCollectJobWorker
---
README.md | 2 +-
README_ZH.md | 2 +-
.../collect/StatisticsCollectJobWorker.java | 37 +++++++++++-----------
.../collect/StatisticsCollectJobWorkerTest.java | 6 ++++
4 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 0247bd992a7..0c5bd07f6de 100644
--- a/README.md
+++ b/README.md
@@ -272,7 +272,7 @@ Through the combination of ShardingSphere-JDBC &
ShardingSphere-Proxy together w
#### Distributed Database Core Capabilities
- **Data Sharding**: Horizontal sharding, vertical sharding, custom sharding
strategies, automatic sharding routing
- **Read/Write Splitting**: Master-slave replication, load balancing,
failover, read weight configuration
-- **Distributed Transaction**: XA transactions, flexible transactions, Seata
AT integration, transaction propagation
+- **Distributed Transaction**: XA transactions, BASE transactions, transaction
propagation
#### Data Security & Governance
- **Data Encryption**: Field-level encryption, transparent encryption, key
management, encryption algorithm support
diff --git a/README_ZH.md b/README_ZH.md
index e9089e98584..bed92e90701 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -258,7 +258,7 @@ Apache ShardingSphere 是多接入端共同组成的生态圈。
#### 分布式数据库核心能力
- **数据分片**:水平分片、垂直分片、自定义分片策略、自动分片路由
- **读写分离**:主从复制、负载均衡、故障转移、读权重配置
-- **分布式事务**:XA 事务、柔性事务、Seata AT 集成、事务传播
+- **分布式事务**:XA 事务、柔性事务、事务传播
#### 数据安全与治理
- **数据加密**:字段级加密、透明加密、密钥管理、加密算法支持
diff --git
a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
index 3fbe4cef06b..ea7b984c44f 100644
---
a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
+++
b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
@@ -116,30 +116,31 @@ public final class StatisticsCollectJobWorker {
}
/**
- * Destroy job worker.
+ * Update job configuration.
*/
- public void destroy() {
- if (WORKER_INITIALIZED.compareAndSet(true, false)) {
-
Optional.ofNullable(scheduleJobBootstrap).ifPresent(ScheduleJobBootstrap::shutdown);
- scheduleJobBootstrap = null;
+ public void updateJobConfiguration() {
+ if (null == contextManager) {
+ return;
+ }
+ String cron =
contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_CRON);
+ log.info("Changing cron of statistics collect job to `{}`", cron);
+ try {
+ new
JobConfigurationAPIImpl(registryCenter).updateJobConfiguration(JobConfigurationPOJO.fromJobConfiguration(createJobConfiguration()));
+ log.info("Changed cron of statistics collect job to `{}`", cron);
+ // CHECKSTYLE:OFF
+ } catch (final Exception ex) {
+ // CHECKSTYLE:ON
+ log.error("Change statistics collect job cron value error", ex);
}
}
/**
- * Update job configuration.
+ * Destroy job worker.
*/
- public void updateJobConfiguration() {
- if (null != contextManager && null != registryCenter) {
- String cron =
contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_CRON);
- log.info("Changing cron of statistics collect job to `{}`", cron);
- try {
- new
JobConfigurationAPIImpl(registryCenter).updateJobConfiguration(JobConfigurationPOJO.fromJobConfiguration(createJobConfiguration()));
- log.info("Changed cron of statistics collect job to `{}`",
cron);
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- log.error("Change statistics collect job cron value error",
ex);
- }
+ public void destroy() {
+ if (WORKER_INITIALIZED.compareAndSet(true, false)) {
+
Optional.ofNullable(scheduleJobBootstrap).ifPresent(ScheduleJobBootstrap::shutdown);
+ scheduleJobBootstrap = null;
}
}
}
diff --git
a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
index 7d80d0e6c2a..103154035cf 100644
---
a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
+++
b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
@@ -28,6 +28,7 @@ import org.mockito.Mock;
import org.mockito.internal.configuration.plugins.Plugins;
import org.mockito.junit.jupiter.MockitoExtension;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.verify;
@@ -57,6 +58,11 @@ class StatisticsCollectJobWorkerTest {
assertNull(getScheduleJobBootstrap());
}
+ @Test
+ void assertUpdateJobConfigurationWithNullContextManager() {
+ assertDoesNotThrow(() -> jobWorker.updateJobConfiguration());
+ }
+
@Test
void assertDestroy() {
jobWorker.destroy();