You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/12/29 10:37:56 UTC
(shardingsphere) branch master updated: Refactor StatisticsCollectJob (#34199)
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 31df4616ccb Refactor StatisticsCollectJob (#34199)
31df4616ccb is described below
commit 31df4616ccb938b8d55c9faa24ca059854da0495
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Dec 29 18:37:50 2024 +0800
Refactor StatisticsCollectJob (#34199)
---
.../schedule/core/job/statistics/collect/StatisticsCollectJob.java | 5 +----
.../core/job/statistics/collect/StatisticsCollectJobTest.java | 1 +
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJob.java b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJob.java
index c49160cdde8..ecd3d64cd2c 100644
--- a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJob.java
+++ b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJob.java
@@ -22,8 +22,6 @@ import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.refresher.ShardingSphereStatisticsRefreshEngine;
-import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
-import org.apache.shardingsphere.mode.spi.PersistRepository;
/**
* Statistics collect job.
@@ -35,8 +33,7 @@ public final class StatisticsCollectJob implements SimpleJob {
@Override
public void execute(final ShardingContext shardingContext) {
- PersistRepository repository = contextManager.getPersistServiceFacade().getRepository();
- if (repository instanceof ClusterPersistRepository) {
+ if (contextManager.getComputeNodeInstanceContext().getModeConfiguration().isCluster()) {
new ShardingSphereStatisticsRefreshEngine(contextManager).refresh();
}
}
diff --git a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobTest.java b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobTest.java
index cdd26eb9e88..a37fa6c4214 100644
--- a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobTest.java
+++ b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobTest.java
@@ -53,6 +53,7 @@ class StatisticsCollectJobTest {
@Test
void assertExecuteWithClusterMode() {
+ when(contextManager.getComputeNodeInstanceContext().getModeConfiguration().isCluster()).thenReturn(true);
when(contextManager.getPersistServiceFacade().getRepository()).thenReturn(mock(ClusterPersistRepository.class));
when(contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_ENABLED)).thenReturn(false);
job.execute(null);