From 479d4e7ada5a2a715800bf9f0c171a08db358558 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Tue, 5 Nov 2024 11:17:17 +0800 Subject: [PATCH] Rename ShadowDataSourceMappingsRetriever (#33551) * Rename ShadowDataSourceMappingsRetriever * Rename ShadowDataSourceMappingsRetriever --- .../shadow/route/ShadowSQLRouter.java | 4 +-- .../ShadowDataSourceMappingsRetriever.java} | 12 +++---- ...owDataSourceMappingsRetrieverFactory.java} | 34 +++++++++++-------- ...StatementDataSourceMappingsRetriever.java} | 12 +++---- ...StatementDataSourceMappingsRetriever.java} | 8 ++--- ...StatementDataSourceMappingsRetriever.java} | 8 ++--- ...StatementDataSourceMappingsRetriever.java} | 8 ++--- ...StatementDataSourceMappingsRetriever.java} | 8 ++--- ...hadowHintDataSourceMappingsRetriever.java} | 10 +++--- ...taSourceMappingsRetrieverFactoryTest.java} | 28 +++++++-------- ...wHintDataSourceMappingsRetrieverTest.java} | 12 +++---- 11 files changed, 74 insertions(+), 70 deletions(-) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/ShadowDataSourceMappingsFinder.java => retriever/ShadowDataSourceMappingsRetriever.java} (75%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/ShadowDataSourceMappingsFinderFactory.java => retriever/ShadowDataSourceMappingsRetrieverFactory.java} (50%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java => retriever/dml/AbstractShadowDMLStatementDataSourceMappingsRetriever.java} (92%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/dml/ShadowDeleteStatementDataSourceMappingsFinder.java => retriever/dml/ShadowDeleteStatementDataSourceMappingsRetriever.java} (86%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/dml/ShadowInsertStatementDataSourceMappingsFinder.java => retriever/dml/ShadowInsertStatementDataSourceMappingsRetriever.java} (88%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/dml/ShadowSelectStatementDataSourceMappingsFinder.java => retriever/dml/ShadowSelectStatementDataSourceMappingsRetriever.java} (89%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/dml/ShadowUpdateStatementDataSourceMappingsFinder.java => retriever/dml/ShadowUpdateStatementDataSourceMappingsRetriever.java} (87%) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/{finder/hint/ShadowHintDataSourceMappingsFinder.java => retriever/hint/ShadowHintDataSourceMappingsRetriever.java} (81%) rename features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/{finder/ShadowDataSourceMappingsFinderFactoryTest.java => retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java} (79%) rename features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/{finder/hint/ShadowHintDataSourceMappingsFinderTest.java => retriever/hint/ShadowHintDataSourceMappingsRetrieverTest.java} (82%) diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java index 1b8ff3be53ed1..f61944efb67ab 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java @@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.route.context.RouteUnit; import org.apache.shardingsphere.infra.session.query.QueryContext; import org.apache.shardingsphere.shadow.constant.ShadowOrder; -import org.apache.shardingsphere.shadow.route.finder.ShadowDataSourceMappingsFinderFactory; +import org.apache.shardingsphere.shadow.route.retriever.ShadowDataSourceMappingsRetrieverFactory; import org.apache.shardingsphere.shadow.rule.ShadowRule; import java.util.Collection; @@ -45,7 +45,7 @@ public void decorateRouteContext(final RouteContext routeContext, final QueryCon final ShadowRule rule, final ConfigurationProperties props) { Collection toBeRemovedRouteUnit = new LinkedList<>(); Collection toBeAddedRouteUnit = new LinkedList<>(); - Map shadowDataSourceMappings = ShadowDataSourceMappingsFinderFactory.newInstance(queryContext).find(rule); + Map shadowDataSourceMappings = ShadowDataSourceMappingsRetrieverFactory.newInstance(queryContext).retrieve(rule); for (RouteUnit each : routeContext.getRouteUnits()) { String logicName = each.getDataSourceMapper().getLogicName(); String actualName = each.getDataSourceMapper().getActualName(); diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetriever.java similarity index 75% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetriever.java index 4fe987b35ffe8..bdab00abd4f56 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetriever.java @@ -15,22 +15,22 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder; +package org.apache.shardingsphere.shadow.route.retriever; import org.apache.shardingsphere.shadow.rule.ShadowRule; import java.util.Map; /** - * Shadow data source mappings finder. + * Shadow data source mappings retriever. */ -public interface ShadowDataSourceMappingsFinder { +public interface ShadowDataSourceMappingsRetriever { /** - * Find shadow data source mappings. + * Retrieve shadow data source mappings. * * @param rule shadow rule - * @return found shadow data source mappings + * @return retrieved shadow data source mappings */ - Map find(ShadowRule rule); + Map retrieve(ShadowRule rule); } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinderFactory.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactory.java similarity index 50% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinderFactory.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactory.java index 02fce57a2a6ca..44ca22b3b848b 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinderFactory.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder; +package org.apache.shardingsphere.shadow.route.retriever; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -24,37 +24,41 @@ import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.dml.UpdateStatementContext; import org.apache.shardingsphere.infra.session.query.QueryContext; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowDeleteStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowInsertStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowSelectStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowUpdateStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.hint.ShadowHintDataSourceMappingsFinder; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowDeleteStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowInsertStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowSelectStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowUpdateStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.hint.ShadowHintDataSourceMappingsRetriever; /** - * Shadow data source mappings finder factory. + * Shadow data source mappings retriever factory. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ShadowDataSourceMappingsFinderFactory { +public final class ShadowDataSourceMappingsRetrieverFactory { /** - * Create new instance of shadow data source mappings finder. + * Create new instance of shadow data source mappings retriever. * * @param queryContext query context * @return created instance */ - public static ShadowDataSourceMappingsFinder newInstance(final QueryContext queryContext) { + public static ShadowDataSourceMappingsRetriever newInstance(final QueryContext queryContext) { if (queryContext.getSqlStatementContext() instanceof InsertStatementContext) { - return new ShadowInsertStatementDataSourceMappingsFinder((InsertStatementContext) queryContext.getSqlStatementContext(), queryContext.getHintValueContext()); + return new ShadowInsertStatementDataSourceMappingsRetriever( + (InsertStatementContext) queryContext.getSqlStatementContext(), queryContext.getHintValueContext()); } if (queryContext.getSqlStatementContext() instanceof DeleteStatementContext) { - return new ShadowDeleteStatementDataSourceMappingsFinder((DeleteStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), queryContext.getHintValueContext()); + return new ShadowDeleteStatementDataSourceMappingsRetriever( + (DeleteStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), queryContext.getHintValueContext()); } if (queryContext.getSqlStatementContext() instanceof UpdateStatementContext) { - return new ShadowUpdateStatementDataSourceMappingsFinder((UpdateStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), queryContext.getHintValueContext()); + return new ShadowUpdateStatementDataSourceMappingsRetriever( + (UpdateStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), queryContext.getHintValueContext()); } if (queryContext.getSqlStatementContext() instanceof SelectStatementContext) { - return new ShadowSelectStatementDataSourceMappingsFinder((SelectStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), queryContext.getHintValueContext()); + return new ShadowSelectStatementDataSourceMappingsRetriever( + (SelectStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), queryContext.getHintValueContext()); } - return new ShadowHintDataSourceMappingsFinder(queryContext.getHintValueContext()); + return new ShadowHintDataSourceMappingsRetriever(queryContext.getHintValueContext()); } } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/AbstractShadowDMLStatementDataSourceMappingsRetriever.java similarity index 92% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/AbstractShadowDMLStatementDataSourceMappingsRetriever.java index 24d2622121cb9..88e1430565bf8 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/AbstractShadowDMLStatementDataSourceMappingsRetriever.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.dml; +package org.apache.shardingsphere.shadow.route.retriever.dml; import lombok.Getter; import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation; @@ -26,7 +26,7 @@ import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.route.determiner.ColumnShadowAlgorithmDeterminer; import org.apache.shardingsphere.shadow.route.determiner.HintShadowAlgorithmDeterminer; -import org.apache.shardingsphere.shadow.route.finder.ShadowDataSourceMappingsFinder; +import org.apache.shardingsphere.shadow.route.retriever.ShadowDataSourceMappingsRetriever; import org.apache.shardingsphere.shadow.rule.ShadowRule; import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm; import org.apache.shardingsphere.shadow.spi.ShadowOperationType; @@ -41,10 +41,10 @@ import java.util.Optional; /** - * Abstract shadow DML statement data source mappings finder. + * Abstract shadow DML statement data source mappings retriever. */ @HighFrequencyInvocation -public abstract class AbstractShadowDMLStatementDataSourceMappingsFinder implements ShadowDataSourceMappingsFinder { +public abstract class AbstractShadowDMLStatementDataSourceMappingsRetriever implements ShadowDataSourceMappingsRetriever { private final ShadowOperationType operationType; @@ -53,7 +53,7 @@ public abstract class AbstractShadowDMLStatementDataSourceMappingsFinder impleme @Getter private final Map tableAliasAndNameMappings; - protected AbstractShadowDMLStatementDataSourceMappingsFinder(final SQLStatementContext sqlStatementContext, final HintValueContext hintValueContext, final ShadowOperationType operationType) { + protected AbstractShadowDMLStatementDataSourceMappingsRetriever(final SQLStatementContext sqlStatementContext, final HintValueContext hintValueContext, final ShadowOperationType operationType) { this.operationType = operationType; isShadow = hintValueContext.isShadow(); tableAliasAndNameMappings = getTableAliasAndNameMappings(((TableAvailable) sqlStatementContext).getTablesContext().getSimpleTables()); @@ -70,7 +70,7 @@ private Map getTableAliasAndNameMappings(final Collection find(final ShadowRule rule) { + public Map retrieve(final ShadowRule rule) { Collection shadowTables = rule.filterShadowTables(tableAliasAndNameMappings.values()); if (shadowTables.isEmpty() && isMatchDefaultAlgorithm(rule)) { return rule.getAllShadowDataSourceMappings(); diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowDeleteStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDeleteStatementDataSourceMappingsRetriever.java similarity index 86% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowDeleteStatementDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDeleteStatementDataSourceMappingsRetriever.java index 6c86f6d8cb86f..08a31ba9a2e5c 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowDeleteStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDeleteStatementDataSourceMappingsRetriever.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.dml; +package org.apache.shardingsphere.shadow.route.retriever.dml; import org.apache.shardingsphere.infra.binder.context.statement.dml.DeleteStatementContext; import org.apache.shardingsphere.infra.hint.HintValueContext; @@ -32,15 +32,15 @@ import java.util.List; /** - * Shadow delete statement data source mappings finder. + * Shadow delete statement data source mappings retriever. */ -public final class ShadowDeleteStatementDataSourceMappingsFinder extends AbstractShadowDMLStatementDataSourceMappingsFinder { +public final class ShadowDeleteStatementDataSourceMappingsRetriever extends AbstractShadowDMLStatementDataSourceMappingsRetriever { private final DeleteStatementContext sqlStatementContext; private final List parameters; - public ShadowDeleteStatementDataSourceMappingsFinder(final DeleteStatementContext sqlStatementContext, final List parameters, final HintValueContext hintValueContext) { + public ShadowDeleteStatementDataSourceMappingsRetriever(final DeleteStatementContext sqlStatementContext, final List parameters, final HintValueContext hintValueContext) { super(sqlStatementContext, hintValueContext, ShadowOperationType.DELETE); this.sqlStatementContext = sqlStatementContext; this.parameters = parameters; diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowInsertStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowInsertStatementDataSourceMappingsRetriever.java similarity index 88% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowInsertStatementDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowInsertStatementDataSourceMappingsRetriever.java index 3cb306f42b56c..2650a3f6fd7a0 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowInsertStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowInsertStatementDataSourceMappingsRetriever.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.dml; +package org.apache.shardingsphere.shadow.route.retriever.dml; import org.apache.shardingsphere.infra.binder.context.segment.insert.values.InsertValueContext; import org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext; @@ -30,13 +30,13 @@ import java.util.List; /** - * Shadow insert statement data source mappings finder. + * Shadow insert statement data source mappings retriever. */ -public final class ShadowInsertStatementDataSourceMappingsFinder extends AbstractShadowDMLStatementDataSourceMappingsFinder { +public final class ShadowInsertStatementDataSourceMappingsRetriever extends AbstractShadowDMLStatementDataSourceMappingsRetriever { private final InsertStatementContext sqlStatementContext; - public ShadowInsertStatementDataSourceMappingsFinder(final InsertStatementContext sqlStatementContext, final HintValueContext hintValueContext) { + public ShadowInsertStatementDataSourceMappingsRetriever(final InsertStatementContext sqlStatementContext, final HintValueContext hintValueContext) { super(sqlStatementContext, hintValueContext, ShadowOperationType.INSERT); this.sqlStatementContext = sqlStatementContext; } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowSelectStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowSelectStatementDataSourceMappingsRetriever.java similarity index 89% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowSelectStatementDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowSelectStatementDataSourceMappingsRetriever.java index 5c1aa683cbf53..2d9240b20dbbc 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowSelectStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowSelectStatementDataSourceMappingsRetriever.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.dml; +package org.apache.shardingsphere.shadow.route.retriever.dml; import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext; import org.apache.shardingsphere.infra.hint.HintValueContext; @@ -36,15 +36,15 @@ import java.util.Optional; /** - * Shadow select statement data source mappings finder. + * Shadow select statement data source mappings retriever. */ -public final class ShadowSelectStatementDataSourceMappingsFinder extends AbstractShadowDMLStatementDataSourceMappingsFinder { +public final class ShadowSelectStatementDataSourceMappingsRetriever extends AbstractShadowDMLStatementDataSourceMappingsRetriever { private final SelectStatementContext sqlStatementContext; private final List parameters; - public ShadowSelectStatementDataSourceMappingsFinder(final SelectStatementContext sqlStatementContext, final List parameters, final HintValueContext hintValueContext) { + public ShadowSelectStatementDataSourceMappingsRetriever(final SelectStatementContext sqlStatementContext, final List parameters, final HintValueContext hintValueContext) { super(sqlStatementContext, hintValueContext, ShadowOperationType.SELECT); this.sqlStatementContext = sqlStatementContext; this.parameters = parameters; diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowUpdateStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowUpdateStatementDataSourceMappingsRetriever.java similarity index 87% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowUpdateStatementDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowUpdateStatementDataSourceMappingsRetriever.java index 052c6fcde7e9a..1f734fc6c0503 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/ShadowUpdateStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowUpdateStatementDataSourceMappingsRetriever.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.dml; +package org.apache.shardingsphere.shadow.route.retriever.dml; import org.apache.shardingsphere.infra.binder.context.statement.dml.UpdateStatementContext; import org.apache.shardingsphere.infra.hint.HintValueContext; @@ -34,15 +34,15 @@ import java.util.List; /** - * Shadow update statement data source mappings finder. + * Shadow update statement data source mappings retriever. */ -public final class ShadowUpdateStatementDataSourceMappingsFinder extends AbstractShadowDMLStatementDataSourceMappingsFinder { +public final class ShadowUpdateStatementDataSourceMappingsRetriever extends AbstractShadowDMLStatementDataSourceMappingsRetriever { private final UpdateStatementContext sqlStatementContext; private final List parameters; - public ShadowUpdateStatementDataSourceMappingsFinder(final UpdateStatementContext sqlStatementContext, final List parameters, final HintValueContext hintValueContext) { + public ShadowUpdateStatementDataSourceMappingsRetriever(final UpdateStatementContext sqlStatementContext, final List parameters, final HintValueContext hintValueContext) { super(sqlStatementContext, hintValueContext, ShadowOperationType.UPDATE); this.sqlStatementContext = sqlStatementContext; this.parameters = parameters; diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/hint/ShadowHintDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/hint/ShadowHintDataSourceMappingsRetriever.java similarity index 81% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/hint/ShadowHintDataSourceMappingsFinder.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/hint/ShadowHintDataSourceMappingsRetriever.java index c483c8451adf6..6d4e41ea1bfb4 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/hint/ShadowHintDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/hint/ShadowHintDataSourceMappingsRetriever.java @@ -15,28 +15,28 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.hint; +package org.apache.shardingsphere.shadow.route.retriever.hint; import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.hint.HintValueContext; import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.route.determiner.HintShadowAlgorithmDeterminer; -import org.apache.shardingsphere.shadow.route.finder.ShadowDataSourceMappingsFinder; +import org.apache.shardingsphere.shadow.route.retriever.ShadowDataSourceMappingsRetriever; import org.apache.shardingsphere.shadow.rule.ShadowRule; import java.util.Collections; import java.util.Map; /** - * Shadow hint data source mappings finder. + * Shadow hint data source mappings retriever. */ @RequiredArgsConstructor -public final class ShadowHintDataSourceMappingsFinder implements ShadowDataSourceMappingsFinder { +public final class ShadowHintDataSourceMappingsRetriever implements ShadowDataSourceMappingsRetriever { private final HintValueContext hintValueContext; @Override - public Map find(final ShadowRule rule) { + public Map retrieve(final ShadowRule rule) { ShadowCondition shadowCondition = new ShadowCondition(); return rule.getAllHintShadowAlgorithms().stream().anyMatch(each -> HintShadowAlgorithmDeterminer.isShadow(each, shadowCondition, rule, hintValueContext.isShadow())) ? rule.getAllShadowDataSourceMappings() diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinderFactoryTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java similarity index 79% rename from features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinderFactoryTest.java rename to features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java index 4c5d960a6ed66..154a9ee9d185f 100644 --- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/finder/ShadowDataSourceMappingsFinderFactoryTest.java +++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder; +package org.apache.shardingsphere.shadow.route.retriever; import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; import org.apache.shardingsphere.infra.binder.context.statement.dml.DeleteStatementContext; @@ -27,10 +27,10 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.infra.session.connection.ConnectionContext; import org.apache.shardingsphere.infra.session.query.QueryContext; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowDeleteStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowInsertStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowSelectStatementDataSourceMappingsFinder; -import org.apache.shardingsphere.shadow.route.finder.dml.ShadowUpdateStatementDataSourceMappingsFinder; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowDeleteStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowInsertStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowSelectStatementDataSourceMappingsRetriever; +import org.apache.shardingsphere.shadow.route.retriever.dml.ShadowUpdateStatementDataSourceMappingsRetriever; import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement; import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.InsertStatement; import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.SelectStatement; @@ -46,22 +46,22 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -class ShadowDataSourceMappingsFinderFactoryTest { +class ShadowDataSourceMappingsRetrieverFactoryTest { @Test void assertNewInstance() { - ShadowDataSourceMappingsFinder finder = ShadowDataSourceMappingsFinderFactory.newInstance( + ShadowDataSourceMappingsRetriever retriever = ShadowDataSourceMappingsRetrieverFactory.newInstance( new QueryContext(createInsertSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class))); - assertThat(finder, instanceOf(ShadowInsertStatementDataSourceMappingsFinder.class)); - ShadowDataSourceMappingsFinder shadowUpdateRouteEngine = ShadowDataSourceMappingsFinderFactory.newInstance( + assertThat(retriever, instanceOf(ShadowInsertStatementDataSourceMappingsRetriever.class)); + ShadowDataSourceMappingsRetriever shadowUpdateRouteEngine = ShadowDataSourceMappingsRetrieverFactory.newInstance( new QueryContext(createUpdateSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class))); - assertThat(shadowUpdateRouteEngine, instanceOf(ShadowUpdateStatementDataSourceMappingsFinder.class)); - ShadowDataSourceMappingsFinder shadowDeleteRouteEngine = ShadowDataSourceMappingsFinderFactory.newInstance( + assertThat(shadowUpdateRouteEngine, instanceOf(ShadowUpdateStatementDataSourceMappingsRetriever.class)); + ShadowDataSourceMappingsRetriever shadowDeleteRouteEngine = ShadowDataSourceMappingsRetrieverFactory.newInstance( new QueryContext(createDeleteSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class))); - assertThat(shadowDeleteRouteEngine, instanceOf(ShadowDeleteStatementDataSourceMappingsFinder.class)); - ShadowDataSourceMappingsFinder shadowSelectRouteEngine = ShadowDataSourceMappingsFinderFactory.newInstance( + assertThat(shadowDeleteRouteEngine, instanceOf(ShadowDeleteStatementDataSourceMappingsRetriever.class)); + ShadowDataSourceMappingsRetriever shadowSelectRouteEngine = ShadowDataSourceMappingsRetrieverFactory.newInstance( new QueryContext(createSelectSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class))); - assertThat(shadowSelectRouteEngine, instanceOf(ShadowSelectStatementDataSourceMappingsFinder.class)); + assertThat(shadowSelectRouteEngine, instanceOf(ShadowSelectStatementDataSourceMappingsRetriever.class)); } private ConnectionContext mockConnectionContext() { diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/finder/hint/ShadowHintDataSourceMappingsFinderTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/hint/ShadowHintDataSourceMappingsRetrieverTest.java similarity index 82% rename from features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/finder/hint/ShadowHintDataSourceMappingsFinderTest.java rename to features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/hint/ShadowHintDataSourceMappingsRetrieverTest.java index e9bf47493bbfb..778c273b2098c 100644 --- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/finder/hint/ShadowHintDataSourceMappingsFinderTest.java +++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/hint/ShadowHintDataSourceMappingsRetrieverTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.shadow.route.finder.hint; +package org.apache.shardingsphere.shadow.route.retriever.hint; import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration; import org.apache.shardingsphere.infra.hint.HintValueContext; @@ -33,19 +33,19 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -class ShadowHintDataSourceMappingsFinderTest { +class ShadowHintDataSourceMappingsRetrieverTest { @Test - void assertFindWithShadowHint() { + void assertRetrieveWithShadowHint() { HintValueContext hintValueContext = new HintValueContext(); hintValueContext.setShadow(true); - assertThat(new ShadowHintDataSourceMappingsFinder(hintValueContext).find(new ShadowRule(createRuleConfiguration())), is(Collections.singletonMap("prod_ds", "shadow_ds"))); + assertThat(new ShadowHintDataSourceMappingsRetriever(hintValueContext).retrieve(new ShadowRule(createRuleConfiguration())), is(Collections.singletonMap("prod_ds", "shadow_ds"))); } @Test - void assertFindWithNotShadowHint() { + void assertRetrieverWithNotShadowHint() { HintValueContext hintValueContext = new HintValueContext(); - assertThat(new ShadowHintDataSourceMappingsFinder(hintValueContext).find(new ShadowRule(createRuleConfiguration())), is(Collections.emptyMap())); + assertThat(new ShadowHintDataSourceMappingsRetriever(hintValueContext).retrieve(new ShadowRule(createRuleConfiguration())), is(Collections.emptyMap())); } private ShadowRuleConfiguration createRuleConfiguration() {