You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2022/11/07 02:19:57 UTC

[shardingsphere] branch master updated: Remove unused create/dropProcessConfiguration methods in InventoryIncrementalJobPublicAPI (#21982)

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

tuichenchuxin 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 2d12f9f5045 Remove unused create/dropProcessConfiguration methods in InventoryIncrementalJobPublicAPI (#21982)
2d12f9f5045 is described below

commit 2d12f9f5045ba75fae024caa3b3db895ef691afe
Author: Hongsheng Zhong <zh...@apache.org>
AuthorDate: Mon Nov 7 10:19:50 2022 +0800

    Remove unused create/dropProcessConfiguration methods in InventoryIncrementalJobPublicAPI (#21982)
---
 .../api/InventoryIncrementalJobPublicAPI.java      | 14 ------
 .../AbstractInventoryIncrementalJobAPIImpl.java    | 25 -----------
 .../process/PipelineProcessConfigurationUtil.java  | 46 +-------------------
 .../PipelineProcessConfigurationUtilTest.java      | 50 ----------------------
 4 files changed, 1 insertion(+), 134 deletions(-)

diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/InventoryIncrementalJobPublicAPI.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/InventoryIncrementalJobPublicAPI.java
index da75b1a92f3..a250eaa1f63 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/InventoryIncrementalJobPublicAPI.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/InventoryIncrementalJobPublicAPI.java
@@ -33,13 +33,6 @@ import java.util.List;
 @SingletonSPI
 public interface InventoryIncrementalJobPublicAPI extends PipelineJobPublicAPI, TypedSPI {
     
-    /**
-     * Create process configuration.
-     *
-     * @param processConfig process configuration
-     */
-    void createProcessConfiguration(PipelineProcessConfiguration processConfig);
-    
     /**
      * Alter process configuration.
      *
@@ -47,13 +40,6 @@ public interface InventoryIncrementalJobPublicAPI extends PipelineJobPublicAPI,
      */
     void alterProcessConfiguration(PipelineProcessConfiguration processConfig);
     
-    /**
-     * Drop process configuration.
-     *
-     * @param confPath configuration path. e.g. <code>/</code>, <code>/READ</code>, <code>/READ/RATE_LIMITER</code>
-     */
-    void dropProcessConfiguration(String confPath);
-    
     /**
      * Show process configuration.
      *
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java
index 10290c57c7c..f23f504e07f 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractInventoryIncrementalJobAPIImpl.java
@@ -38,7 +38,6 @@ import org.apache.shardingsphere.data.pipeline.core.check.consistency.DataConsis
 import org.apache.shardingsphere.data.pipeline.core.config.process.PipelineProcessConfigurationUtil;
 import org.apache.shardingsphere.data.pipeline.core.context.InventoryIncrementalJobItemContext;
 import org.apache.shardingsphere.data.pipeline.core.context.InventoryIncrementalProcessContext;
-import org.apache.shardingsphere.data.pipeline.core.exception.metadata.AlterNotExistProcessConfigurationException;
 import org.apache.shardingsphere.data.pipeline.core.job.progress.yaml.YamlInventoryIncrementalJobItemProgress;
 import org.apache.shardingsphere.data.pipeline.core.job.progress.yaml.YamlInventoryIncrementalJobItemProgressSwapper;
 import org.apache.shardingsphere.data.pipeline.core.task.IncrementalTask;
@@ -46,8 +45,6 @@ import org.apache.shardingsphere.data.pipeline.core.task.InventoryTask;
 import org.apache.shardingsphere.data.pipeline.scenario.consistencycheck.ConsistencyCheckJobItemContext;
 import org.apache.shardingsphere.data.pipeline.spi.check.consistency.DataConsistencyCalculateAlgorithm;
 import org.apache.shardingsphere.data.pipeline.spi.check.consistency.DataConsistencyCalculateAlgorithmFactory;
-import org.apache.shardingsphere.data.pipeline.yaml.process.YamlPipelineProcessConfiguration;
-import org.apache.shardingsphere.data.pipeline.yaml.process.YamlPipelineProcessConfigurationSwapper;
 import org.apache.shardingsphere.elasticjob.infra.pojo.JobConfigurationPOJO;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
 import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -71,8 +68,6 @@ import java.util.stream.IntStream;
 @Slf4j
 public abstract class AbstractInventoryIncrementalJobAPIImpl extends AbstractPipelineJobAPIImpl implements InventoryIncrementalJobAPI, InventoryIncrementalJobPublicAPI {
     
-    private final YamlPipelineProcessConfigurationSwapper processConfigSwapper = new YamlPipelineProcessConfigurationSwapper();
-    
     private final PipelineProcessConfigurationPersistService processConfigPersistService = new PipelineProcessConfigurationPersistService();
     
     private final YamlInventoryIncrementalJobItemProgressSwapper jobItemProgressSwapper = new YamlInventoryIncrementalJobItemProgressSwapper();
@@ -82,32 +77,12 @@ public abstract class AbstractInventoryIncrementalJobAPIImpl extends AbstractPip
     @Override
     public abstract InventoryIncrementalProcessContext buildPipelineProcessContext(PipelineJobConfiguration pipelineJobConfig);
     
-    @Override
-    public void createProcessConfiguration(final PipelineProcessConfiguration processConfig) {
-        processConfigPersistService.persist(getJobType(), processConfig);
-    }
-    
     @Override
     public void alterProcessConfiguration(final PipelineProcessConfiguration processConfig) {
         // TODO check rateLimiter type match or not
         processConfigPersistService.persist(getJobType(), processConfig);
     }
     
-    private YamlPipelineProcessConfiguration getTargetYamlProcessConfiguration() {
-        PipelineProcessConfiguration existingProcessConfig = processConfigPersistService.load(getJobType());
-        ShardingSpherePreconditions.checkNotNull(existingProcessConfig, AlterNotExistProcessConfigurationException::new);
-        return processConfigSwapper.swapToYamlConfiguration(existingProcessConfig);
-    }
-    
-    @Override
-    public void dropProcessConfiguration(final String confPath) {
-        String finalConfPath = confPath.trim();
-        PipelineProcessConfigurationUtil.verifyConfPath(confPath);
-        YamlPipelineProcessConfiguration targetYamlProcessConfig = getTargetYamlProcessConfiguration();
-        PipelineProcessConfigurationUtil.setFieldsNullByConfPath(targetYamlProcessConfig, finalConfPath);
-        processConfigPersistService.persist(getJobType(), processConfigSwapper.swapToObject(targetYamlProcessConfig));
-    }
-    
     @Override
     public PipelineProcessConfiguration showProcessConfiguration() {
         PipelineProcessConfiguration result = processConfigPersistService.load(getJobType());
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
index cd94b4a4216..92ec715e11a 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
@@ -17,19 +17,15 @@
 
 package org.apache.shardingsphere.data.pipeline.core.config.process;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
 import org.apache.shardingsphere.data.pipeline.api.config.process.PipelineProcessConfiguration;
+import org.apache.shardingsphere.data.pipeline.core.ingest.channel.memory.MemoryPipelineChannelCreator;
 import org.apache.shardingsphere.data.pipeline.yaml.process.YamlPipelineProcessConfiguration;
 import org.apache.shardingsphere.data.pipeline.yaml.process.YamlPipelineProcessConfigurationSwapper;
 import org.apache.shardingsphere.data.pipeline.yaml.process.YamlPipelineReadConfiguration;
 import org.apache.shardingsphere.data.pipeline.yaml.process.YamlPipelineWriteConfiguration;
-import org.apache.shardingsphere.data.pipeline.core.ingest.channel.memory.MemoryPipelineChannelCreator;
 import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
 
-import java.util.List;
 import java.util.Properties;
-import java.util.regex.Pattern;
 
 /**
  * Pipeline process configuration util.
@@ -38,10 +34,6 @@ public final class PipelineProcessConfigurationUtil {
     
     private static final YamlPipelineProcessConfigurationSwapper SWAPPER = new YamlPipelineProcessConfigurationSwapper();
     
-    private static final String CONF_PATH_REGEX = "^/|(/[a-zA-Z_]+)+$";
-    
-    private static final Pattern CONF_PATH_PATTERN = Pattern.compile(CONF_PATH_REGEX);
-    
     /**
      * Convert with default value.
      *
@@ -76,40 +68,4 @@ public final class PipelineProcessConfigurationUtil {
             yamlConfig.setStreamChannel(new YamlAlgorithmConfiguration(MemoryPipelineChannelCreator.TYPE, props));
         }
     }
-    
-    /**
-     * Verify configuration path valid or not.
-     *
-     * @param confPath configuration path
-     * @throws IllegalArgumentException if path doesn't match pattern
-     */
-    public static void verifyConfPath(final String confPath) {
-        Preconditions.checkArgument(CONF_PATH_PATTERN.matcher(confPath).matches(), "Invalid confPath, it doesn't match pattern: %s", CONF_PATH_REGEX);
-    }
-    
-    /**
-     * Set fields to null by configuration path.
-     *
-     * @param targetYamlProcessConfig target YAML process configuration
-     * @param confPath configuration path, e.g. <code>/</code>, <code>/READ</code>, <code>/READ/RATE_LIMITER</code>
-     */
-    public static void setFieldsNullByConfPath(final YamlPipelineProcessConfiguration targetYamlProcessConfig, final String confPath) {
-        List<String> confPathNodes = Splitter.on('/').splitToList(confPath);
-        if (2 == confPathNodes.size()) {
-            String levelOne = confPathNodes.get(1).toUpperCase();
-            if (levelOne.isEmpty()) {
-                targetYamlProcessConfig.setAllFieldsNull();
-            } else {
-                targetYamlProcessConfig.setFieldNull(levelOne);
-            }
-        } else if (3 == confPathNodes.size()) {
-            String levelOne = confPathNodes.get(1).toUpperCase();
-            String levelTwo = confPathNodes.get(2).toUpperCase();
-            if ("READ".equals(levelOne) && null != targetYamlProcessConfig.getRead()) {
-                targetYamlProcessConfig.getRead().setFieldNull(levelTwo);
-            } else if ("WRITE".equals(levelOne) && null != targetYamlProcessConfig.getWrite()) {
-                targetYamlProcessConfig.getWrite().setFieldNull(levelTwo);
-            }
-        }
-    }
 }
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtilTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtilTest.java
deleted file mode 100644
index 0bbbd652e25..00000000000
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtilTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.data.pipeline.core.config.process;
-
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public final class PipelineProcessConfigurationUtilTest {
-    
-    @Test
-    public void assertVerifyConfPathSuccess() {
-        for (String each : Arrays.asList("/", "/READ", "/READ/RATE_LIMITER")) {
-            PipelineProcessConfigurationUtil.verifyConfPath(each);
-        }
-    }
-    
-    @Test
-    public void assertVerifyConfPathFailed() {
-        Collection<String> confPaths = Arrays.asList("", "//", "READ", "/READ/");
-        int failCount = 0;
-        for (String each : confPaths) {
-            try {
-                PipelineProcessConfigurationUtil.verifyConfPath(each);
-            } catch (final IllegalArgumentException ex) {
-                ++failCount;
-            }
-        }
-        assertThat(failCount, is(confPaths.size()));
-    }
-}