This is an automated email from the ASF dual-hosted git repository.
panjuan 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 978c5707376 Rename TimeServiceRuleConfiguration to
TimestampServiceRuleConfiguration (#25803)
978c5707376 is described below
commit 978c57073762cef42b51efc6eb7d39cfb017cceb
Author: Liang Zhang <[email protected]>
AuthorDate: Sat May 20 12:40:06 2023 +0800
Rename TimeServiceRuleConfiguration to TimestampServiceRuleConfiguration
(#25803)
---
.../sharding/cache/ShardingCache.java | 8 +++----
.../checker/ShardingRouteCacheableChecker.java | 12 +++++-----
.../InsertClauseShardingConditionEngine.java | 8 +++----
.../condition/engine/ShardingConditionEngine.java | 8 +++----
.../engine/WhereClauseShardingConditionEngine.java | 6 ++---
.../generator/ConditionValueGenerator.java | 6 ++---
.../generator/ConditionValueGeneratorFactory.java | 12 +++++-----
.../ConditionValueBetweenOperatorGenerator.java | 12 +++++-----
.../ConditionValueCompareOperatorGenerator.java | 6 ++---
.../impl/ConditionValueInOperatorGenerator.java | 6 ++---
.../checker/ShardingRouteCacheableCheckerTest.java | 16 ++++++-------
.../InsertClauseShardingConditionEngineTest.java | 6 ++---
.../WhereClauseShardingConditionEngineTest.java | 4 ++--
.../ConditionValueGeneratorFactoryTest.java | 14 +++++------
...ConditionValueBetweenOperatorGeneratorTest.java | 20 ++++++++--------
...ConditionValueCompareOperatorGeneratorTest.java | 22 ++++++++---------
.../ConditionValueInOperatorGeneratorTest.java | 12 +++++-----
.../ShardingRoutingEngineFixtureBuilder.java | 8 +++----
.../standard/assertion/ShardingRouteAssert.java | 6 ++---
...java => TimestampServiceRuleConfiguration.java} | 4 ++--
...phereTimeService.java => TimestampService.java} | 12 +++++-----
...eServiceRule.java => TimestampServiceRule.java} | 28 +++++++++++-----------
...faultTimestampServiceConfigurationBuilder.java} | 18 +++++++-------
...ilder.java => TimestampServiceRuleBuilder.java} | 20 ++++++++--------
...erviceOrder.java => TimestampServiceOrder.java} | 4 ++--
...er.global.DefaultGlobalRuleConfigurationBuilder | 2 +-
...ere.infra.rule.builder.global.GlobalRuleBuilder | 2 +-
...eService.java => DatabaseTimestampService.java} | 18 +++++++-------
...vider.java => TimestampLoadingSQLProvider.java} | 10 ++++----
....java => MySQLTimestampLoadingSQLProvider.java} | 8 +++----
...java => OracleTimestampLoadingSQLProvider.java} | 8 +++----
... => PostgreSQLTimestampLoadingSQLProvider.java} | 8 +++----
...a => SQLServerTimestampLoadingSQLProvider.java} | 8 +++----
...hardingsphere.timeservice.spi.TimestampService} | 2 +-
....database.provider.TimestampLoadingSQLProvider} | 8 +++----
...Test.java => DatabaseTimestampServiceTest.java} | 8 +++----
...imeService.java => SystemTimestampService.java} | 13 +++++-----
...hardingsphere.timeservice.spi.TimestampService} | 2 +-
...ceTest.java => SystemTimestampServiceTest.java} | 8 +++----
.../test/it/rewrite/engine/SQLRewriterIT.java | 8 +++----
40 files changed, 196 insertions(+), 195 deletions(-)
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/ShardingCache.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/ShardingCache.java
index cecbce33be6..fed3039625b 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/ShardingCache.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/ShardingCache.java
@@ -22,8 +22,8 @@ import
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfigur
import
org.apache.shardingsphere.sharding.cache.checker.ShardingRouteCacheableChecker;
import org.apache.shardingsphere.sharding.cache.route.cache.ShardingRouteCache;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
-import
org.apache.shardingsphere.timeservice.core.rule.builder.DefaultTimeServiceConfigurationBuilder;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
+import
org.apache.shardingsphere.timeservice.core.rule.builder.DefaultTimestampServiceConfigurationBuilder;
/**
* <strong>EXPERIMENTAL</strong> Sharding cache.
@@ -35,7 +35,7 @@ public final class ShardingCache {
private final ShardingRule shardingRule;
- private final TimeServiceRule timeServiceRule;
+ private final TimestampServiceRule timestampServiceRule;
private final ShardingRouteCacheableChecker routeCacheableChecker;
@@ -44,7 +44,7 @@ public final class ShardingCache {
public ShardingCache(final ShardingCacheConfiguration configuration, final
ShardingRule shardingRule) {
this.configuration = configuration;
this.shardingRule = shardingRule;
- timeServiceRule = new TimeServiceRule(new
DefaultTimeServiceConfigurationBuilder().build());
+ timestampServiceRule = new TimestampServiceRule(new
DefaultTimestampServiceConfigurationBuilder().build());
routeCacheableChecker = new ShardingRouteCacheableChecker(this);
routeCache = new ShardingRouteCache(configuration.getRouteCache());
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
index d4b62020bfd..37a146a0f70 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
@@ -46,7 +46,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.In
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.ArrayList;
import java.util.Collection;
@@ -63,13 +63,13 @@ public final class ShardingRouteCacheableChecker {
private final ShardingRule shardingRule;
- private final TimeServiceRule timeServiceRule;
+ private final TimestampServiceRule timestampServiceRule;
private final LoadingCache<Key, ShardingRouteCacheableCheckResult>
checkingCache;
public ShardingRouteCacheableChecker(final ShardingCache shardingCache) {
shardingRule = shardingCache.getShardingRule();
- timeServiceRule = shardingCache.getTimeServiceRule();
+ timestampServiceRule = shardingCache.getTimestampServiceRule();
checkingCache =
buildCache(shardingCache.getConfiguration().getRouteCache());
}
@@ -108,7 +108,7 @@ public final class ShardingRouteCacheableChecker {
if (1 != tableNames.size() &&
!shardingRule.isAllBindingTables(tableNames) ||
containsNonCacheableShardingAlgorithm(tableNames)) {
return new ShardingRouteCacheableCheckResult(false,
Collections.emptyList());
}
- List<ShardingCondition> shardingConditions = new
WhereClauseShardingConditionEngine(database, shardingRule,
timeServiceRule).createShardingConditions(statementContext, params);
+ List<ShardingCondition> shardingConditions = new
WhereClauseShardingConditionEngine(database, shardingRule,
timestampServiceRule).createShardingConditions(statementContext, params);
return checkShardingConditionsCacheable(shardingConditions);
}
@@ -136,7 +136,7 @@ public final class ShardingRouteCacheableChecker {
return new ShardingRouteCacheableCheckResult(false,
Collections.emptyList());
}
}
- List<ShardingCondition> shardingConditions = new
InsertClauseShardingConditionEngine(database, shardingRule,
timeServiceRule).createShardingConditions(statementContext, params);
+ List<ShardingCondition> shardingConditions = new
InsertClauseShardingConditionEngine(database, shardingRule,
timestampServiceRule).createShardingConditions(statementContext, params);
return checkShardingConditionsCacheable(shardingConditions);
}
@@ -153,7 +153,7 @@ public final class ShardingRouteCacheableChecker {
if (isShardingTable &&
containsNonCacheableShardingAlgorithm(tableNames) || !isShardingTable &&
!shardingRule.isAllBroadcastTables(tableNames)) {
return new ShardingRouteCacheableCheckResult(false,
Collections.emptyList());
}
- List<ShardingCondition> shardingConditions = new
WhereClauseShardingConditionEngine(database, shardingRule,
timeServiceRule).createShardingConditions(statementContext, params);
+ List<ShardingCondition> shardingConditions = new
WhereClauseShardingConditionEngine(database, shardingRule,
timestampServiceRule).createShardingConditions(statementContext, params);
return checkShardingConditionsCacheable(shardingConditions);
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
index 42911f1e3c2..48ada0ec921 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
@@ -35,7 +35,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.SimpleExpressionSegment;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.ArrayList;
import java.util.Collection;
@@ -58,7 +58,7 @@ public final class InsertClauseShardingConditionEngine {
private final ShardingRule shardingRule;
- private final TimeServiceRule timeServiceRule;
+ private final TimestampServiceRule timestampServiceRule;
/**
* Create sharding conditions.
@@ -139,7 +139,7 @@ public final class InsertClauseShardingConditionEngine {
} else if (each instanceof CommonExpressionSegment) {
generateShardingCondition((CommonExpressionSegment) each,
result, shardingColumn.get(), tableName);
} else if (ExpressionConditionUtils.isNowExpression(each)) {
- result.getValues().add(new
ListShardingConditionValue<>(shardingColumn.get(), tableName,
Collections.singletonList(timeServiceRule.getDatetime())));
+ result.getValues().add(new
ListShardingConditionValue<>(shardingColumn.get(), tableName,
Collections.singletonList(timestampServiceRule.getTimestamp())));
}
}
return result;
@@ -162,7 +162,7 @@ public final class InsertClauseShardingConditionEngine {
private List<ShardingCondition>
createShardingConditionsWithInsertSelect(final InsertStatementContext
sqlStatementContext, final List<Object> params) {
SelectStatementContext selectStatementContext =
sqlStatementContext.getInsertSelectContext().getSelectStatementContext();
- return new LinkedList<>(new
WhereClauseShardingConditionEngine(database, shardingRule,
timeServiceRule).createShardingConditions(selectStatementContext, params));
+ return new LinkedList<>(new
WhereClauseShardingConditionEngine(database, shardingRule,
timestampServiceRule).createShardingConditions(selectStatementContext, params));
}
private void appendGeneratedKeyConditions(final InsertStatementContext
sqlStatementContext, final List<ShardingCondition> shardingConditions) {
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngine.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngine.java
index c5673521fc3..ff39eb61916 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngine.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngine.java
@@ -24,7 +24,7 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.List;
@@ -48,9 +48,9 @@ public final class ShardingConditionEngine {
* @return sharding conditions
*/
public List<ShardingCondition> createShardingConditions(final
SQLStatementContext sqlStatementContext, final List<Object> params) {
- TimeServiceRule timeServiceRule =
globalRuleMetaData.getSingleRule(TimeServiceRule.class);
+ TimestampServiceRule timestampServiceRule =
globalRuleMetaData.getSingleRule(TimestampServiceRule.class);
return sqlStatementContext instanceof InsertStatementContext
- ? new InsertClauseShardingConditionEngine(database,
shardingRule,
timeServiceRule).createShardingConditions((InsertStatementContext)
sqlStatementContext, params)
- : new WhereClauseShardingConditionEngine(database,
shardingRule, timeServiceRule).createShardingConditions(sqlStatementContext,
params);
+ ? new InsertClauseShardingConditionEngine(database,
shardingRule,
timestampServiceRule).createShardingConditions((InsertStatementContext)
sqlStatementContext, params)
+ : new WhereClauseShardingConditionEngine(database,
shardingRule,
timestampServiceRule).createShardingConditions(sqlStatementContext, params);
}
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
index e7c5fbba037..f9b81d73d45 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
@@ -41,7 +41,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.Whe
import org.apache.shardingsphere.sql.parser.sql.common.util.ColumnExtractor;
import
org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtils;
import
org.apache.shardingsphere.sql.parser.sql.common.util.SafeNumberOperationUtils;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.ArrayList;
import java.util.Collection;
@@ -65,7 +65,7 @@ public final class WhereClauseShardingConditionEngine {
private final ShardingRule shardingRule;
- private final TimeServiceRule timeServiceRule;
+ private final TimestampServiceRule timestampServiceRule;
/**
* Create sharding conditions.
@@ -117,7 +117,7 @@ public final class WhereClauseShardingConditionEngine {
continue;
}
Column column = new Column(shardingColumn.get(),
tableName.get());
- Optional<ShardingConditionValue> shardingConditionValue =
ConditionValueGeneratorFactory.generate(each, column, params, timeServiceRule);
+ Optional<ShardingConditionValue> shardingConditionValue =
ConditionValueGeneratorFactory.generate(each, column, params,
timestampServiceRule);
if (!shardingConditionValue.isPresent()) {
continue;
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGenerator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGenerator.java
index be57b003a7c..76f7319d160 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGenerator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGenerator.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.sharding.route.engine.condition.generator;
import org.apache.shardingsphere.sharding.route.engine.condition.Column;
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.List;
import java.util.Optional;
@@ -38,8 +38,8 @@ public interface ConditionValueGenerator<T extends
ExpressionSegment> {
* @param predicateRightValue predicate right value
* @param column column
* @param params SQL parameters
- * @param timeServiceRule time service rule
+ * @param timestampServiceRule time service rule
* @return route value
*/
- Optional<ShardingConditionValue> generate(T predicateRightValue, Column
column, List<Object> params, TimeServiceRule timeServiceRule);
+ Optional<ShardingConditionValue> generate(T predicateRightValue, Column
column, List<Object> params, TimestampServiceRule timestampServiceRule);
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
index 20fea33bf29..487705e42df 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenE
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.InExpression;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.List;
import java.util.Optional;
@@ -51,18 +51,18 @@ public final class ConditionValueGeneratorFactory {
* @param predicate predicate right value
* @param column column
* @param params SQL parameters
- * @param timeServiceRule time service rule
+ * @param timestampServiceRule time service rule
* @return route value
*/
- public static Optional<ShardingConditionValue> generate(final
ExpressionSegment predicate, final Column column, final List<Object> params,
final TimeServiceRule timeServiceRule) {
+ public static Optional<ShardingConditionValue> generate(final
ExpressionSegment predicate, final Column column, final List<Object> params,
final TimestampServiceRule timestampServiceRule) {
if (predicate instanceof BinaryOperationExpression) {
- return
COMPARE_OPERATOR_GENERATOR.generate((BinaryOperationExpression) predicate,
column, params, timeServiceRule);
+ return
COMPARE_OPERATOR_GENERATOR.generate((BinaryOperationExpression) predicate,
column, params, timestampServiceRule);
}
if (predicate instanceof InExpression) {
- return IN_OPERATOR_GENERATOR.generate((InExpression) predicate,
column, params, timeServiceRule);
+ return IN_OPERATOR_GENERATOR.generate((InExpression) predicate,
column, params, timestampServiceRule);
}
if (predicate instanceof BetweenExpression) {
- return BETWEEN_OPERATOR_GENERATOR.generate((BetweenExpression)
predicate, column, params, timeServiceRule);
+ return BETWEEN_OPERATOR_GENERATOR.generate((BetweenExpression)
predicate, column, params, timestampServiceRule);
}
return Optional.empty();
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
index 27ca948ffa4..cec2da69991 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
@@ -26,10 +26,10 @@ import
org.apache.shardingsphere.sharding.route.engine.condition.value.RangeShar
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenExpression;
import
org.apache.shardingsphere.sql.parser.sql.common.util.SafeNumberOperationUtils;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
+import java.sql.Timestamp;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Optional;
@@ -39,7 +39,7 @@ import java.util.Optional;
public final class ConditionValueBetweenOperatorGenerator implements
ConditionValueGenerator<BetweenExpression> {
@Override
- public Optional<ShardingConditionValue> generate(final BetweenExpression
predicate, final Column column, final List<Object> params, final
TimeServiceRule timeServiceRule) {
+ public Optional<ShardingConditionValue> generate(final BetweenExpression
predicate, final Column column, final List<Object> params, final
TimestampServiceRule timestampServiceRule) {
ConditionValue betweenConditionValue = new
ConditionValue(predicate.getBetweenExpr(), params);
ConditionValue andConditionValue = new
ConditionValue(predicate.getAndExpr(), params);
Optional<Comparable<?>> betweenValue =
betweenConditionValue.getValue();
@@ -51,12 +51,12 @@ public final class ConditionValueBetweenOperatorGenerator
implements ConditionVa
return Optional.of(new
RangeShardingConditionValue<>(column.getName(), column.getTableName(),
SafeNumberOperationUtils.safeClosed(betweenValue.get(), andValue.get()),
parameterMarkerIndexes));
}
- Date datetime = timeServiceRule.getDatetime();
+ Timestamp timestamp = timestampServiceRule.getTimestamp();
if (!betweenValue.isPresent() &&
ExpressionConditionUtils.isNowExpression(predicate.getBetweenExpr())) {
- betweenValue = Optional.of(datetime);
+ betweenValue = Optional.of(timestamp);
}
if (!andValue.isPresent() &&
ExpressionConditionUtils.isNowExpression(predicate.getAndExpr())) {
- andValue = Optional.of(datetime);
+ andValue = Optional.of(timestamp);
}
if (!betweenValue.isPresent() || !andValue.isPresent()) {
return Optional.empty();
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
index 0607b988f59..2e86c8ed78a 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingC
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.ArrayList;
import java.util.Arrays;
@@ -56,7 +56,7 @@ public final class ConditionValueCompareOperatorGenerator
implements ConditionVa
private static final Collection<String> OPERATORS = new
HashSet<>(Arrays.asList(EQUAL, GREATER_THAN, LESS_THAN, AT_LEAST, AT_MOST));
@Override
- public Optional<ShardingConditionValue> generate(final
BinaryOperationExpression predicate, final Column column, final List<Object>
params, final TimeServiceRule timeServiceRule) {
+ public Optional<ShardingConditionValue> generate(final
BinaryOperationExpression predicate, final Column column, final List<Object>
params, final TimestampServiceRule timestampServiceRule) {
String operator = predicate.getOperator();
if (!isSupportedOperator(operator)) {
return Optional.empty();
@@ -68,7 +68,7 @@ public final class ConditionValueCompareOperatorGenerator
implements ConditionVa
return generate(value.get(), column, operator,
conditionValue.getParameterMarkerIndex().orElse(-1));
}
if (ExpressionConditionUtils.isNowExpression(valueExpression)) {
- return generate(timeServiceRule.getDatetime(), column, operator,
-1);
+ return generate(timestampServiceRule.getTimestamp(), column,
operator, -1);
}
return Optional.empty();
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
index 3e6b6cb4124..da95610608a 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShard
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.InExpression;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -38,7 +38,7 @@ import java.util.Optional;
public final class ConditionValueInOperatorGenerator implements
ConditionValueGenerator<InExpression> {
@Override
- public Optional<ShardingConditionValue> generate(final InExpression
predicate, final Column column, final List<Object> params, final
TimeServiceRule timeServiceRule) {
+ public Optional<ShardingConditionValue> generate(final InExpression
predicate, final Column column, final List<Object> params, final
TimestampServiceRule timestampServiceRule) {
List<Comparable<?>> shardingConditionValues = new LinkedList<>();
List<Integer> parameterMarkerIndexes = new
ArrayList<>(predicate.getExpressionList().size());
for (ExpressionSegment each : predicate.getExpressionList()) {
@@ -50,7 +50,7 @@ public final class ConditionValueInOperatorGenerator
implements ConditionValueGe
continue;
}
if (ExpressionConditionUtils.isNowExpression(each)) {
- shardingConditionValues.add(timeServiceRule.getDatetime());
+
shardingConditionValues.add(timestampServiceRule.getTimestamp());
}
}
return shardingConditionValues.isEmpty() ? Optional.empty()
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
index a6153b00622..9b2f53d9d47 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableCheckerTest.java
@@ -44,8 +44,8 @@ import org.apache.shardingsphere.sql.parser.api.CacheOption;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -75,8 +75,8 @@ class ShardingRouteCacheableCheckerTest {
@ArgumentsSource(TestCaseArgumentsProvider.class)
void assertCheckCacheable(final String sql, final List<Object> parameters,
final boolean expectedProbablyCacheable, final List<Integer>
expectedShardingConditionParameterMarkerIndexes) {
ShardingRule shardingRule = createShardingRule();
- TimeServiceRule timeServiceRule = createTimeServiceRule();
- ShardingSphereDatabase database = createDatabase(shardingRule,
timeServiceRule);
+ TimestampServiceRule timestampServiceRule = createTimeServiceRule();
+ ShardingSphereDatabase database = createDatabase(shardingRule,
timestampServiceRule);
ShardingRouteCacheableCheckResult actual = new
ShardingRouteCacheableChecker(shardingRule.getShardingCache()).check(database,
createQueryContext(database, sql, parameters));
assertThat(actual.isProbablyCacheable(),
is(expectedProbablyCacheable));
assertThat(actual.getShardingConditionParameterMarkerIndexes(),
is(expectedShardingConditionParameterMarkerIndexes));
@@ -104,11 +104,11 @@ class ShardingRouteCacheableCheckerTest {
return new ShardingRule(ruleConfig, Arrays.asList("ds_0", "ds_1"), new
InstanceContext(mock(ComputeNodeInstance.class), props -> 0, null, null, null,
null));
}
- private TimeServiceRule createTimeServiceRule() {
- return new TimeServiceRule(new TimeServiceRuleConfiguration("System",
new Properties()));
+ private TimestampServiceRule createTimeServiceRule() {
+ return new TimestampServiceRule(new
TimestampServiceRuleConfiguration("System", new Properties()));
}
- private ShardingSphereDatabase createDatabase(final ShardingRule
shardingRule, final TimeServiceRule timeServiceRule) {
+ private ShardingSphereDatabase createDatabase(final ShardingRule
shardingRule, final TimestampServiceRule timestampServiceRule) {
ShardingSphereSchema schema = new ShardingSphereSchema();
schema.getTables().put("t_broadcast_table", new
ShardingSphereTable("t_broadcast_table", Arrays.asList(
new ShardingSphereColumn("broadcast_table_id", Types.INTEGER,
true, false, false, true, false),
@@ -126,7 +126,7 @@ class ShardingRouteCacheableCheckerTest {
new ShardingSphereColumn("order_broadcast_table_id",
Types.INTEGER, true, false, false, true, false)),
Collections.emptyList(), Collections.emptyList()));
return new ShardingSphereDatabase(DATABASE_NAME,
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"),
- new ShardingSphereResourceMetaData(DATABASE_NAME,
Collections.emptyMap()), new
ShardingSphereRuleMetaData(Arrays.asList(shardingRule, timeServiceRule)),
+ new ShardingSphereResourceMetaData(DATABASE_NAME,
Collections.emptyMap()), new
ShardingSphereRuleMetaData(Arrays.asList(shardingRule, timestampServiceRule)),
Collections.singletonMap(SCHEMA_NAME, schema));
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
index 8a4dd981ac0..67f3c65905e 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
@@ -36,8 +36,8 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.Sim
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -79,7 +79,7 @@ class InsertClauseShardingConditionEngineTest {
void setUp() {
ShardingSphereDatabase database = mockDatabase();
InsertStatement insertStatement = mockInsertStatement();
- shardingConditionEngine = new
InsertClauseShardingConditionEngine(database, shardingRule, new
TimeServiceRule(new TimeServiceRuleConfiguration("System", new Properties())));
+ shardingConditionEngine = new
InsertClauseShardingConditionEngine(database, shardingRule, new
TimestampServiceRule(new TimestampServiceRuleConfiguration("System", new
Properties())));
when(insertStatementContext.getSqlStatement()).thenReturn(insertStatement);
when(insertStatementContext.getColumnNames()).thenReturn(Collections.singletonList("foo_col_1"));
when(insertStatementContext.getInsertValueContexts()).thenReturn(Collections.singletonList(createInsertValueContext()));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
index d6e40cbb215..3a8f12698b8 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
@@ -34,7 +34,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ListExpr
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -73,7 +73,7 @@ class WhereClauseShardingConditionEngineTest {
@BeforeEach
void setUp() {
shardingConditionEngine = new WhereClauseShardingConditionEngine(
- ShardingSphereDatabase.create("test_db",
DatabaseTypeEngine.getDatabaseType("MySQL")), shardingRule,
mock(TimeServiceRule.class));
+ ShardingSphereDatabase.create("test_db",
DatabaseTypeEngine.getDatabaseType("MySQL")), shardingRule,
mock(TimestampServiceRule.class));
when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.singleton(whereSegment));
when(sqlStatementContext.getTablesContext()).thenReturn(tablesContext);
when(tablesContext.findTableNamesByColumnSegment(anyCollection(),
any())).thenReturn(Maps.of("foo_sharding_col", "table_1"));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactoryTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactoryTest.java
index ccaa1e932e7..5cd55c704d1 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactoryTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactoryTest.java
@@ -31,7 +31,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ListExpr
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -51,8 +51,8 @@ class ConditionValueGeneratorFactoryTest {
void assertGenerateBinaryOperationExpression() {
ConditionValueCompareOperatorGenerator
conditionValueCompareOperatorGenerator = new
ConditionValueCompareOperatorGenerator();
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, 1), "=", null);
- Optional<ShardingConditionValue> actual =
conditionValueCompareOperatorGenerator.generate(rightValue, column, new
LinkedList<>(), mock(TimeServiceRule.class));
- Optional<ShardingConditionValue> expected =
ConditionValueGeneratorFactory.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> actual =
conditionValueCompareOperatorGenerator.generate(rightValue, column, new
LinkedList<>(), mock(TimestampServiceRule.class));
+ Optional<ShardingConditionValue> expected =
ConditionValueGeneratorFactory.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(actual.isPresent() && expected.isPresent());
assertThat(actual.get().getTableName(),
is(expected.get().getTableName()));
assertThat(actual.get().getColumnName(),
is(expected.get().getColumnName()));
@@ -65,9 +65,9 @@ class ConditionValueGeneratorFactoryTest {
ListExpression right = new ListExpression(0, 0);
right.getItems().add(new ParameterMarkerExpressionSegment(0, 0, 0));
Optional<ShardingConditionValue> actual =
conditionValueInOperatorGenerator.generate(
- new InExpression(0, 0, left, right, false), column,
Collections.singletonList(1), mock(TimeServiceRule.class));
+ new InExpression(0, 0, left, right, false), column,
Collections.singletonList(1), mock(TimestampServiceRule.class));
Optional<ShardingConditionValue> expected =
ConditionValueGeneratorFactory.generate(
- new InExpression(0, 0, left, right, false), column,
Collections.singletonList(1), mock(TimeServiceRule.class));
+ new InExpression(0, 0, left, right, false), column,
Collections.singletonList(1), mock(TimestampServiceRule.class));
assertTrue(actual.isPresent() && expected.isPresent());
assertThat(actual.get().getColumnName(),
is(expected.get().getColumnName()));
assertThat(actual.get().getTableName(),
is(expected.get().getTableName()));
@@ -79,9 +79,9 @@ class ConditionValueGeneratorFactoryTest {
ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0,
1);
ExpressionSegment andSegment = new LiteralExpressionSegment(0, 0, 2);
Optional<ShardingConditionValue> actual =
conditionValueBetweenOperatorGenerator.generate(
- new BetweenExpression(0, 0, null, betweenSegment, andSegment,
false), column, new LinkedList<>(), mock(TimeServiceRule.class));
+ new BetweenExpression(0, 0, null, betweenSegment, andSegment,
false), column, new LinkedList<>(), mock(TimestampServiceRule.class));
Optional<ShardingConditionValue> expected =
ConditionValueGeneratorFactory.generate(
- new BetweenExpression(0, 0, null, betweenSegment, andSegment,
false), column, new LinkedList<>(), mock(TimeServiceRule.class));
+ new BetweenExpression(0, 0, null, betweenSegment, andSegment,
false), column, new LinkedList<>(), mock(TimestampServiceRule.class));
assertTrue(actual.isPresent() && expected.isPresent());
assertThat(actual.get().getColumnName(),
is(expected.get().getColumnName()));
assertThat(actual.get().getTableName(),
is(expected.get().getTableName()));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
index 0e6cc1e0809..d8867ac6e52 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
@@ -29,8 +29,8 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.L
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.util.SafeNumberOperationUtils;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -56,7 +56,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
private final Column column = new Column("id", "tbl");
- private final TimeServiceRule timeServiceRule = new TimeServiceRule(new
TimeServiceRuleConfiguration("System", new Properties()));
+ private final TimestampServiceRule timestampServiceRule = new
TimestampServiceRule(new TimestampServiceRuleConfiguration("System", new
Properties()));
@SuppressWarnings("unchecked")
@Test
@@ -66,7 +66,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0,
between);
ExpressionSegment andSegment = new LiteralExpressionSegment(0, 0, and);
BetweenExpression value = new BetweenExpression(0, 0, null,
betweenSegment, andSegment, false);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timestampServiceRule);
assertTrue(shardingConditionValue.isPresent());
RangeShardingConditionValue<Integer> rangeShardingConditionValue =
(RangeShardingConditionValue<Integer>) shardingConditionValue.get();
assertThat(rangeShardingConditionValue.getColumnName(),
is(column.getName()));
@@ -84,7 +84,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0,
between);
ExpressionSegment andSegment = new LiteralExpressionSegment(0, 0, and);
BetweenExpression value = new BetweenExpression(0, 0, null,
betweenSegment, andSegment, false);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timestampServiceRule);
assertTrue(shardingConditionValue.isPresent());
RangeShardingConditionValue<Comparable<?>> rangeShardingConditionValue
= (RangeShardingConditionValue<Comparable<?>>) shardingConditionValue.get();
assertThat(rangeShardingConditionValue.getColumnName(),
is(column.getName()));
@@ -100,7 +100,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0,
between);
ExpressionSegment andSegment = new CommonExpressionSegment(0, 0,
"now()");
BetweenExpression value = new BetweenExpression(0, 0, null,
betweenSegment, andSegment, false);
- assertThrows(ClassCastException.class, () -> generator.generate(value,
column, new LinkedList<>(), timeServiceRule));
+ assertThrows(ClassCastException.class, () -> generator.generate(value,
column, new LinkedList<>(), timestampServiceRule));
}
@SuppressWarnings("unchecked")
@@ -110,7 +110,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0,
date);
ExpressionSegment andSegment = new CommonExpressionSegment(0, 0,
"now()");
BetweenExpression value = new BetweenExpression(0, 0, null,
betweenSegment, andSegment, false);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timestampServiceRule);
assertTrue(shardingConditionValue.isPresent());
RangeShardingConditionValue<Date> rangeShardingConditionValue =
(RangeShardingConditionValue<Date>) shardingConditionValue.get();
assertThat(rangeShardingConditionValue.getColumnName(),
is(column.getName()));
@@ -128,7 +128,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ExpressionSegment betweenSegment = new CommonExpressionSegment(0, 0,
"now()");
ExpressionSegment andSegment = new CommonExpressionSegment(0, 0,
"now()");
BetweenExpression value = new BetweenExpression(0, 0, null,
betweenSegment, andSegment, false);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(value, column, new LinkedList<>(), timestampServiceRule);
assertTrue(shardingConditionValue.isPresent());
RangeShardingConditionValue<Date> rangeShardingConditionValue =
(RangeShardingConditionValue<Date>) shardingConditionValue.get();
assertThat(rangeShardingConditionValue.getColumnName(),
is(column.getName()));
@@ -144,7 +144,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ParameterMarkerExpressionSegment between = new
ParameterMarkerExpressionSegment(0, 0, 0);
ParameterMarkerExpressionSegment and = new
ParameterMarkerExpressionSegment(0, 0, 1);
BetweenExpression predicate = new BetweenExpression(0, 0, left,
between, and, false);
- Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, Arrays.asList(1, 2), timeServiceRule);
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, Arrays.asList(1, 2),
timestampServiceRule);
assertTrue(actual.isPresent());
assertThat(actual.get(),
instanceOf(RangeShardingConditionValue.class));
RangeShardingConditionValue<Integer> conditionValue =
(RangeShardingConditionValue<Integer>) actual.get();
@@ -160,7 +160,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
ParameterMarkerExpressionSegment between = new
ParameterMarkerExpressionSegment(0, 0, 0);
ParameterMarkerExpressionSegment and = new
ParameterMarkerExpressionSegment(0, 0, 1);
BetweenExpression predicate = new BetweenExpression(0, 0, left,
between, and, false);
- Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(), timestampServiceRule);
assertFalse(actual.isPresent());
}
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
index 7e9ce370e78..14b1574c138 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -53,7 +53,7 @@ class ConditionValueCompareOperatorGeneratorTest {
void assertGenerateConditionValue() {
int value = 1;
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, value), "=", null);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(shardingConditionValue.isPresent());
assertTrue(((ListShardingConditionValue<Integer>)
shardingConditionValue.get()).getValues().contains(value));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -63,7 +63,7 @@ class ConditionValueCompareOperatorGeneratorTest {
@Test
void assertGenerateConditionValueWithLessThanOperator() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, 1), "<", null);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(shardingConditionValue.isPresent());
assertTrue(Range.lessThan(1).encloses(((RangeShardingConditionValue<Integer>)
shardingConditionValue.get()).getValueRange()));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -73,7 +73,7 @@ class ConditionValueCompareOperatorGeneratorTest {
@Test
void assertGenerateConditionValueWithGreaterThanOperator() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, 1), ">", null);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(shardingConditionValue.isPresent());
assertTrue(Range.greaterThan(1).encloses(((RangeShardingConditionValue<Integer>)
shardingConditionValue.get()).getValueRange()));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -83,7 +83,7 @@ class ConditionValueCompareOperatorGeneratorTest {
@Test
void assertGenerateConditionValueWithAtMostOperator() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, 1), "<=", null);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(shardingConditionValue.isPresent());
assertTrue(Range.atMost(1).encloses(((RangeShardingConditionValue<Integer>)
shardingConditionValue.get()).getValueRange()));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -93,7 +93,7 @@ class ConditionValueCompareOperatorGeneratorTest {
@Test
void assertGenerateConditionValueWithAtLeastOperator() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, 1), ">=", null);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(shardingConditionValue.isPresent());
assertTrue(Range.atLeast(1).encloses(((RangeShardingConditionValue<Integer>)
shardingConditionValue.get()).getValueRange()));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -102,20 +102,20 @@ class ConditionValueCompareOperatorGeneratorTest {
@Test
void assertGenerateConditionValueWithErrorOperator() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, 1), "!=", null);
- assertFalse(generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class)).isPresent());
+ assertFalse(generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class)).isPresent());
}
@Test
void assertGenerateConditionValueWithoutNowExpression() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
CommonExpressionSegment(0, 0, "value"), "=", null);
- assertFalse(generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class)).isPresent());
+ assertFalse(generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class)).isPresent());
}
@SuppressWarnings("unchecked")
@Test
void assertGenerateConditionValueWithNowExpression() {
BinaryOperationExpression rightValue = new
BinaryOperationExpression(0, 0, mock(ColumnSegment.class), new
LiteralExpressionSegment(0, 0, "now()"), "=", null);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(rightValue, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertTrue(shardingConditionValue.isPresent());
assertFalse(((ListShardingConditionValue<Integer>)
shardingConditionValue.get()).getValues().isEmpty());
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -127,7 +127,7 @@ class ConditionValueCompareOperatorGeneratorTest {
ColumnSegment left = new ColumnSegment(0, 0, new
IdentifierValue("id"));
ParameterMarkerExpressionSegment right = new
ParameterMarkerExpressionSegment(0, 0, 0);
BinaryOperationExpression predicate = new BinaryOperationExpression(0,
0, left, right, "=", "id = ?");
- Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, Collections.singletonList(1),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, Collections.singletonList(1),
mock(TimestampServiceRule.class));
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ListShardingConditionValue.class));
ListShardingConditionValue<Integer> conditionValue =
(ListShardingConditionValue<Integer>) actual.get();
@@ -142,7 +142,7 @@ class ConditionValueCompareOperatorGeneratorTest {
ColumnSegment left = new ColumnSegment(0, 0, new
IdentifierValue("order_id"));
ParameterMarkerExpressionSegment right = new
ParameterMarkerExpressionSegment(0, 0, 0);
BinaryOperationExpression predicate = new BinaryOperationExpression(0,
0, left, right, "=", "order_id = ?");
- Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(),
mock(TimeServiceRule.class));
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(),
mock(TimestampServiceRule.class));
assertFalse(actual.isPresent());
}
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
index 7cc7a6cec86..737a4596266 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
@@ -26,8 +26,8 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ListExpr
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.CommonExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -48,14 +48,14 @@ class ConditionValueInOperatorGeneratorTest {
private final Column column = new Column("id", "tbl");
- private final TimeServiceRule timeServiceRule = new TimeServiceRule(new
TimeServiceRuleConfiguration("System", new Properties()));
+ private final TimestampServiceRule timestampServiceRule = new
TimestampServiceRule(new TimestampServiceRuleConfiguration("System", new
Properties()));
@Test
void assertNowExpression() {
ListExpression listExpression = new ListExpression(0, 0);
listExpression.getItems().add(new CommonExpressionSegment(0, 0,
"now()"));
InExpression inExpression = new InExpression(0, 0, null,
listExpression, false);
- Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(inExpression, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> shardingConditionValue =
generator.generate(inExpression, column, new LinkedList<>(),
timestampServiceRule);
assertTrue(shardingConditionValue.isPresent());
assertThat(((ListShardingConditionValue<?>)
shardingConditionValue.get()).getValues().iterator().next(),
instanceOf(Date.class));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
@@ -68,7 +68,7 @@ class ConditionValueInOperatorGeneratorTest {
ListExpression right = new ListExpression(0, 0);
right.getItems().add(new ParameterMarkerExpressionSegment(0, 0, 0));
InExpression predicate = new InExpression(0, 0, left, right, false);
- Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, Collections.singletonList(1),
timeServiceRule);
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, Collections.singletonList(1),
timestampServiceRule);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ListShardingConditionValue.class));
ListShardingConditionValue<Integer> conditionValue =
(ListShardingConditionValue<Integer>) actual.get();
@@ -84,7 +84,7 @@ class ConditionValueInOperatorGeneratorTest {
ListExpression right = new ListExpression(0, 0);
right.getItems().add(new ParameterMarkerExpressionSegment(0, 0, 0));
InExpression predicate = new InExpression(0, 0, left, right, false);
- Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(), timeServiceRule);
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(), timestampServiceRule);
assertFalse(actual.isPresent());
}
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/ShardingRoutingEngineFixtureBuilder.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/ShardingRoutingEngineFixtureBuilder.java
index 30dbd6f17ec..6372c86dc00 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/ShardingRoutingEngineFixtureBuilder.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/fixture/ShardingRoutingEngineFixtureBuilder.java
@@ -41,8 +41,8 @@ import org.apache.shardingsphere.single.rule.SingleRule;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -303,8 +303,8 @@ public final class ShardingRoutingEngineFixtureBuilder {
*
* @return created time service rule
*/
- public static TimeServiceRule createTimeServiceRule() {
- return new TimeServiceRule(new TimeServiceRuleConfiguration("System",
new Properties()));
+ public static TimestampServiceRule createTimeServiceRule() {
+ return new TimestampServiceRule(new
TimestampServiceRuleConfiguration("System", new Properties()));
}
@SneakyThrows(SQLException.class)
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
index 60e7fd85e26..fe9a8f17493 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
@@ -42,7 +42,7 @@ import
org.apache.shardingsphere.sharding.route.engine.fixture.ShardingRoutingEn
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.single.rule.SingleRule;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import java.sql.Types;
import java.util.Arrays;
@@ -72,12 +72,12 @@ public final class ShardingRouteAssert {
public static RouteContext assertRoute(final String sql, final
List<Object> params) {
ShardingRule shardingRule =
ShardingRoutingEngineFixtureBuilder.createAllShardingRule();
SingleRule singleRule =
ShardingRoutingEngineFixtureBuilder.createSingleRule(Collections.singletonList(shardingRule));
- TimeServiceRule timeServiceRule =
ShardingRoutingEngineFixtureBuilder.createTimeServiceRule();
+ TimestampServiceRule timestampServiceRule =
ShardingRoutingEngineFixtureBuilder.createTimeServiceRule();
Map<String, ShardingSphereSchema> schemas = buildSchemas();
ConfigurationProperties props = new ConfigurationProperties(new
Properties());
SQLStatementParserEngine sqlStatementParserEngine = new
SQLStatementParserEngine("MySQL",
new CacheOption(2000, 65535L), new CacheOption(128, 1024L),
false);
- ShardingSphereRuleMetaData ruleMetaData = new
ShardingSphereRuleMetaData(Arrays.asList(shardingRule, singleRule,
timeServiceRule));
+ ShardingSphereRuleMetaData ruleMetaData = new
ShardingSphereRuleMetaData(Arrays.asList(shardingRule, singleRule,
timestampServiceRule));
ShardingSphereResourceMetaData resourceMetaData =
mock(ShardingSphereResourceMetaData.class, RETURNS_DEEP_STUBS);
when(resourceMetaData.getStorageTypes()).thenReturn(Collections.singletonMap("ds_0",
new MySQLDatabaseType()));
ShardingSphereDatabase database = new ShardingSphereDatabase(
diff --git
a/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/api/config/TimeServiceRuleConfiguration.java
b/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/api/config/TimestampServiceRuleConfiguration.java
similarity index 89%
rename from
kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/api/config/TimeServiceRuleConfiguration.java
rename to
kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/api/config/TimestampServiceRuleConfiguration.java
index c8e1e99786c..1adc7414546 100644
---
a/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/api/config/TimeServiceRuleConfiguration.java
+++
b/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/api/config/TimestampServiceRuleConfiguration.java
@@ -24,11 +24,11 @@ import
org.apache.shardingsphere.infra.config.rule.scope.GlobalRuleConfiguration
import java.util.Properties;
/**
- * Time service rule configuration.
+ * Timestamp service rule configuration.
*/
@RequiredArgsConstructor
@Getter
-public final class TimeServiceRuleConfiguration implements
GlobalRuleConfiguration {
+public final class TimestampServiceRuleConfiguration implements
GlobalRuleConfiguration {
private final String type;
diff --git
a/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/spi/ShardingSphereTimeService.java
b/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/spi/TimestampService.java
similarity index 83%
rename from
kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/spi/ShardingSphereTimeService.java
rename to
kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/spi/TimestampService.java
index 331bb46b810..6167b18fcae 100644
---
a/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/spi/ShardingSphereTimeService.java
+++
b/kernel/time-service/api/src/main/java/org/apache/shardingsphere/timeservice/spi/TimestampService.java
@@ -19,17 +19,17 @@ package org.apache.shardingsphere.timeservice.spi;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
-import java.util.Date;
+import java.sql.Timestamp;
/**
- * ShardingSphere time service.
+ * Timestamp service.
*/
-public interface ShardingSphereTimeService extends TypedSPI {
+public interface TimestampService extends TypedSPI {
/**
- * Get datetime.
+ * Get timestamp.
*
- * @return datetime
+ * @return timestamp
*/
- Date getDatetime();
+ Timestamp getTimestamp();
}
diff --git
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimeServiceRule.java
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java
similarity index 59%
rename from
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimeServiceRule.java
rename to
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java
index 9c6c8ebf7df..28b416f9bff 100644
---
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimeServiceRule.java
+++
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/TimestampServiceRule.java
@@ -20,38 +20,38 @@ package org.apache.shardingsphere.timeservice.core.rule;
import lombok.Getter;
import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.spi.TimestampService;
-import java.util.Date;
+import java.sql.Timestamp;
import java.util.Properties;
/**
- * Time service rule.
+ * Timestamp service rule.
*/
-public final class TimeServiceRule implements GlobalRule {
+public final class TimestampServiceRule implements GlobalRule {
@Getter
- private final TimeServiceRuleConfiguration configuration;
+ private final TimestampServiceRuleConfiguration configuration;
- private final ShardingSphereTimeService timeService;
+ private final TimestampService timestampService;
- public TimeServiceRule(final TimeServiceRuleConfiguration ruleConfig) {
+ public TimestampServiceRule(final TimestampServiceRuleConfiguration
ruleConfig) {
configuration = ruleConfig;
- timeService =
TypedSPILoader.getService(ShardingSphereTimeService.class,
ruleConfig.getType(), null == ruleConfig.getProps() ? new Properties() :
ruleConfig.getProps());
+ timestampService = TypedSPILoader.getService(TimestampService.class,
ruleConfig.getType(), null == ruleConfig.getProps() ? new Properties() :
ruleConfig.getProps());
}
/**
- * Get datetime.
+ * Get timestamp.
*
- * @return datetime
+ * @return timestamp
*/
- public Date getDatetime() {
- return timeService.getDatetime();
+ public Timestamp getTimestamp() {
+ return timestampService.getTimestamp();
}
@Override
public String getType() {
- return TimeServiceRule.class.getSimpleName();
+ return TimestampServiceRule.class.getSimpleName();
}
}
diff --git
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/DefaultTimeServiceConfigurationBuilder.java
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/DefaultTimestampServiceConfigurationBuilder.java
similarity index 64%
rename from
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/DefaultTimeServiceConfigurationBuilder.java
rename to
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/DefaultTimestampServiceConfigurationBuilder.java
index 4d2f8fce126..f34858a8426 100644
---
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/DefaultTimeServiceConfigurationBuilder.java
+++
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/DefaultTimestampServiceConfigurationBuilder.java
@@ -18,28 +18,28 @@
package org.apache.shardingsphere.timeservice.core.rule.builder;
import
org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import
org.apache.shardingsphere.timeservice.core.rule.constant.TimeServiceOrder;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import
org.apache.shardingsphere.timeservice.core.rule.constant.TimestampServiceOrder;
import java.util.Properties;
/**
- * Default time service rule configuration builder.
+ * Default timestamp service rule configuration builder.
*/
-public final class DefaultTimeServiceConfigurationBuilder implements
DefaultGlobalRuleConfigurationBuilder<TimeServiceRuleConfiguration,
TimeServiceRuleBuilder> {
+public final class DefaultTimestampServiceConfigurationBuilder implements
DefaultGlobalRuleConfigurationBuilder<TimestampServiceRuleConfiguration,
TimestampServiceRuleBuilder> {
@Override
- public TimeServiceRuleConfiguration build() {
- return new TimeServiceRuleConfiguration("System", new Properties());
+ public TimestampServiceRuleConfiguration build() {
+ return new TimestampServiceRuleConfiguration("System", new
Properties());
}
@Override
public int getOrder() {
- return TimeServiceOrder.ORDER;
+ return TimestampServiceOrder.ORDER;
}
@Override
- public Class<TimeServiceRuleBuilder> getTypeClass() {
- return TimeServiceRuleBuilder.class;
+ public Class<TimestampServiceRuleBuilder> getTypeClass() {
+ return TimestampServiceRuleBuilder.class;
}
}
diff --git
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/TimeServiceRuleBuilder.java
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/TimestampServiceRuleBuilder.java
similarity index 63%
rename from
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/TimeServiceRuleBuilder.java
rename to
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/TimestampServiceRuleBuilder.java
index 724122ef812..d7f094aaa5e 100644
---
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/TimeServiceRuleBuilder.java
+++
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/builder/TimestampServiceRuleBuilder.java
@@ -20,29 +20,29 @@ package
org.apache.shardingsphere.timeservice.core.rule.builder;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
-import
org.apache.shardingsphere.timeservice.core.rule.constant.TimeServiceOrder;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
+import
org.apache.shardingsphere.timeservice.core.rule.constant.TimestampServiceOrder;
import java.util.Map;
/**
- * Time service rule builder.
+ * Timestamp service rule builder.
*/
-public final class TimeServiceRuleBuilder implements
GlobalRuleBuilder<TimeServiceRuleConfiguration> {
+public final class TimestampServiceRuleBuilder implements
GlobalRuleBuilder<TimestampServiceRuleConfiguration> {
@Override
- public TimeServiceRule build(final TimeServiceRuleConfiguration
ruleConfig, final Map<String, ShardingSphereDatabase> databases, final
ConfigurationProperties props) {
- return new TimeServiceRule(ruleConfig);
+ public TimestampServiceRule build(final TimestampServiceRuleConfiguration
ruleConfig, final Map<String, ShardingSphereDatabase> databases, final
ConfigurationProperties props) {
+ return new TimestampServiceRule(ruleConfig);
}
@Override
public int getOrder() {
- return TimeServiceOrder.ORDER;
+ return TimestampServiceOrder.ORDER;
}
@Override
- public Class<TimeServiceRuleConfiguration> getTypeClass() {
- return TimeServiceRuleConfiguration.class;
+ public Class<TimestampServiceRuleConfiguration> getTypeClass() {
+ return TimestampServiceRuleConfiguration.class;
}
}
diff --git
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/constant/TimeServiceOrder.java
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/constant/TimestampServiceOrder.java
similarity index 93%
rename from
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/constant/TimeServiceOrder.java
rename to
kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/constant/TimestampServiceOrder.java
index f98d720be09..43ebf0e18cc 100644
---
a/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/constant/TimeServiceOrder.java
+++
b/kernel/time-service/core/src/main/java/org/apache/shardingsphere/timeservice/core/rule/constant/TimestampServiceOrder.java
@@ -21,10 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
- * Time service order.
+ * Timestamp service order.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class TimeServiceOrder {
+public final class TimestampServiceOrder {
/**
* Time service order.
diff --git
a/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
b/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
index d0254aed0db..8b4d01016e1 100644
---
a/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
+++
b/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.timeservice.core.rule.builder.DefaultTimeServiceConfigurationBuilder
+org.apache.shardingsphere.timeservice.core.rule.builder.DefaultTimestampServiceConfigurationBuilder
diff --git
a/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
b/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
index aac262c2a94..60f3686b404 100644
---
a/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
+++
b/kernel/time-service/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.timeservice.core.rule.builder.TimeServiceRuleBuilder
+org.apache.shardingsphere.timeservice.core.rule.builder.TimestampServiceRuleBuilder
diff --git
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimeService.java
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampService.java
similarity index 83%
rename from
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimeService.java
rename to
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampService.java
index 6d636eb1244..2f6cefed7cb 100644
---
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimeService.java
+++
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampService.java
@@ -22,25 +22,25 @@ import
org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
import
org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import
org.apache.shardingsphere.infra.yaml.config.swapper.resource.YamlDataSourceConfigurationSwapper;
-import org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService;
+import org.apache.shardingsphere.timeservice.spi.TimestampService;
import
org.apache.shardingsphere.timeservice.type.database.exception.DatetimeLoadingException;
-import
org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider;
+import
org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.util.Collections;
-import java.util.Date;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.Collectors;
/**
- * Database time service.
+ * Database timestamp service.
*/
-public final class DatabaseTimeService implements ShardingSphereTimeService {
+public final class DatabaseTimestampService implements TimestampService {
private DataSource dataSource;
@@ -54,21 +54,21 @@ public final class DatabaseTimeService implements
ShardingSphereTimeService {
}
@Override
- public Date getDatetime() {
+ public Timestamp getTimestamp() {
try {
- return loadDatetime(dataSource,
TypedSPILoader.getService(DatetimeLoadingSQLProvider.class,
DatabaseTypeEngine.getTrunkDatabaseTypeName(storageType)).getDatetimeLoadingSQL());
+ return loadDatetime(dataSource,
TypedSPILoader.getService(TimestampLoadingSQLProvider.class,
DatabaseTypeEngine.getTrunkDatabaseTypeName(storageType)).getTimestampLoadingSQL());
} catch (final SQLException ex) {
throw new DatetimeLoadingException(ex);
}
}
- private Date loadDatetime(final DataSource dataSource, final String
datetimeLoadingSQL) throws SQLException {
+ private Timestamp loadDatetime(final DataSource dataSource, final String
datetimeLoadingSQL) throws SQLException {
try (
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement =
connection.prepareStatement(datetimeLoadingSQL)) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
- return (Date) resultSet.getObject(1);
+ return (Timestamp) resultSet.getObject(1);
}
}
}
diff --git
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/DatetimeLoadingSQLProvider.java
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/TimestampLoadingSQLProvider.java
similarity index 83%
rename from
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/DatetimeLoadingSQLProvider.java
rename to
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/TimestampLoadingSQLProvider.java
index 288c7e0174b..eaabf6b2b19 100644
---
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/DatetimeLoadingSQLProvider.java
+++
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/TimestampLoadingSQLProvider.java
@@ -21,15 +21,15 @@ import
org.apache.shardingsphere.infra.util.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
/**
- * Datetime loading SQL provider.
+ * Timestamp loading SQL provider.
*/
@SingletonSPI
-public interface DatetimeLoadingSQLProvider extends TypedSPI {
+public interface TimestampLoadingSQLProvider extends TypedSPI {
/**
- * Get SQL for datetime loading.
+ * Get SQL for timestamp loading.
*
- * @return SQL for datetime loading
+ * @return SQL for timestamp loading
*/
- String getDatetimeLoadingSQL();
+ String getTimestampLoadingSQL();
}
diff --git
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/MySQLDatetimeLoadingSQLProvider.java
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/MySQLTimestampLoadingSQLProvider.java
similarity index 83%
rename from
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/MySQLDatetimeLoadingSQLProvider.java
rename to
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/MySQLTimestampLoadingSQLProvider.java
index bbe2f6455d4..48202411759 100644
---
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/MySQLDatetimeLoadingSQLProvider.java
+++
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/MySQLTimestampLoadingSQLProvider.java
@@ -17,15 +17,15 @@
package org.apache.shardingsphere.timeservice.type.database.provider.dialect;
-import
org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider;
+import
org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
/**
- * Datetime loading SQL provider for MySQL.
+ * Timestamp loading SQL provider for MySQL.
*/
-public final class MySQLDatetimeLoadingSQLProvider implements
DatetimeLoadingSQLProvider {
+public final class MySQLTimestampLoadingSQLProvider implements
TimestampLoadingSQLProvider {
@Override
- public String getDatetimeLoadingSQL() {
+ public String getTimestampLoadingSQL() {
return "SELECT NOW()";
}
diff --git
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/OracleDatetimeLoadingSQLProvider.java
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/OracleTimestampLoadingSQLProvider.java
similarity index 83%
rename from
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/OracleDatetimeLoadingSQLProvider.java
rename to
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/OracleTimestampLoadingSQLProvider.java
index a49452e5951..b067403238d 100644
---
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/OracleDatetimeLoadingSQLProvider.java
+++
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/OracleTimestampLoadingSQLProvider.java
@@ -17,15 +17,15 @@
package org.apache.shardingsphere.timeservice.type.database.provider.dialect;
-import
org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider;
+import
org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
/**
- * Datetime loading SQL provider for Oracle.
+ * Timestamp loading SQL provider for Oracle.
*/
-public final class OracleDatetimeLoadingSQLProvider implements
DatetimeLoadingSQLProvider {
+public final class OracleTimestampLoadingSQLProvider implements
TimestampLoadingSQLProvider {
@Override
- public String getDatetimeLoadingSQL() {
+ public String getTimestampLoadingSQL() {
return "SELECT sysdate FROM DUAL";
}
diff --git
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/PostgreSQLDatetimeLoadingSQLProvider.java
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/PostgreSQLTimestampLoadingSQLProvider.java
similarity index 82%
rename from
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/PostgreSQLDatetimeLoadingSQLProvider.java
rename to
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/PostgreSQLTimestampLoadingSQLProvider.java
index dc3bf8da6f4..e51f77c1c73 100644
---
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/PostgreSQLDatetimeLoadingSQLProvider.java
+++
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/PostgreSQLTimestampLoadingSQLProvider.java
@@ -17,15 +17,15 @@
package org.apache.shardingsphere.timeservice.type.database.provider.dialect;
-import
org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider;
+import
org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
/**
- * Datetime loading SQL provider for PostgreSQL.
+ * Timestamp loading SQL provider for PostgreSQL.
*/
-public final class PostgreSQLDatetimeLoadingSQLProvider implements
DatetimeLoadingSQLProvider {
+public final class PostgreSQLTimestampLoadingSQLProvider implements
TimestampLoadingSQLProvider {
@Override
- public String getDatetimeLoadingSQL() {
+ public String getTimestampLoadingSQL() {
return "SELECT NOW()";
}
diff --git
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/SQLServerDatetimeLoadingSQLProvider.java
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/SQLServerTimestampLoadingSQLProvider.java
similarity index 83%
rename from
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/SQLServerDatetimeLoadingSQLProvider.java
rename to
kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/SQLServerTimestampLoadingSQLProvider.java
index 37f0db086b5..d2cb9306788 100644
---
a/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/SQLServerDatetimeLoadingSQLProvider.java
+++
b/kernel/time-service/type/database/src/main/java/org/apache/shardingsphere/timeservice/type/database/provider/dialect/SQLServerTimestampLoadingSQLProvider.java
@@ -17,15 +17,15 @@
package org.apache.shardingsphere.timeservice.type.database.provider.dialect;
-import
org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider;
+import
org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
/**
- * Datetime loading SQL provider for SQLServer.
+ * Timestamp loading SQL provider for SQLServer.
*/
-public final class SQLServerDatetimeLoadingSQLProvider implements
DatetimeLoadingSQLProvider {
+public final class SQLServerTimestampLoadingSQLProvider implements
TimestampLoadingSQLProvider {
@Override
- public String getDatetimeLoadingSQL() {
+ public String getTimestampLoadingSQL() {
return "SELECT GETDATE()";
}
diff --git
a/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService
b/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.TimestampService
similarity index 98%
rename from
kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService
rename to
kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.TimestampService
index 78543bb9fd0..35114823e5c 100644
---
a/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService
+++
b/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.TimestampService
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.timeservice.type.database.DatabaseTimeService
+org.apache.shardingsphere.timeservice.type.database.DatabaseTimestampService
diff --git
a/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider
b/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider
similarity index 86%
rename from
kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider
rename to
kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider
index 96cc201142d..9ba61f7f11b 100644
---
a/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.type.database.provider.DatetimeLoadingSQLProvider
+++
b/kernel/time-service/type/database/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider
@@ -15,7 +15,7 @@
# limitations under the License.
#
-org.apache.shardingsphere.timeservice.type.database.provider.dialect.PostgreSQLDatetimeLoadingSQLProvider
-org.apache.shardingsphere.timeservice.type.database.provider.dialect.MySQLDatetimeLoadingSQLProvider
-org.apache.shardingsphere.timeservice.type.database.provider.dialect.SQLServerDatetimeLoadingSQLProvider
-org.apache.shardingsphere.timeservice.type.database.provider.dialect.OracleDatetimeLoadingSQLProvider
+org.apache.shardingsphere.timeservice.type.database.provider.dialect.PostgreSQLTimestampLoadingSQLProvider
+org.apache.shardingsphere.timeservice.type.database.provider.dialect.MySQLTimestampLoadingSQLProvider
+org.apache.shardingsphere.timeservice.type.database.provider.dialect.SQLServerTimestampLoadingSQLProvider
+org.apache.shardingsphere.timeservice.type.database.provider.dialect.OracleTimestampLoadingSQLProvider
diff --git
a/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimeServiceTest.java
b/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
similarity index 85%
rename from
kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimeServiceTest.java
rename to
kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
index efc84e4a71a..d1f32af1c71 100644
---
a/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimeServiceTest.java
+++
b/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
@@ -20,17 +20,17 @@ package org.apache.shardingsphere.timeservice.type.database;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
-import org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService;
+import org.apache.shardingsphere.timeservice.spi.TimestampService;
import org.junit.jupiter.api.Test;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertTrue;
-class DatabaseTimeServiceTest {
+class DatabaseTimestampServiceTest {
@Test
- void assertGetDatetime() {
+ void assertTimestamp() {
Properties props = PropertiesBuilder.build(
new Property("dataSourceClassName",
"com.zaxxer.hikari.HikariDataSource"),
new Property("jdbcUrl",
"jdbc:h2:mem:foo_db;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL"),
@@ -38,6 +38,6 @@ class DatabaseTimeServiceTest {
new Property("password", ""),
new Property("maximumPoolSize", "1"));
long currentTime = System.currentTimeMillis();
- assertTrue(TypedSPILoader.getService(ShardingSphereTimeService.class,
"Database", props).getDatetime().getTime() >= currentTime);
+ assertTrue(TypedSPILoader.getService(TimestampService.class,
"Database", props).getTimestamp().getTime() >= currentTime);
}
}
diff --git
a/kernel/time-service/type/system/src/main/java/org/apache/shardingsphere/timeservice/type/system/SystemTimeService.java
b/kernel/time-service/type/system/src/main/java/org/apache/shardingsphere/timeservice/type/system/SystemTimestampService.java
similarity index 76%
rename from
kernel/time-service/type/system/src/main/java/org/apache/shardingsphere/timeservice/type/system/SystemTimeService.java
rename to
kernel/time-service/type/system/src/main/java/org/apache/shardingsphere/timeservice/type/system/SystemTimestampService.java
index d67c17a346e..9e158d93956 100644
---
a/kernel/time-service/type/system/src/main/java/org/apache/shardingsphere/timeservice/type/system/SystemTimeService.java
+++
b/kernel/time-service/type/system/src/main/java/org/apache/shardingsphere/timeservice/type/system/SystemTimestampService.java
@@ -17,18 +17,19 @@
package org.apache.shardingsphere.timeservice.type.system;
-import org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService;
+import org.apache.shardingsphere.timeservice.spi.TimestampService;
-import java.util.Date;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
/**
- * System time service.
+ * System timestamp service.
*/
-public final class SystemTimeService implements ShardingSphereTimeService {
+public final class SystemTimestampService implements TimestampService {
@Override
- public Date getDatetime() {
- return new Date();
+ public Timestamp getTimestamp() {
+ return Timestamp.valueOf(LocalDateTime.now());
}
@Override
diff --git
a/kernel/time-service/type/system/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService
b/kernel/time-service/type/system/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.TimestampService
similarity index 91%
rename from
kernel/time-service/type/system/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService
rename to
kernel/time-service/type/system/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.TimestampService
index e27971a4272..d2ec6f3c53e 100644
---
a/kernel/time-service/type/system/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService
+++
b/kernel/time-service/type/system/src/main/resources/META-INF/services/org.apache.shardingsphere.timeservice.spi.TimestampService
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.timeservice.type.system.SystemTimeService
+org.apache.shardingsphere.timeservice.type.system.SystemTimestampService
diff --git
a/kernel/time-service/type/system/src/test/java/org/apache/shardingsphere/timeservice/type/system/SystemTimeServiceTest.java
b/kernel/time-service/type/system/src/test/java/org/apache/shardingsphere/timeservice/type/system/SystemTimestampServiceTest.java
similarity index 80%
rename from
kernel/time-service/type/system/src/test/java/org/apache/shardingsphere/timeservice/type/system/SystemTimeServiceTest.java
rename to
kernel/time-service/type/system/src/test/java/org/apache/shardingsphere/timeservice/type/system/SystemTimestampServiceTest.java
index e18b7e08c2f..298de49278a 100644
---
a/kernel/time-service/type/system/src/test/java/org/apache/shardingsphere/timeservice/type/system/SystemTimeServiceTest.java
+++
b/kernel/time-service/type/system/src/test/java/org/apache/shardingsphere/timeservice/type/system/SystemTimestampServiceTest.java
@@ -18,16 +18,16 @@
package org.apache.shardingsphere.timeservice.type.system;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.timeservice.spi.ShardingSphereTimeService;
+import org.apache.shardingsphere.timeservice.spi.TimestampService;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
-class SystemTimeServiceTest {
+class SystemTimestampServiceTest {
@Test
- void assertGetDatetime() {
+ void assertGetTimestamp() {
long currentTime = System.currentTimeMillis();
- assertTrue(TypedSPILoader.getService(ShardingSphereTimeService.class,
null).getDatetime().getTime() >= currentTime);
+ assertTrue(TypedSPILoader.getService(TimestampService.class,
null).getTimestamp().getTime() >= currentTime);
}
}
diff --git
a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
index 4cbf5c0814e..2d4c227edd6 100644
---
a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
+++
b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
@@ -60,8 +60,8 @@ import
org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfi
import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
import
org.apache.shardingsphere.test.it.rewrite.engine.parameter.SQLRewriteEngineTestParameters;
import
org.apache.shardingsphere.test.it.rewrite.engine.parameter.SQLRewriteEngineTestParametersBuilder;
-import
org.apache.shardingsphere.timeservice.api.config.TimeServiceRuleConfiguration;
-import org.apache.shardingsphere.timeservice.core.rule.TimeServiceRule;
+import
org.apache.shardingsphere.timeservice.api.config.TimestampServiceRuleConfiguration;
+import org.apache.shardingsphere.timeservice.core.rule.TimestampServiceRule;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -90,7 +90,7 @@ public abstract class SQLRewriterIT {
private final SQLParserRule sqlParserRule = new SQLParserRule(new
SQLParserRuleConfiguration(true,
DefaultSQLParserRuleConfigurationBuilder.PARSE_TREE_CACHE_OPTION,
DefaultSQLParserRuleConfigurationBuilder.SQL_STATEMENT_CACHE_OPTION));
- private final TimeServiceRule timeServiceRule = new TimeServiceRule(new
TimeServiceRuleConfiguration("System", new Properties()));
+ private final TimestampServiceRule timestampServiceRule = new
TimestampServiceRule(new TimestampServiceRuleConfiguration("System", new
Properties()));
@ParameterizedTest(name = "{0}")
@ArgumentsSource(TestCaseArgumentsProvider.class)
@@ -124,7 +124,7 @@ public abstract class SQLRewriterIT {
SQLStatement sqlStatement =
sqlStatementParserEngine.parse(testParams.getInputSQL(), false);
mockRules(databaseRules, schemaName, sqlStatement);
databaseRules.add(sqlParserRule);
- databaseRules.add(timeServiceRule);
+ databaseRules.add(timestampServiceRule);
ShardingSphereDatabase database = new
ShardingSphereDatabase(schemaName, databaseType, resourceMetaData, new
ShardingSphereRuleMetaData(databaseRules), mockSchemas(schemaName));
Map<String, ShardingSphereDatabase> databases = new HashMap<>(2, 1);
databases.put(schemaName, database);