This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 ae8808f52c1 Add global clock rule(#24519) (#24525)
ae8808f52c1 is described below
commit ae8808f52c1b1056d65db05372cae89d0b41196a
Author: ZhangCheng <[email protected]>
AuthorDate: Fri Mar 10 16:35:57 2023 +0800
Add global clock rule(#24519) (#24525)
* Add global clock rule(#24519)
* Fix
---
kernel/{ => global-clock/api}/pom.xml | 25 +++-----
.../api/config/GlobalClockRuleConfiguration.java | 40 ++++++++++++
kernel/{ => global-clock/core}/pom.xml | 30 ++++-----
.../exception/GlobalClockNotEnabledException.java | 32 +++++++++
.../core/exception/GlobalClockSQLException.java | 35 ++++++++++
.../core/provider/GlobalClockProvider.java | 49 ++++++++++++++
.../globalclock/core/rule/GlobalClockRule.java | 75 ++++++++++++++++++++++
...DefaultGlobalClockRuleConfigurationBuilder.java | 45 +++++++++++++
.../core/rule/builder/GlobalClockRuleBuilder.java | 48 ++++++++++++++
.../core/rule/constant/GlobalClockOrder.java | 29 +++++++++
.../config/YamlGlobalClockRuleConfiguration.java | 46 +++++++++++++
.../YamlGlobalClockRuleConfigurationSwapper.java | 61 ++++++++++++++++++
...er.global.DefaultGlobalRuleConfigurationBuilder | 18 ++++++
...ere.infra.rule.builder.global.GlobalRuleBuilder | 18 ++++++
...onfig.swapper.rule.YamlRuleConfigurationSwapper | 18 ++++++
kernel/{ => global-clock}/pom.xml | 18 ++----
kernel/{ => global-clock/type/hlc}/pom.xml | 31 ++++-----
.../globalclock/type/hlc/HLCProvider.java | 26 ++++++++
kernel/{ => global-clock/type}/pom.xml | 17 ++---
kernel/{ => global-clock/type/tso/core}/pom.xml | 36 ++++++-----
.../type/tso/provider/LocalTSOProvider.java | 53 +++++++++++++++
.../globalclock/type/tso/provider/TSOProvider.java | 26 ++++++++
...e.globalclock.core.provider.GlobalClockProvider | 18 ++++++
kernel/{ => global-clock/type/tso}/pom.xml | 17 ++---
.../{ => global-clock/type/tso/provider}/pom.xml | 16 +----
.../type/tso/provider/redis}/pom.xml | 36 ++++++-----
.../type/tso/provider/RedisTSOProvider.java | 45 +++++++++++++
...e.globalclock.core.provider.GlobalClockProvider | 18 ++++++
kernel/pom.xml | 1 +
proxy/backend/core/pom.xml | 10 +++
.../config/yaml/YamlProxyServerConfiguration.java | 3 +
31 files changed, 807 insertions(+), 133 deletions(-)
diff --git a/kernel/pom.xml b/kernel/global-clock/api/pom.xml
similarity index 70%
copy from kernel/pom.xml
copy to kernel/global-clock/api/pom.xml
index 101c65993cb..740faed9b2a 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/api/pom.xml
@@ -21,24 +21,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-global-clock-api</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/kernel/global-clock/api/src/main/java/org/apache/shardingsphere/globalclock/api/config/GlobalClockRuleConfiguration.java
b/kernel/global-clock/api/src/main/java/org/apache/shardingsphere/globalclock/api/config/GlobalClockRuleConfiguration.java
new file mode 100644
index 00000000000..cc2f09a0ac1
--- /dev/null
+++
b/kernel/global-clock/api/src/main/java/org/apache/shardingsphere/globalclock/api/config/GlobalClockRuleConfiguration.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.api.config;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.infra.config.rule.scope.GlobalRuleConfiguration;
+
+import java.util.Properties;
+
+/**
+ * Global clock rule configuration.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class GlobalClockRuleConfiguration implements
GlobalRuleConfiguration {
+
+ private final String type;
+
+ private final String provider;
+
+ private final boolean enabled;
+
+ private final Properties props;
+}
diff --git a/kernel/pom.xml b/kernel/global-clock/core/pom.xml
similarity index 68%
copy from kernel/pom.xml
copy to kernel/global-clock/core/pom.xml
index 101c65993cb..3325274774f 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/core/pom.xml
@@ -21,24 +21,22 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-global-clock-core</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockNotEnabledException.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockNotEnabledException.java
new file mode 100644
index 00000000000..0202f2356f3
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockNotEnabledException.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.exception;
+
+import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
+/**
+ * Global clock not enabled exception.
+ */
+public final class GlobalClockNotEnabledException extends
GlobalClockSQLException {
+
+ private static final long serialVersionUID = 2499130145956182704L;
+
+ public GlobalClockNotEnabledException() {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 1, "The global clock rule
has not been enabled");
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockSQLException.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockSQLException.java
new file mode 100644
index 00000000000..6380049cce5
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/exception/GlobalClockSQLException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.exception;
+
+import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.SQLState;
+import
org.apache.shardingsphere.infra.util.exception.external.sql.type.kernel.KernelSQLException;
+
+/**
+ * Global clock SQL exception.
+ */
+public abstract class GlobalClockSQLException extends KernelSQLException {
+
+ private static final long serialVersionUID = -2262893200471389177L;
+
+ private static final int KERNEL_CODE = 10;
+
+ public GlobalClockSQLException(final SQLState sqlState, final int
errorCode, final String reason, final Object... messageArgs) {
+ super(sqlState, KERNEL_CODE, errorCode, reason, messageArgs);
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/provider/GlobalClockProvider.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/provider/GlobalClockProvider.java
new file mode 100644
index 00000000000..638f1988262
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/provider/GlobalClockProvider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.provider;
+
+import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
+
+import java.util.Properties;
+
+/**
+ * Global clock provider.
+ */
+public interface GlobalClockProvider extends TypedSPI {
+
+ /**
+ * Initialize global clock provider.
+ *
+ * @param props properties to be initialized
+ */
+ void init(Properties props);
+
+ /**
+ * Get current timestamp.
+ *
+ * @return current timestamp
+ */
+ long getCurrentTimestamp();
+
+ /**
+ * Get next timestamp.
+ *
+ * @return next timestamp
+ */
+ long getNextTimestamp();
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/GlobalClockRule.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/GlobalClockRule.java
new file mode 100644
index 00000000000..5e049484f11
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/GlobalClockRule.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.rule;
+
+import lombok.Getter;
+import
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
+import
org.apache.shardingsphere.globalclock.core.exception.GlobalClockNotEnabledException;
+import org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider;
+import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
+import
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
+
+import java.util.Optional;
+import java.util.Properties;
+
+/**
+ * Global clock rule.
+ */
+public final class GlobalClockRule implements GlobalRule {
+
+ @Getter
+ private final GlobalClockRuleConfiguration configuration;
+
+ private final GlobalClockProvider globalClockProvider;
+
+ private final boolean enabled;
+
+ public GlobalClockRule(final GlobalClockRuleConfiguration ruleConfig) {
+ configuration = ruleConfig;
+ enabled = ruleConfig.isEnabled();
+ globalClockProvider = enabled ?
TypedSPILoader.getService(GlobalClockProvider.class, String.join(".",
ruleConfig.getType(), ruleConfig.getProvider()),
+ null == ruleConfig.getProps() ? new Properties() :
ruleConfig.getProps()) : null;
+ Optional.ofNullable(globalClockProvider).ifPresent(optional ->
optional.init(ruleConfig.getProps()));
+ }
+
+ /**
+ * Get current timestamp.
+ *
+ * @return current timestamp
+ */
+ public long getCurrentTimestamp() {
+ ShardingSpherePreconditions.checkState(enabled,
GlobalClockNotEnabledException::new);
+ return globalClockProvider.getCurrentTimestamp();
+ }
+
+ /**
+ * Get next timestamp.
+ *
+ * @return next timestamp
+ */
+ public long getNextTimestamp() {
+ ShardingSpherePreconditions.checkState(enabled,
GlobalClockNotEnabledException::new);
+ return globalClockProvider.getNextTimestamp();
+ }
+
+ @Override
+ public String getType() {
+ return GlobalClockRule.class.getSimpleName();
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/builder/DefaultGlobalClockRuleConfigurationBuilder.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/builder/DefaultGlobalClockRuleConfigurationBuilder.java
new file mode 100644
index 00000000000..e985a46d23a
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/builder/DefaultGlobalClockRuleConfigurationBuilder.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.rule.builder;
+
+import
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
+import
org.apache.shardingsphere.globalclock.core.rule.constant.GlobalClockOrder;
+import
org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder;
+
+import java.util.Properties;
+
+/**
+ * Default global clock rule configuration builder.
+ */
+public final class DefaultGlobalClockRuleConfigurationBuilder implements
DefaultGlobalRuleConfigurationBuilder<GlobalClockRuleConfiguration,
GlobalClockRuleBuilder> {
+
+ @Override
+ public GlobalClockRuleConfiguration build() {
+ return new GlobalClockRuleConfiguration("TSO", "local", false, new
Properties());
+ }
+
+ @Override
+ public int getOrder() {
+ return GlobalClockOrder.ORDER;
+ }
+
+ @Override
+ public Class<GlobalClockRuleBuilder> getTypeClass() {
+ return GlobalClockRuleBuilder.class;
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/builder/GlobalClockRuleBuilder.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/builder/GlobalClockRuleBuilder.java
new file mode 100644
index 00000000000..c0f19e0be68
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/builder/GlobalClockRuleBuilder.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.rule.builder;
+
+import
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
+import org.apache.shardingsphere.globalclock.core.rule.GlobalClockRule;
+import
org.apache.shardingsphere.globalclock.core.rule.constant.GlobalClockOrder;
+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 java.util.Map;
+
+/**
+ * Global clock rule builder.
+ */
+public final class GlobalClockRuleBuilder implements
GlobalRuleBuilder<GlobalClockRuleConfiguration> {
+
+ @Override
+ public GlobalClockRule build(final GlobalClockRuleConfiguration
ruleConfig, final Map<String, ShardingSphereDatabase> databases, final
ConfigurationProperties props) {
+ return new GlobalClockRule(ruleConfig);
+ }
+
+ @Override
+ public int getOrder() {
+ return GlobalClockOrder.ORDER;
+ }
+
+ @Override
+ public Class<GlobalClockRuleConfiguration> getTypeClass() {
+ return GlobalClockRuleConfiguration.class;
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/constant/GlobalClockOrder.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/constant/GlobalClockOrder.java
new file mode 100644
index 00000000000..360be92dd26
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/rule/constant/GlobalClockOrder.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.rule.constant;
+
+/**
+ * Global clock order.
+ */
+public final class GlobalClockOrder {
+
+ /**
+ * Global clock order.
+ */
+ public static final int ORDER = 1200;
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/config/YamlGlobalClockRuleConfiguration.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/config/YamlGlobalClockRuleConfiguration.java
new file mode 100644
index 00000000000..b63b055f7dc
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/config/YamlGlobalClockRuleConfiguration.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.yaml.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+
+import java.util.Properties;
+
+/**
+ * Global clock rule configuration for YAML.
+ */
+@Getter
+@Setter
+public final class YamlGlobalClockRuleConfiguration implements
YamlGlobalRuleConfiguration {
+
+ private String type;
+
+ private String provider;
+
+ private boolean enabled;
+
+ private Properties props;
+
+ @Override
+ public Class<GlobalClockRuleConfiguration> getRuleConfigurationType() {
+ return GlobalClockRuleConfiguration.class;
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/YamlGlobalClockRuleConfigurationSwapper.java
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/YamlGlobalClockRuleConfigurationSwapper.java
new file mode 100644
index 00000000000..7f64558a903
--- /dev/null
+++
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/core/yaml/swapper/YamlGlobalClockRuleConfigurationSwapper.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.core.yaml.swapper;
+
+import
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
+import
org.apache.shardingsphere.globalclock.core.rule.constant.GlobalClockOrder;
+import
org.apache.shardingsphere.globalclock.core.yaml.config.YamlGlobalClockRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
+
+import java.util.Properties;
+
+/**
+ * YAML global clock rule configuration swapper.
+ */
+public final class YamlGlobalClockRuleConfigurationSwapper implements
YamlRuleConfigurationSwapper<YamlGlobalClockRuleConfiguration,
GlobalClockRuleConfiguration> {
+
+ @Override
+ public YamlGlobalClockRuleConfiguration swapToYamlConfiguration(final
GlobalClockRuleConfiguration data) {
+ YamlGlobalClockRuleConfiguration result = new
YamlGlobalClockRuleConfiguration();
+ result.setType(data.getType());
+ result.setProvider(data.getProvider());
+ result.setEnabled(data.isEnabled());
+ result.setProps(data.getProps());
+ return result;
+ }
+
+ @Override
+ public GlobalClockRuleConfiguration swapToObject(final
YamlGlobalClockRuleConfiguration yamlConfig) {
+ return new GlobalClockRuleConfiguration(yamlConfig.getType(),
yamlConfig.getProvider(), yamlConfig.isEnabled(), null == yamlConfig.getProps()
? new Properties() : yamlConfig.getProps());
+ }
+
+ @Override
+ public String getRuleTagName() {
+ return "GLOBAL_CLOCK";
+ }
+
+ @Override
+ public int getOrder() {
+ return GlobalClockOrder.ORDER;
+ }
+
+ @Override
+ public Class<GlobalClockRuleConfiguration> getTypeClass() {
+ return GlobalClockRuleConfiguration.class;
+ }
+}
diff --git
a/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
new file mode 100644
index 00000000000..05d362c7657
--- /dev/null
+++
b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.globalclock.core.rule.builder.DefaultGlobalClockRuleConfigurationBuilder
diff --git
a/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
new file mode 100644
index 00000000000..452d3de28ae
--- /dev/null
+++
b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.globalclock.core.rule.builder.GlobalClockRuleBuilder
diff --git
a/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
new file mode 100644
index 00000000000..476fb56ee72
--- /dev/null
+++
b/kernel/global-clock/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.globalclock.core.yaml.swapper.YamlGlobalClockRuleConfigurationSwapper
diff --git a/kernel/pom.xml b/kernel/global-clock/pom.xml
similarity index 73%
copy from kernel/pom.xml
copy to kernel/global-clock/pom.xml
index 101c65993cb..ac46f3bf676 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/pom.xml
@@ -21,24 +21,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-kernel</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
+ <artifactId>shardingsphere-global-clock</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
+ <module>api</module>
+ <module>core</module>
+ <module>type</module>
</modules>
</project>
diff --git a/kernel/pom.xml b/kernel/global-clock/type/hlc/pom.xml
similarity index 67%
copy from kernel/pom.xml
copy to kernel/global-clock/type/hlc/pom.xml
index 101c65993cb..d86439ecb9d 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/type/hlc/pom.xml
@@ -21,24 +21,21 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock-type</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
+ <artifactId>shardingsphere-global-clock-hlc</artifactId>
- <modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/kernel/global-clock/type/hlc/src/main/java/org/apache/shardingsphere/globalclock/type/hlc/HLCProvider.java
b/kernel/global-clock/type/hlc/src/main/java/org/apache/shardingsphere/globalclock/type/hlc/HLCProvider.java
new file mode 100644
index 00000000000..fb1d8f11310
--- /dev/null
+++
b/kernel/global-clock/type/hlc/src/main/java/org/apache/shardingsphere/globalclock/type/hlc/HLCProvider.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.type.hlc;
+
+import org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider;
+
+/**
+ * Hybrid logical clock provider.
+ */
+public interface HLCProvider extends GlobalClockProvider {
+}
diff --git a/kernel/pom.xml b/kernel/global-clock/type/pom.xml
similarity index 73%
copy from kernel/pom.xml
copy to kernel/global-clock/type/pom.xml
index 101c65993cb..84bccacf087 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/type/pom.xml
@@ -21,24 +21,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
+ <artifactId>shardingsphere-global-clock-type</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
+ <module>hlc</module>
+ <module>tso</module>
</modules>
</project>
diff --git a/kernel/pom.xml b/kernel/global-clock/type/tso/core/pom.xml
similarity index 59%
copy from kernel/pom.xml
copy to kernel/global-clock/type/tso/core/pom.xml
index 101c65993cb..558e948a9ee 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/type/tso/core/pom.xml
@@ -21,24 +21,28 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock-tso</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-global-clock-tso-core</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-fixture-infra</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/kernel/global-clock/type/tso/core/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/LocalTSOProvider.java
b/kernel/global-clock/type/tso/core/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/LocalTSOProvider.java
new file mode 100644
index 00000000000..a9edf3e859c
--- /dev/null
+++
b/kernel/global-clock/type/tso/core/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/LocalTSOProvider.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.type.tso.provider;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Local timestamp oracle provider.
+ */
+public class LocalTSOProvider implements TSOProvider {
+
+ private final AtomicLong localClock = new AtomicLong();
+
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public long getCurrentTimestamp() {
+ return localClock.get();
+ }
+
+ @Override
+ public long getNextTimestamp() {
+ return localClock.incrementAndGet();
+ }
+
+ @Override
+ public String getType() {
+ return "TSO.local";
+ }
+
+ @Override
+ public boolean isDefault() {
+ return true;
+ }
+}
diff --git
a/kernel/global-clock/type/tso/core/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/TSOProvider.java
b/kernel/global-clock/type/tso/core/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/TSOProvider.java
new file mode 100644
index 00000000000..bc46bbd91e4
--- /dev/null
+++
b/kernel/global-clock/type/tso/core/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/TSOProvider.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.type.tso.provider;
+
+import org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider;
+
+/**
+ * Timestamp oracle provider.
+ */
+public interface TSOProvider extends GlobalClockProvider {
+}
diff --git
a/kernel/global-clock/type/tso/core/src/main/resources/META-INF/services/org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider
b/kernel/global-clock/type/tso/core/src/main/resources/META-INF/services/org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider
new file mode 100644
index 00000000000..9335d6062a9
--- /dev/null
+++
b/kernel/global-clock/type/tso/core/src/main/resources/META-INF/services/org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.globalclock.type.tso.provider.LocalTSOProvider
diff --git a/kernel/pom.xml b/kernel/global-clock/type/tso/pom.xml
similarity index 73%
copy from kernel/pom.xml
copy to kernel/global-clock/type/tso/pom.xml
index 101c65993cb..61138983117 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/type/tso/pom.xml
@@ -21,24 +21,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock-type</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
+ <artifactId>shardingsphere-global-clock-tso</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
+ <module>core</module>
+ <module>provider</module>
</modules>
</project>
diff --git a/kernel/pom.xml b/kernel/global-clock/type/tso/provider/pom.xml
similarity index 73%
copy from kernel/pom.xml
copy to kernel/global-clock/type/tso/provider/pom.xml
index 101c65993cb..12c61f0ac41 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/type/tso/provider/pom.xml
@@ -21,24 +21,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock-tso</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
+ <artifactId>shardingsphere-global-clock-tso-provider</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
+ <module>redis</module>
</modules>
</project>
diff --git a/kernel/pom.xml
b/kernel/global-clock/type/tso/provider/redis/pom.xml
similarity index 59%
copy from kernel/pom.xml
copy to kernel/global-clock/type/tso/provider/redis/pom.xml
index 101c65993cb..d044b45cf91 100644
--- a/kernel/pom.xml
+++ b/kernel/global-clock/type/tso/provider/redis/pom.xml
@@ -21,24 +21,28 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-global-clock-tso-provider</artifactId>
<version>5.3.2-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-global-clock-tso-provider-redis</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>parser</module>
- <module>single</module>
- <module>authority</module>
- <module>transaction</module>
- <module>time-service</module>
- <module>schedule</module>
- <module>data-pipeline</module>
- <module>sql-federation</module>
- <module>sql-translator</module>
- <module>traffic</module>
- <module>logging</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-tso-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-fixture-infra</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java
b/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java
new file mode 100644
index 00000000000..66ff2c24c6e
--- /dev/null
+++
b/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.globalclock.type.tso.provider;
+
+import java.util.Properties;
+
+/**
+ * Redis timestamp oracle provider.
+ */
+public class RedisTSOProvider implements TSOProvider {
+
+ @Override
+ public void init(final Properties props) {
+ }
+
+ @Override
+ public long getCurrentTimestamp() {
+ return 0;
+ }
+
+ @Override
+ public long getNextTimestamp() {
+ return 0;
+ }
+
+ @Override
+ public String getType() {
+ return "TSO.redis";
+ }
+}
diff --git
a/kernel/global-clock/type/tso/provider/redis/src/main/resources/META-INF/services/org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider
b/kernel/global-clock/type/tso/provider/redis/src/main/resources/META-INF/services/org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider
new file mode 100644
index 00000000000..1549e8dc05f
--- /dev/null
+++
b/kernel/global-clock/type/tso/provider/redis/src/main/resources/META-INF/services/org.apache.shardingsphere.globalclock.core.provider.GlobalClockProvider
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.globalclock.type.tso.provider.RedisTSOProvider
diff --git a/kernel/pom.xml b/kernel/pom.xml
index 101c65993cb..bf3a6d2423b 100644
--- a/kernel/pom.xml
+++ b/kernel/pom.xml
@@ -40,5 +40,6 @@
<module>sql-translator</module>
<module>traffic</module>
<module>logging</module>
+ <module>global-clock</module>
</modules>
</project>
diff --git a/proxy/backend/core/pom.xml b/proxy/backend/core/pom.xml
index a579b464f8d..70436823070 100644
--- a/proxy/backend/core/pom.xml
+++ b/proxy/backend/core/pom.xml
@@ -143,6 +143,16 @@
<artifactId>shardingsphere-transaction-xa-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-core</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-global-clock-tso-core</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-data-pipeline-mysql</artifactId>
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
index 81155e2045f..2c2b268aca1 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.proxy.backend.config.yaml;
import lombok.Getter;
import lombok.Setter;
import
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
+import
org.apache.shardingsphere.globalclock.core.yaml.config.YamlGlobalClockRuleConfiguration;
import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
import
org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration;
import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
@@ -54,6 +55,8 @@ public final class YamlProxyServerConfiguration implements
YamlConfiguration {
private YamlLoggingRuleConfiguration logging;
+ private YamlGlobalClockRuleConfiguration globalClock;
+
private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
private Properties props = new Properties();