You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2024/06/26 04:07:15 UTC

(shardingsphere) branch master updated: Refactor PipelineAPIFactory (#31861)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 5499c0290f8 Refactor PipelineAPIFactory (#31861)
5499c0290f8 is described below

commit 5499c0290f8195e3b4463c19390715b91fda1be7
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Jun 26 12:07:09 2024 +0800

    Refactor PipelineAPIFactory (#31861)
---
 .../data/pipeline/core/job/api/PipelineAPIFactory.java            | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/api/PipelineAPIFactory.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/api/PipelineAPIFactory.java
index b8ad17805f0..19097dc4a69 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/api/PipelineAPIFactory.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/api/PipelineAPIFactory.java
@@ -36,6 +36,7 @@ import org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.settings.Job
 import org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.statistics.JobStatisticsAPIImpl;
 import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 
@@ -146,11 +147,8 @@ public final class PipelineAPIFactory {
             ModeConfiguration modeConfig = pipelineContext.getModeConfig();
             String elasticJobNamespace = PipelineMetaDataNode.getElasticJobNamespace();
             String clusterType = modeConfig.getRepository().getType();
-            if ("ZooKeeper".equals(clusterType)) {
-                return registryCenterInitializer.createZookeeperRegistryCenter(modeConfig, elasticJobNamespace);
-            } else {
-                throw new IllegalArgumentException("Unsupported cluster type: " + clusterType);
-            }
+            ShardingSpherePreconditions.checkState("ZooKeeper".equals(clusterType), () -> new IllegalArgumentException("Unsupported cluster type: " + clusterType));
+            return registryCenterInitializer.createZookeeperRegistryCenter(modeConfig, elasticJobNamespace);
         }
         
         public static RegistryCenterHolder getInstance(final PipelineContextKey contextKey) {