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/04/07 15:28:07 UTC

[shardingsphere] branch master updated: Remove TypedSingletonSPIHolder (#16643)

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 7a792a84477 Remove TypedSingletonSPIHolder (#16643)
7a792a84477 is described below

commit 7a792a844779d17204f6d7d7c4e4f33343a364b0
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Apr 7 23:27:53 2022 +0800

    Remove TypedSingletonSPIHolder (#16643)
---
 .../CreateShardingScalingRuleStatementUpdater.java | 27 +++++--------
 .../position/PositionInitializerFactory.java       |  7 +---
 .../AbstractDataConsistencyCheckAlgorithm.java     | 14 ++-----
 .../channel/MemoryPipelineChannelFactory.java      | 14 ++-----
 .../core/sqlbuilder/PipelineSQLBuilderFactory.java |  7 +---
 ...dleRuleAlteredJobCompletionDetectAlgorithm.java | 14 ++-----
 .../spi/detect/JobCompletionDetectAlgorithm.java   |  3 +-
 .../spi/ingest/channel/PipelineChannelFactory.java |  3 +-
 .../spi/ingest/position/PositionInitializer.java   |  5 +--
 .../spi/ratelimit/JobRateLimitAlgorithm.java       |  3 +-
 .../spi/sqlbuilder/PipelineSQLBuilder.java         |  5 +--
 .../spi/type/singleton/SingletonSPIRegistry.java   |  3 --
 .../type/singleton/TypedSingletonSPIHolder.java    | 45 ----------------------
 .../singleton/TypedSingletonSPIHolderTest.java     | 39 -------------------
 14 files changed, 31 insertions(+), 158 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdater.java
index 8a6d7f06ab9..ee3e4a2d3d1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdater.java
@@ -34,14 +34,14 @@ import org.apache.shardingsphere.scaling.distsql.statement.CreateShardingScaling
 import org.apache.shardingsphere.scaling.distsql.statement.segment.ShardingScalingRuleConfigurationSegment;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
-import org.apache.shardingsphere.spi.type.singleton.TypedSingletonSPIHolder;
-import org.apache.shardingsphere.spi.type.typed.TypedSPI;
+import org.apache.shardingsphere.spi.type.typed.StatefulTypedSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Properties;
 
 /**
  * Create sharding scaling rule statement updater.
@@ -55,14 +55,6 @@ public final class CreateShardingScalingRuleStatementUpdater implements RuleDefi
         ShardingSphereServiceLoader.register(DataConsistencyCheckAlgorithm.class);
     }
     
-    private static final TypedSingletonSPIHolder<JobRateLimitAlgorithm> RATE_LIMIT_ALGORITHM_HOLDER = new TypedSingletonSPIHolder<>(JobRateLimitAlgorithm.class);
-    
-    private static final TypedSingletonSPIHolder<PipelineChannelFactory> PIPELINE_CHANNEL_FACTORY_HOLDER = new TypedSingletonSPIHolder<>(PipelineChannelFactory.class);
-    
-    private static final TypedSingletonSPIHolder<JobCompletionDetectAlgorithm> COMPLETION_DETECT_ALGORITHM_HOLDER = new TypedSingletonSPIHolder<>(JobCompletionDetectAlgorithm.class);
-    
-    private static final TypedSingletonSPIHolder<DataConsistencyCheckAlgorithm> DATA_CONSISTENCY_CHECK_ALGORITHM_HOLDER = new TypedSingletonSPIHolder<>(DataConsistencyCheckAlgorithm.class);
-    
     @Override
     public void checkSQLStatement(final ShardingSphereMetaData shardingSphereMetaData, final CreateShardingScalingRuleStatement sqlStatement,
                                   final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
@@ -105,31 +97,30 @@ public final class CreateShardingScalingRuleStatementUpdater implements RuleDefi
     
     private void checkRateLimiterAlgorithm(final AlgorithmSegment rateLimiter) throws DistSQLException {
         if (null != rateLimiter) {
-            checkAlgorithm(RATE_LIMIT_ALGORITHM_HOLDER, "rate limiter", rateLimiter);
+            checkAlgorithm(JobRateLimitAlgorithm.class, "rate limiter", rateLimiter);
         }
     }
     
     private void checkStreamChannelExist(final ShardingScalingRuleConfigurationSegment segment) throws DistSQLException {
         if (null != segment.getStreamChannel()) {
-            checkAlgorithm(PIPELINE_CHANNEL_FACTORY_HOLDER, "stream channel", segment.getStreamChannel());
+            checkAlgorithm(PipelineChannelFactory.class, "stream channel", segment.getStreamChannel());
         }
     }
     
     private void checkCompletionDetectorExist(final ShardingScalingRuleConfigurationSegment segment) throws DistSQLException {
         if (null != segment.getCompletionDetector()) {
-            checkAlgorithm(COMPLETION_DETECT_ALGORITHM_HOLDER, "completion detector", segment.getCompletionDetector());
+            checkAlgorithm(JobCompletionDetectAlgorithm.class, "completion detector", segment.getCompletionDetector());
         }
     }
     
     private void checkDataConsistencyCheckerExist(final ShardingScalingRuleConfigurationSegment segment) throws DistSQLException {
         if (null != segment.getDataConsistencyChecker()) {
-            checkAlgorithm(DATA_CONSISTENCY_CHECK_ALGORITHM_HOLDER, "data consistency checker", segment.getDataConsistencyChecker());
+            checkAlgorithm(DataConsistencyCheckAlgorithm.class, "data consistency checker", segment.getDataConsistencyChecker());
         }
     }
     
-    private <T extends TypedSPI & SingletonSPI> void checkAlgorithm(
-            final TypedSingletonSPIHolder<T> singletonSPIHolder, final String algorithmType, final AlgorithmSegment segment) throws DistSQLException {
-        Optional<T> service = singletonSPIHolder.get(segment.getName());
+    private <T extends StatefulTypedSPI> void checkAlgorithm(final Class<T> algorithmClass, final String algorithmType, final AlgorithmSegment segment) throws DistSQLException {
+        Optional<T> service = TypedSPIRegistry.findRegisteredService(algorithmClass, segment.getName(), new Properties());
         if (!service.isPresent()) {
             throw new InvalidAlgorithmConfigurationException(algorithmType, segment.getName());
         }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactory.java
index a7775e5ad40..45fbbd32acf 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactory.java
@@ -21,8 +21,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.data.pipeline.spi.ingest.position.PositionInitializer;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.exception.ServiceProviderNotFoundException;
-import org.apache.shardingsphere.spi.type.singleton.TypedSingletonSPIHolder;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
 
 /**
  * Position initializer factory.
@@ -34,8 +33,6 @@ public final class PositionInitializerFactory {
         ShardingSphereServiceLoader.register(PositionInitializer.class);
     }
     
-    private static final TypedSingletonSPIHolder<PositionInitializer> INITIALIZER_SPI_HOLDER = new TypedSingletonSPIHolder<>(PositionInitializer.class);
-    
     /**
      * Get position initializer instance.
      *
@@ -43,6 +40,6 @@ public final class PositionInitializerFactory {
      * @return position initializer
      */
     public static PositionInitializer getPositionInitializer(final String databaseType) {
-        return INITIALIZER_SPI_HOLDER.get(databaseType).orElseThrow(() -> new ServiceProviderNotFoundException(PositionInitializer.class, databaseType));
+        return TypedSPIRegistry.getRegisteredService(PositionInitializer.class, databaseType);
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/AbstractDataConsistencyCheckAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/AbstractDataConsistencyCheckAlgorithm.java
index 82de85936a8..d716821f50b 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/AbstractDataConsistencyCheckAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/AbstractDataConsistencyCheckAlgorithm.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.data.pipeline.core.spi.check.consistency;
 
+import lombok.Getter;
+import lombok.Setter;
 import org.apache.shardingsphere.data.pipeline.core.check.consistency.SingleTableDataCalculatorRegistry;
 import org.apache.shardingsphere.data.pipeline.spi.check.consistency.DataConsistencyCheckAlgorithm;
 import org.apache.shardingsphere.data.pipeline.spi.check.consistency.SingleTableDataCalculator;
@@ -26,20 +28,12 @@ import java.util.Properties;
 /**
  * Abstract data consistency check algorithm.
  */
+@Getter
+@Setter
 public abstract class AbstractDataConsistencyCheckAlgorithm implements DataConsistencyCheckAlgorithm {
     
     private Properties props = new Properties();
     
-    @Override
-    public Properties getProps() {
-        return props;
-    }
-    
-    @Override
-    public void setProps(final Properties props) {
-        this.props = props;
-    }
-    
     @Override
     public void init() {
     }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/ingest/channel/MemoryPipelineChannelFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/ingest/channel/MemoryPipelineChannelFactory.java
index 616b5d4edca..01c69f94dfc 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/ingest/channel/MemoryPipelineChannelFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/ingest/channel/MemoryPipelineChannelFactory.java
@@ -18,6 +18,8 @@
 package org.apache.shardingsphere.data.pipeline.core.spi.ingest.channel;
 
 import com.google.common.base.Strings;
+import lombok.Getter;
+import lombok.Setter;
 import org.apache.shardingsphere.data.pipeline.api.ingest.channel.AckCallback;
 import org.apache.shardingsphere.data.pipeline.api.ingest.channel.PipelineChannel;
 import org.apache.shardingsphere.data.pipeline.core.ingest.channel.memory.MultiplexMemoryPipelineChannel;
@@ -29,6 +31,8 @@ import java.util.Properties;
 /**
  * Memory implementation of pipeline channel factory.
  */
+@Getter
+@Setter
 public final class MemoryPipelineChannelFactory implements PipelineChannelFactory {
     
     public static final String TYPE = "MEMORY";
@@ -39,16 +43,6 @@ public final class MemoryPipelineChannelFactory implements PipelineChannelFactor
     
     private Properties props = new Properties();
     
-    @Override
-    public Properties getProps() {
-        return props;
-    }
-    
-    @Override
-    public void setProps(final Properties props) {
-        this.props = props;
-    }
-    
     @Override
     public void init() {
         String blockQueueSizeValue = props.getProperty(BLOCK_QUEUE_SIZE_KEY);
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactory.java
index e81d4d2a4dd..b1f43becdb6 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactory.java
@@ -21,8 +21,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.data.pipeline.spi.sqlbuilder.PipelineSQLBuilder;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.exception.ServiceProviderNotFoundException;
-import org.apache.shardingsphere.spi.type.singleton.TypedSingletonSPIHolder;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
 
 /**
  * Pipeline SQL builder factory.
@@ -34,8 +33,6 @@ public final class PipelineSQLBuilderFactory {
         ShardingSphereServiceLoader.register(PipelineSQLBuilder.class);
     }
     
-    private static final TypedSingletonSPIHolder<PipelineSQLBuilder> SQL_BUILDER_SPI_HOLDER = new TypedSingletonSPIHolder<>(PipelineSQLBuilder.class);
-    
     /**
      * Get SQL builder instance.
      *
@@ -43,6 +40,6 @@ public final class PipelineSQLBuilderFactory {
      * @return SQL builder
      */
     public static PipelineSQLBuilder getSQLBuilder(final String databaseType) {
-        return SQL_BUILDER_SPI_HOLDER.get(databaseType).orElseThrow(() -> new ServiceProviderNotFoundException(PipelineSQLBuilder.class, databaseType));
+        return TypedSPIRegistry.getRegisteredService(PipelineSQLBuilder.class, databaseType);
     }
 }
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 d1edd903e3d..f323f37f08b 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;
@@ -33,6 +34,8 @@ import java.util.stream.Collectors;
 /**
  * Idle rule altered job completion detect algorithm.
  */
+@Getter
+@Setter
 public final class IdleRuleAlteredJobCompletionDetectAlgorithm implements JobCompletionDetectAlgorithm<RuleAlteredJobAlmostCompletedParameter> {
     
     public static final String IDLE_MINUTE_THRESHOLD_KEY = "incremental-task-idle-minute-threshold";
@@ -43,19 +46,8 @@ public final class IdleRuleAlteredJobCompletionDetectAlgorithm implements JobCom
     
     private Properties props = new Properties();
     
-    @Getter
     private long incrementalTaskIdleSecondThreshold = DEFAULT_IDLE_SECOND_THRESHOLD;
     
-    @Override
-    public Properties getProps() {
-        return props;
-    }
-    
-    @Override
-    public void setProps(final Properties props) {
-        this.props = props;
-    }
-    
     @Override
     public void init() {
         Preconditions.checkArgument(props.containsKey(IDLE_MINUTE_THRESHOLD_KEY) || props.containsKey(IDLE_SECOND_THRESHOLD_KEY), "incremental task idle threshold can not be null.");
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithm.java
index 3bd4dfb5ef8..86dd8ca2037 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithm.java
@@ -19,14 +19,13 @@ package org.apache.shardingsphere.data.pipeline.spi.detect;
 
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmPostProcessor;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
 
 /**
  * Job completion detect algorithm, SPI.
  *
  * @param <T> completion detect parameter type
  */
-public interface JobCompletionDetectAlgorithm<T> extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor, SingletonSPI {
+public interface JobCompletionDetectAlgorithm<T> extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor {
     
     /**
      * Whether job is almost completed.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelFactory.java
index 095a8f13d00..fafef82c1dd 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelFactory.java
@@ -21,12 +21,11 @@ import org.apache.shardingsphere.data.pipeline.api.ingest.channel.AckCallback;
 import org.apache.shardingsphere.data.pipeline.api.ingest.channel.PipelineChannel;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmPostProcessor;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
 
 /**
  * Pipeline channel factory, SPI.
  */
-public interface PipelineChannelFactory extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor, SingletonSPI {
+public interface PipelineChannelFactory extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor {
     
     /**
      * Create pipeline channel.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java
index 7bbce84747d..81f40d722e4 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java
@@ -18,8 +18,7 @@
 package org.apache.shardingsphere.data.pipeline.spi.ingest.position;
 
 import org.apache.shardingsphere.data.pipeline.api.ingest.position.IngestPosition;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
-import org.apache.shardingsphere.spi.type.typed.TypedSPI;
+import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -27,7 +26,7 @@ import java.sql.SQLException;
 /**
  * Position initializer.
  */
-public interface PositionInitializer extends TypedSPI, SingletonSPI {
+public interface PositionInitializer extends StatelessTypedSPI {
     
     /**
      * Init position by data source.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithm.java
index 9e1c1167aa2..d0df9a55837 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithm.java
@@ -20,12 +20,11 @@ package org.apache.shardingsphere.data.pipeline.spi.ratelimit;
 import org.apache.shardingsphere.data.pipeline.api.job.JobOperationType;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmPostProcessor;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
 
 /**
  * Job rate limit algorithm, SPI.
  */
-public interface JobRateLimitAlgorithm extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor, SingletonSPI {
+public interface JobRateLimitAlgorithm extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor {
     
     /**
      * Intercept.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java
index cac47ba61c3..3b37506ff0b 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java
@@ -19,8 +19,7 @@ package org.apache.shardingsphere.data.pipeline.spi.sqlbuilder;
 
 import org.apache.shardingsphere.data.pipeline.api.ingest.record.Column;
 import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
-import org.apache.shardingsphere.spi.type.typed.TypedSPI;
+import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
 
 import java.util.Collection;
 import java.util.List;
@@ -29,7 +28,7 @@ import java.util.List;
  * Pipeline SQL builder.
  * It's singleton when it's used as SPI, else not.
  */
-public interface PipelineSQLBuilder extends TypedSPI, SingletonSPI {
+public interface PipelineSQLBuilder extends StatelessTypedSPI {
     
     /**
      * Build insert SQL.
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java
index c82ba76f641..d176904f461 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java
@@ -49,9 +49,6 @@ public final class SingletonSPIRegistry {
     
     /**
      * Get typed singleton instances map.
-     * <p>
-     *     Notice: Map key is {@linkplain TypedSPI#getType()}, it won't be converted to upper case or lower case. If type is case-insensitive, then try {@linkplain TypedSingletonSPIHolder}.
-     * </p>
      *
      * @param spiClass singleton SPI class
      * @param <T> the type of the input elements
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/TypedSingletonSPIHolder.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/TypedSingletonSPIHolder.java
deleted file mode 100644
index 3d255e67cad..00000000000
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/TypedSingletonSPIHolder.java
+++ /dev/null
@@ -1,45 +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.spi.type.singleton;
-
-import org.apache.shardingsphere.spi.type.typed.TypedSPI;
-
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Typed singleton SPI holder.
- */
-public final class TypedSingletonSPIHolder<T extends TypedSPI & SingletonSPI> {
-    
-    private final Map<String, T> singletonSPIMap;
-    
-    public TypedSingletonSPIHolder(final Class<T> singletonSPIClass) {
-        singletonSPIMap = SingletonSPIRegistry.getSingletonInstancesMap(singletonSPIClass, TypedSPI::getType);
-    }
-    
-    /**
-     * Get typed singleton SPI instance.
-     *
-     * @param type SPI type
-     * @return typed singleton SPI instance
-     */
-    public Optional<T> get(final String type) {
-        return Optional.ofNullable(singletonSPIMap.get(type));
-    }
-}
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/TypedSingletonSPIHolderTest.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/TypedSingletonSPIHolderTest.java
deleted file mode 100644
index 1bbd4144812..00000000000
--- a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/TypedSingletonSPIHolderTest.java
+++ /dev/null
@@ -1,39 +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.spi.type.singleton;
-
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.singleton.fixture.SingletonSPIFixture;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public final class TypedSingletonSPIHolderTest {
-    
-    static {
-        ShardingSphereServiceLoader.register(SingletonSPIFixture.class);
-    }
-    
-    @Test
-    public void assertGetOnType() {
-        TypedSingletonSPIHolder<SingletonSPIFixture> spiHolder = new TypedSingletonSPIHolder<>(SingletonSPIFixture.class);
-        assertTrue(spiHolder.get("SINGLETON_FIXTURE").isPresent());
-        assertFalse(spiHolder.get("singleton_fixture").isPresent());
-    }
-}