diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java index 9f587b5151fef..d40ab1e88febe 100644 --- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java +++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java @@ -20,6 +20,7 @@ import com.cedarsoftware.util.CaseInsensitiveSet; import lombok.Getter; import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration; +import org.apache.shardingsphere.broadcast.constant.BroadcastOrder; import org.apache.shardingsphere.broadcast.rule.attribute.BroadcastDataNodeRuleAttribute; import org.apache.shardingsphere.broadcast.rule.attribute.BroadcastTableNamesRuleAttribute; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; @@ -102,4 +103,9 @@ public Collection filterBroadcastTableNames(final Collection log public boolean isAllBroadcastTables(final Collection logicTableNames) { return !logicTableNames.isEmpty() && tables.containsAll(logicTableNames); } + + @Override + public int getOrder() { + return BroadcastOrder.ORDER; + } } diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java index a60a399481e2e..8e68dd077c3e5 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java @@ -23,6 +23,7 @@ import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration; import org.apache.shardingsphere.encrypt.config.rule.EncryptColumnRuleConfiguration; import org.apache.shardingsphere.encrypt.config.rule.EncryptTableRuleConfiguration; +import org.apache.shardingsphere.encrypt.constant.EncryptOrder; import org.apache.shardingsphere.encrypt.exception.metadata.EncryptTableNotFoundException; import org.apache.shardingsphere.encrypt.exception.metadata.MismatchedEncryptAlgorithmTypeException; import org.apache.shardingsphere.encrypt.rule.attribute.EncryptTableMapperRuleAttribute; @@ -189,4 +190,9 @@ private EncryptTableRuleConfiguration getTableRuleConfiguration(final String tab Preconditions.checkState(result.isPresent()); return result.get(); } + + @Override + public int getOrder() { + return EncryptOrder.ORDER; + } } diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java index 8f53f93e4c81a..5d9e546b686f6 100644 --- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java +++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java @@ -27,6 +27,7 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.mask.config.MaskRuleConfiguration; import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration; +import org.apache.shardingsphere.mask.constant.MaskOrder; import org.apache.shardingsphere.mask.rule.attribute.MaskTableMapperRuleAttribute; import org.apache.shardingsphere.mask.spi.MaskAlgorithm; @@ -118,4 +119,9 @@ private MaskTableRuleConfiguration getTableRuleConfiguration(final String tableN Preconditions.checkState(result.isPresent()); return result.get(); } + + @Override + public int getOrder() { + return MaskOrder.ORDER; + } } diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java index 5ad0a7b30edcc..6a9818a6c386b 100644 --- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java +++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java @@ -29,6 +29,7 @@ import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration; import org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration; import org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingDataSourceType; +import org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder; import org.apache.shardingsphere.readwritesplitting.exception.ReadwriteSplittingRuleExceptionIdentifier; import org.apache.shardingsphere.readwritesplitting.exception.actual.InvalidReadwriteSplittingActualDataSourceInlineExpressionException; import org.apache.shardingsphere.readwritesplitting.rule.attribute.ReadwriteSplittingDataSourceMapperRuleAttribute; @@ -139,4 +140,9 @@ public ReadwriteSplittingDataSourceGroupRule getSingleDataSourceGroupRule() { public Optional findDataSourceGroupRule(final String dataSourceName) { return Optional.ofNullable(dataSourceRuleGroups.get(dataSourceName)); } + + @Override + public int getOrder() { + return ReadwriteSplittingOrder.ORDER; + } } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java index d884826638a55..d67d1ecf60309 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java @@ -20,17 +20,18 @@ import lombok.Getter; import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration; import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation; -import org.apache.shardingsphere.infra.rule.scope.DatabaseRule; import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes; +import org.apache.shardingsphere.infra.rule.scope.DatabaseRule; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration; import org.apache.shardingsphere.shadow.config.datasource.ShadowDataSourceConfiguration; import org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration; +import org.apache.shardingsphere.shadow.constant.ShadowOrder; +import org.apache.shardingsphere.shadow.rule.attribute.ShadowDataSourceMapperRuleAttribute; +import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm; import org.apache.shardingsphere.shadow.spi.ShadowOperationType; import org.apache.shardingsphere.shadow.spi.column.ColumnShadowAlgorithm; import org.apache.shardingsphere.shadow.spi.hint.HintShadowAlgorithm; -import org.apache.shardingsphere.shadow.rule.attribute.ShadowDataSourceMapperRuleAttribute; -import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm; import java.util.Collection; import java.util.Collections; @@ -242,4 +243,9 @@ public Optional findProductionDataSourceName(final String logicDataSourc ShadowDataSourceRule dataSourceRule = dataSourceRules.get(logicDataSourceName); return null == dataSourceRule ? Optional.empty() : Optional.of(dataSourceRule.getProductionDataSource()); } + + @Override + public int getOrder() { + return ShadowOrder.ORDER; + } } diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java index d6c0938ef5a5d..ffeb6588265a1 100644 --- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java +++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java @@ -49,6 +49,7 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration; import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm; import org.apache.shardingsphere.sharding.cache.ShardingCache; +import org.apache.shardingsphere.sharding.constant.ShardingOrder; import org.apache.shardingsphere.sharding.exception.metadata.ShardingTableRuleNotFoundException; import org.apache.shardingsphere.sharding.rule.attribute.ShardingDataNodeRuleAttribute; import org.apache.shardingsphere.sharding.rule.attribute.ShardingTableNamesRuleAttribute; @@ -634,4 +635,9 @@ private boolean isJoinConditionExpression(final ExpressionSegment expression) { BinaryOperationExpression binaryExpression = (BinaryOperationExpression) expression; return binaryExpression.getLeft() instanceof ColumnSegment && binaryExpression.getRight() instanceof ColumnSegment && "=".equals(binaryExpression.getOperator()); } + + @Override + public int getOrder() { + return ShardingOrder.ORDER; + } } diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java index af70785fd3efb..ac5e7a38befe7 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java @@ -23,9 +23,12 @@ import org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute; import org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -49,7 +52,7 @@ public Collection getDataNodes(final String tableName) { if (result.isEmpty()) { return result; } - for (ShardingSphereRule each : rules) { + for (ShardingSphereRule each : getOrderedRules()) { Optional dataSourceMapperRuleAttribute = each.getAttributes().findAttribute(DataSourceMapperRuleAttribute.class); if (dataSourceMapperRuleAttribute.isPresent()) { result = buildDataNodes(result, dataSourceMapperRuleAttribute.get()); @@ -72,6 +75,12 @@ private Collection getDataNodesByTableName(final ShardingSphereRule ru return rule.getAttributes().findAttribute(DataNodeRuleAttribute.class).map(optional -> optional.getDataNodesByTableName(tableName)).orElse(Collections.emptyList()); } + private Collection getOrderedRules() { + List result = new ArrayList<>(rules); + result.sort(Comparator.comparingInt(ShardingSphereRule::getOrder)); + return result; + } + private Collection buildDataNodes(final Collection dataNodes, final DataSourceMapperRuleAttribute dataSourceMapperRuleAttribute) { Collection result = new LinkedList<>(); Map> dataSourceMapper = dataSourceMapperRuleAttribute.getDataSourceMapper(); diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/ShardingSphereRule.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/ShardingSphereRule.java index 2eb12455c415a..3ff3292595731 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/ShardingSphereRule.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/ShardingSphereRule.java @@ -40,4 +40,11 @@ public interface ShardingSphereRule { default RuleAttributes getAttributes() { return new RuleAttributes(); } + + /** + * Get rule order. + * + * @return rule order + */ + int getOrder(); } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRule.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRule.java index d5599af26160f..eaabe5670fad5 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRule.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRule.java @@ -35,4 +35,9 @@ public RuleConfiguration getConfiguration() { public RuleAttributes getAttributes() { return new RuleAttributes(mock(DataSourceMapperRuleAttribute.class)); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataShardingSphereRuleFixture.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataShardingSphereRuleFixture.java index e7c3d8b4b09b6..28a54645d9a7b 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataShardingSphereRuleFixture.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataShardingSphereRuleFixture.java @@ -28,4 +28,9 @@ public class RuleMetaDataShardingSphereRuleFixture implements ShardingSphereRule public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRule.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRule.java index 7ca342e2b9f17..19ffb5b1387ba 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRule.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRule.java @@ -28,4 +28,9 @@ public final class FixtureGlobalRule implements GlobalRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/fixture/DistSQLHandlerFixtureRule.java b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/fixture/DistSQLHandlerFixtureRule.java index 34313dd132d1a..294e2914cb03c 100644 --- a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/fixture/DistSQLHandlerFixtureRule.java +++ b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/fixture/DistSQLHandlerFixtureRule.java @@ -52,4 +52,9 @@ private DataNodeRuleAttribute getDataNodeRuleAttribute() { when(result.findActualTableByCatalog(any(), any())).thenReturn(Optional.empty()); return result; } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/DecoratorRuleFixture.java b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/DecoratorRuleFixture.java index 6e2b3cdaa8c7b..f6c895807367c 100644 --- a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/DecoratorRuleFixture.java +++ b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/DecoratorRuleFixture.java @@ -28,4 +28,9 @@ public final class DecoratorRuleFixture implements ShardingSphereRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/MergerRuleFixture.java b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/MergerRuleFixture.java index 6d15a2d293bd7..1547229610219 100644 --- a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/MergerRuleFixture.java +++ b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/MergerRuleFixture.java @@ -28,4 +28,9 @@ public final class MergerRuleFixture implements ShardingSphereRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteFailureRuleFixture.java b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteFailureRuleFixture.java index 3e0c24fea42ac..874aa25a49ee0 100644 --- a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteFailureRuleFixture.java +++ b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteFailureRuleFixture.java @@ -28,4 +28,9 @@ public final class RouteFailureRuleFixture implements ShardingSphereRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteRuleFixture.java b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteRuleFixture.java index edb1c534dcf4f..d64bdaffd8f28 100644 --- a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteRuleFixture.java +++ b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/rule/RouteRuleFixture.java @@ -28,4 +28,9 @@ public final class RouteRuleFixture implements ShardingSphereRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java index f468877d4b799..e422c04d4bcf5 100644 --- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java +++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java @@ -19,6 +19,7 @@ import lombok.Getter; import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration; +import org.apache.shardingsphere.authority.constant.AuthorityOrder; import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges; import org.apache.shardingsphere.authority.spi.PrivilegeProvider; import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation; @@ -109,4 +110,9 @@ public Optional findPrivileges(final Grantee grantee) } return Optional.empty(); } + + @Override + public int getOrder() { + return AuthorityOrder.ORDER; + } } diff --git a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/rule/GlobalClockRule.java b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/rule/GlobalClockRule.java index a20512e87467f..ccaf964a6e9be 100644 --- a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/rule/GlobalClockRule.java +++ b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/rule/GlobalClockRule.java @@ -20,6 +20,7 @@ import lombok.Getter; import org.apache.shardingsphere.globalclock.config.GlobalClockRuleConfiguration; import org.apache.shardingsphere.globalclock.provider.GlobalClockProvider; +import org.apache.shardingsphere.globalclock.rule.constant.GlobalClockOrder; import org.apache.shardingsphere.infra.rule.scope.GlobalRule; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; @@ -50,4 +51,9 @@ public GlobalClockRule(final GlobalClockRuleConfiguration ruleConfig) { public Optional getGlobalClockProvider() { return Optional.ofNullable(globalClockProvider); } + + @Override + public int getOrder() { + return GlobalClockOrder.ORDER; + } } diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/rule/LoggingRule.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/rule/LoggingRule.java index 2ee2b7868815b..f4d9d359426d0 100644 --- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/rule/LoggingRule.java +++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/rule/LoggingRule.java @@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.rule.scope.GlobalRule; import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration; import org.apache.shardingsphere.logging.constant.LoggingConstants; +import org.apache.shardingsphere.logging.constant.LoggingOrder; import org.apache.shardingsphere.logging.logger.ShardingSphereLogger; import java.util.Optional; @@ -45,4 +46,9 @@ public LoggingRule(final LoggingRuleConfiguration ruleConfig) { public Optional getSQLLogger() { return configuration.getLoggers().stream().filter(each -> LoggingConstants.SQL_LOG_TOPIC.equalsIgnoreCase(each.getLoggerName())).findFirst(); } + + @Override + public int getOrder() { + return LoggingOrder.ORDER; + } } diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java index 473026ea5a489..c84acb585cef6 100644 --- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java +++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java @@ -33,6 +33,7 @@ import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes; import org.apache.shardingsphere.infra.rule.scope.DatabaseRule; import org.apache.shardingsphere.single.config.SingleRuleConfiguration; +import org.apache.shardingsphere.single.constant.SingleOrder; import org.apache.shardingsphere.single.datanode.SingleTableDataNodeLoader; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; @@ -186,4 +187,9 @@ private Collection getQualifiedTables(final ShardingSphereDataba } return result; } + + @Override + public int getOrder() { + return SingleOrder.ORDER; + } } diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java index b299213ed504a..6fffda59320d7 100644 --- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java +++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java @@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.infra.rule.scope.GlobalRule; import org.apache.shardingsphere.sqlfederation.config.SQLFederationRuleConfiguration; +import org.apache.shardingsphere.sqlfederation.constant.SQLFederationOrder; import org.apache.shardingsphere.sqlfederation.optimizer.context.OptimizerContext; import org.apache.shardingsphere.sqlfederation.optimizer.context.OptimizerContextFactory; @@ -55,4 +56,9 @@ public void refresh(final Map databases, final G public OptimizerContext getOptimizerContext() { return optimizerContext.get(); } + + @Override + public int getOrder() { + return SQLFederationOrder.ORDER; + } } diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleMatchFixture.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleMatchFixture.java index 6e48683b209e6..b92992058fa2d 100644 --- a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleMatchFixture.java +++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleMatchFixture.java @@ -30,4 +30,9 @@ public final class SQLFederationDeciderRuleMatchFixture implements ShardingSpher public RuleConfiguration getConfiguration() { return new SQLFederationRuleConfiguration(true, false, mock(CacheOption.class)); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleNotMatchFixture.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleNotMatchFixture.java index d392506149a0a..b0d5145ebcba2 100644 --- a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleNotMatchFixture.java +++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/engine/fixture/rule/SQLFederationDeciderRuleNotMatchFixture.java @@ -30,4 +30,9 @@ public final class SQLFederationDeciderRuleNotMatchFixture implements ShardingSp public RuleConfiguration getConfiguration() { return new SQLFederationRuleConfiguration(false, false, mock(CacheOption.class)); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/rule/SQLParserRule.java b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/rule/SQLParserRule.java index 3d0b5ad6f1b55..af34a0b572d6e 100644 --- a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/rule/SQLParserRule.java +++ b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/rule/SQLParserRule.java @@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine; import org.apache.shardingsphere.infra.rule.scope.GlobalRule; import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration; +import org.apache.shardingsphere.parser.constant.SQLParserOrder; import org.apache.shardingsphere.sql.parser.api.CacheOption; /** @@ -52,4 +53,9 @@ public SQLParserRule(final SQLParserRuleConfiguration ruleConfig) { public SQLParserEngine getSQLParserEngine(final DatabaseType databaseType) { return new ShardingSphereSQLParserEngine(databaseType, sqlStatementCache, parseTreeCache); } + + @Override + public int getOrder() { + return SQLParserOrder.ORDER; + } } diff --git a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRule.java b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRule.java index 013765e6be438..c8499978fce36 100644 --- a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRule.java +++ b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRule.java @@ -25,6 +25,7 @@ import org.apache.shardingsphere.infra.session.query.QueryContext; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.sqltranslator.config.SQLTranslatorRuleConfiguration; +import org.apache.shardingsphere.sqltranslator.constant.SQLTranslatorOrder; import org.apache.shardingsphere.sqltranslator.context.SQLTranslatorContext; import org.apache.shardingsphere.sqltranslator.exception.SQLTranslationException; import org.apache.shardingsphere.sqltranslator.spi.SQLTranslator; @@ -75,4 +76,9 @@ public SQLTranslatorContext translate(final String sql, final List param throw ex; } } + + @Override + public int getOrder() { + return SQLTranslatorOrder.ORDER; + } } diff --git a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java index 9fe58602bd49e..79eacd8bdba85 100644 --- a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java +++ b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java @@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.rule.scope.GlobalRule; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.timeservice.config.TimestampServiceRuleConfiguration; +import org.apache.shardingsphere.timeservice.core.rule.constant.TimestampServiceOrder; import org.apache.shardingsphere.timeservice.spi.TimestampService; import java.sql.Timestamp; @@ -49,4 +50,9 @@ public TimestampServiceRule(final TimestampServiceRuleConfiguration ruleConfig) public Timestamp getTimestamp() { return timestampService.getTimestamp(); } + + @Override + public int getOrder() { + return TimestampServiceOrder.ORDER; + } } diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java index 62cab89e7a94d..892bb20ce98bf 100644 --- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java +++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java @@ -32,6 +32,7 @@ import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine; import org.apache.shardingsphere.transaction.api.TransactionType; import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration; +import org.apache.shardingsphere.transaction.constant.TransactionOrder; import javax.sql.DataSource; import java.util.LinkedHashMap; @@ -147,4 +148,9 @@ private void close(final ShardingSphereTransactionManagerEngine engine) { log.error("Close transaction engine failed.", ex); } } + + @Override + public int getOrder() { + return TransactionOrder.ORDER; + } } diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/ModeRuleFixture.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/ModeRuleFixture.java index f0130971eaf52..a1cf91e290063 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/ModeRuleFixture.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/ModeRuleFixture.java @@ -28,4 +28,9 @@ public final class ModeRuleFixture implements DatabaseRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } } diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/processor/fixture/AlgorithmChangedProcessorFixtureRule.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/processor/fixture/AlgorithmChangedProcessorFixtureRule.java index cb89211d9d3ce..66c0ce67adbf8 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/processor/fixture/AlgorithmChangedProcessorFixtureRule.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/processor/fixture/AlgorithmChangedProcessorFixtureRule.java @@ -26,4 +26,9 @@ public final class AlgorithmChangedProcessorFixtureRule implements ShardingSphereRule { private final AlgorithmChangedProcessorFixtureRuleConfiguration configuration; + + @Override + public int getOrder() { + return 0; + } } diff --git a/test/fixture/infra/src/main/java/org/apache/shardingsphere/test/fixture/infra/rule/MockedRule.java b/test/fixture/infra/src/main/java/org/apache/shardingsphere/test/fixture/infra/rule/MockedRule.java index 0425cec047cc6..a8c80a39ffc1a 100644 --- a/test/fixture/infra/src/main/java/org/apache/shardingsphere/test/fixture/infra/rule/MockedRule.java +++ b/test/fixture/infra/src/main/java/org/apache/shardingsphere/test/fixture/infra/rule/MockedRule.java @@ -31,4 +31,9 @@ public final class MockedRule implements ShardingSphereRule { public RuleConfiguration getConfiguration() { return mock(RuleConfiguration.class); } + + @Override + public int getOrder() { + return 0; + } }