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 c1308788b1a Refactor schedule module to split 
StandaloneScheduleStrategy and ClusterScheduleStrategy (#19142)
c1308788b1a is described below

commit c1308788b1af81efd2e838852106048afda48912
Author: zhaojinchao <[email protected]>
AuthorDate: Thu Jul 14 18:29:19 2022 +0800

    Refactor schedule module to split StandaloneScheduleStrategy and 
ClusterScheduleStrategy (#19142)
    
    * Refactor schedule module to plan support standalone scheduler
    
    * Rename scheduler to schedule
    
    * Fix ci
    
    * Modify it.
    
    * Fix unit test
    
    * Add final
    
    * fix ci
---
 .../dbdiscovery/rule/DatabaseDiscoveryRule.java    | 12 ++--
 .../datasource/ShardingSphereDataSourceTest.java   |  3 -
 .../src/test/resources/logback-test.xml            |  2 +-
 ...extFactory.java => ScheduleContextFactory.java} | 29 ++++++----
 .../schedule/core/{api => model}/CronJob.java      |  2 +-
 .../schedule/core/{api => model}/JobParameter.java |  2 +-
 .../ScheduleStrategy.java}                         | 15 ++++-
 .../type/ClusterScheduleStrategy.java}             | 66 +++++++---------------
 .../type/StandaloneScheduleStrategy.java}          | 14 ++++-
 .../cluster/ClusterContextManagerBuilder.java      |  4 +-
 .../src/test/resources/logback-test.xml            |  2 +-
 .../StandaloneContextManagerBuilder.java           |  2 +
 .../src/test/resources/logback-test.xml            |  2 +-
 13 files changed, 75 insertions(+), 80 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
index 68bd065abc9..0ce183d61ca 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
@@ -41,9 +41,9 @@ import 
org.apache.shardingsphere.infra.rule.identifier.type.exportable.Exportabl
 import org.apache.shardingsphere.mode.metadata.storage.StorageNodeStatus;
 import 
org.apache.shardingsphere.mode.metadata.storage.event.PrimaryDataSourceChangedEvent;
 import 
org.apache.shardingsphere.mode.metadata.storage.event.StorageNodeDataSourceChangedEvent;
-import org.apache.shardingsphere.schedule.core.api.CronJob;
-import org.apache.shardingsphere.schedule.core.api.ModeScheduleContext;
-import org.apache.shardingsphere.schedule.core.api.ModeScheduleContextFactory;
+import org.apache.shardingsphere.schedule.core.model.CronJob;
+import org.apache.shardingsphere.schedule.core.ScheduleContextFactory;
+import org.apache.shardingsphere.schedule.core.strategy.ScheduleStrategy;
 
 import javax.sql.DataSource;
 import java.util.Collection;
@@ -166,15 +166,15 @@ public final class DatabaseDiscoveryRule implements 
DatabaseRule, DataSourceCont
     }
     
     private void initHeartBeatJobs(final String instanceId) {
-        Optional<ModeScheduleContext> modeScheduleContext = 
ModeScheduleContextFactory.getInstance().get(instanceId);
-        if (modeScheduleContext.isPresent()) {
+        Optional<ScheduleStrategy> scheduleStrategy = 
ScheduleContextFactory.getInstance().get(instanceId);
+        if (scheduleStrategy.isPresent()) {
             for (Entry<String, DatabaseDiscoveryDataSourceRule> entry : 
dataSourceRules.entrySet()) {
                 DatabaseDiscoveryDataSourceRule rule = entry.getValue();
                 String jobName = 
rule.getDatabaseDiscoveryProviderAlgorithm().getType() + "-" + databaseName + 
"-" + rule.getGroupName();
                 CronJob job = new CronJob(jobName, each -> new 
HeartbeatJob(databaseName, rule.getGroupName(), 
rule.getPrimaryDataSourceName(), rule.getDataSourceGroup(dataSourceMap),
                         rule.getDatabaseDiscoveryProviderAlgorithm(), 
rule.getDisabledDataSourceNames(), 
instanceContext.getEventBusContext()).execute(null),
                         
rule.getHeartbeatProps().getProperty("keep-alive-cron"));
-                modeScheduleContext.get().startCronJob(job);
+                scheduleStrategy.get().startSchedule(job);
             }
         }
     }
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
index c4ec0c9658a..a1d4c990641 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.infra.state.StateType;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
-import org.apache.shardingsphere.transaction.rule.TransactionRule;
 import org.junit.After;
 import org.junit.Test;
 
@@ -58,7 +57,6 @@ public final class ShardingSphereDataSourceTest {
         ShardingSphereDataSource actual = new 
ShardingSphereDataSource(DefaultDatabase.LOGIC_NAME, null);
         ContextManager contextManager = getContextManager(actual);
         
assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabases().containsKey(DefaultDatabase.LOGIC_NAME));
-        TransactionRule transactionRule = 
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(TransactionRule.class);
         
assertThat(contextManager.getInstanceContext().getInstance().getState().getCurrentState(),
 is(StateType.OK));
         
assertTrue(contextManager.getDataSourceMap(DefaultDatabase.LOGIC_NAME).isEmpty());
     }
@@ -70,7 +68,6 @@ public final class ShardingSphereDataSourceTest {
         ShardingSphereDataSource actual = createShardingSphereDataSource(new 
MockedDataSource(connection));
         ContextManager contextManager = getContextManager(actual);
         
assertTrue(contextManager.getMetaDataContexts().getMetaData().getDatabases().containsKey(DefaultDatabase.LOGIC_NAME));
-        TransactionRule transactionRule = 
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(TransactionRule.class);
         
assertThat(contextManager.getInstanceContext().getInstance().getState().getCurrentState(),
 is(StateType.OK));
         
assertThat(contextManager.getDataSourceMap(DefaultDatabase.LOGIC_NAME).size(), 
is(1));
         
assertThat(contextManager.getDataSourceMap(DefaultDatabase.LOGIC_NAME).get("ds").getConnection().getMetaData().getURL(),
 is("jdbc:mock://127.0.0.1/foo_ds"));
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/logback-test.xml
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/logback-test.xml
index 064918a0829..29123bfa8f2 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/logback-test.xml
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/logback-test.xml
@@ -25,7 +25,7 @@
     <logger name="org.apache.shardingsphere" level="warn" additivity="false">
         <appender-ref ref="console" />
     </logger>
-    <logger 
name="org.apache.shardingsphere.schedule.core.api.ModeScheduleContext" 
level="error" />
+    <logger name="org.apache.shardingsphere.schedule.core.ModeScheduleContext" 
level="error" />
     <logger 
name="org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service.ComputeNodeStatusService"
 level="off" />
     
     <root>
diff --git 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/ModeScheduleContextFactory.java
 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/ScheduleContextFactory.java
similarity index 55%
rename from 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/ModeScheduleContextFactory.java
rename to 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/ScheduleContextFactory.java
index c43e59453ec..18742bf9252 100644
--- 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/ModeScheduleContextFactory.java
+++ 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/ScheduleContextFactory.java
@@ -15,54 +15,59 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.schedule.core.api;
+package org.apache.shardingsphere.schedule.core;
 
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.schedule.core.strategy.ScheduleStrategy;
+import 
org.apache.shardingsphere.schedule.core.strategy.type.ClusterScheduleStrategy;
+import 
org.apache.shardingsphere.schedule.core.strategy.type.StandaloneScheduleStrategy;
 
 import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
- * Mode schedule context factory.
+ * Schedule context factory.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 @Getter
-public final class ModeScheduleContextFactory {
+public final class ScheduleContextFactory {
     
-    private static final ModeScheduleContextFactory INSTANCE = new 
ModeScheduleContextFactory();
+    private static final ScheduleContextFactory INSTANCE = new 
ScheduleContextFactory();
     
-    private final Map<String, ModeScheduleContext> modeScheduleContexts = new 
ConcurrentHashMap<>();
+    private final Map<String, ScheduleStrategy> scheduleStrategy = new 
ConcurrentHashMap<>();
     
     /**
      * Get instance.
      *
      * @return singleton instance
      */
-    public static ModeScheduleContextFactory getInstance() {
+    public static ScheduleContextFactory getInstance() {
         return INSTANCE;
     }
     
     /**
-     * Init mode schedule context.
+     * Init schedule context.
      * 
      * @param instanceId instance id
      * @param modeConfig mode configuration
      */
     public void init(final String instanceId, final ModeConfiguration 
modeConfig) {
-        modeScheduleContexts.put(instanceId, new 
ModeScheduleContext(modeConfig));
+        scheduleStrategy.put(instanceId, 
"Cluster".equalsIgnoreCase(modeConfig.getType()) && 
"ZooKeeper".equalsIgnoreCase(modeConfig.getRepository().getType())
+                ? new 
ClusterScheduleStrategy(modeConfig.getRepository().getProps().getProperty("server-lists"),
 modeConfig.getRepository().getProps().getProperty("namespace"))
+                : new StandaloneScheduleStrategy());
     }
     
     /**
-     * Get mode schedule context.
+     * Get schedule strategy.
      * 
      * @param instanceId instance id
-     * @return got mode schedule context
+     * @return get schedule strategy
      */
-    public Optional<ModeScheduleContext> get(final String instanceId) {
-        return Optional.ofNullable(modeScheduleContexts.get(instanceId));
+    public Optional<ScheduleStrategy> get(final String instanceId) {
+        return Optional.ofNullable(scheduleStrategy.get(instanceId));
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/CronJob.java
 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/model/CronJob.java
similarity index 95%
rename from 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/CronJob.java
rename to 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/model/CronJob.java
index dbf840ee13c..9c56aa60524 100644
--- 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/CronJob.java
+++ 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/model/CronJob.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.schedule.core.api;
+package org.apache.shardingsphere.schedule.core.model;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
diff --git 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/model/JobParameter.java
similarity index 94%
copy from 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
copy to 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/model/JobParameter.java
index 36931ebe9ba..7b0808ab186 100644
--- 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
+++ 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/model/JobParameter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.schedule.core.api;
+package org.apache.shardingsphere.schedule.core.model;
 
 /**
  * Schedule job parameter.
diff --git 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/ScheduleStrategy.java
similarity index 73%
copy from 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
copy to 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/ScheduleStrategy.java
index 36931ebe9ba..ebfebc6a299 100644
--- 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
+++ 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/ScheduleStrategy.java
@@ -15,10 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.schedule.core.api;
+package org.apache.shardingsphere.schedule.core.strategy;
+
+import org.apache.shardingsphere.schedule.core.model.CronJob;
 
 /**
- * Schedule job parameter.
+ * Schedule Strategy.
  */
-public final class JobParameter {
+public interface ScheduleStrategy {
+    
+    /**
+     * Start schedule.
+     *
+     * @param job cron job
+     */
+    void startSchedule(CronJob job);
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/ModeScheduleContext.java
 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/type/ClusterScheduleStrategy.java
similarity index 60%
rename from 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/ModeScheduleContext.java
rename to 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/type/ClusterScheduleStrategy.java
index 85bf8ab66a6..0da283f6cdf 100644
--- 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/ModeScheduleContext.java
+++ 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/type/ClusterScheduleStrategy.java
@@ -15,8 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.schedule.core.api;
+package org.apache.shardingsphere.schedule.core.strategy.type;
 
+import com.google.common.base.Preconditions;
 import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
@@ -29,77 +30,44 @@ import 
org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 import 
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
 import 
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
 import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
-import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.schedule.core.model.CronJob;
+import org.apache.shardingsphere.schedule.core.model.JobParameter;
+import org.apache.shardingsphere.schedule.core.strategy.ScheduleStrategy;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
 import java.util.function.Consumer;
 
 /**
- * Mode schedule context, used for proxy and jdbc.
+ * Cluster schedule strategy.
  */
 @RequiredArgsConstructor
 @Slf4j
-public final class ModeScheduleContext {
+public final class ClusterScheduleStrategy implements ScheduleStrategy {
     
     private static final Map<String, ScheduleJobBootstrap> 
SCHEDULE_JOB_BOOTSTRAP_MAP = new HashMap<>();
     
-    private final ModeConfiguration modeConfig;
+    private final String serverList;
+    
+    private final String namespace;
     
     private final LazyInitializer<CoordinatorRegistryCenter> 
registryCenterLazyInitializer = new 
LazyInitializer<CoordinatorRegistryCenter>() {
         
         @Override
         protected CoordinatorRegistryCenter initialize() {
-            return initRegistryCenter(modeConfig);
+            return initRegisterCenter();
         }
     };
     
-    private CoordinatorRegistryCenter initRegistryCenter(final 
ModeConfiguration modeConfig) {
-        if (null == modeConfig) {
-            return null;
-        }
-        String modeType = modeConfig.getType().toUpperCase();
-        switch (modeType) {
-            // TODO do not hard-code mode type, refactor later
-            case "CLUSTER":
-                return initRegistryCenterForClusterMode(modeConfig);
-            case "STANDALONE":
-                return null;
-            default:
-                // TODO ModeConfiguration.type is not limited, it could be any 
value
-                log.warn("Unknown mode type '{}'", modeType);
-                return null;
-        }
-    }
-    
-    private CoordinatorRegistryCenter initRegistryCenterForClusterMode(final 
ModeConfiguration modeConfig) {
-        String clusterType = modeConfig.getRepository().getType();
-        Properties props = modeConfig.getRepository().getProps();
-        // TODO do not hard-code cluster type and property key, refactor later
-        if ("ZooKeeper".equalsIgnoreCase(clusterType)) {
-            ZookeeperConfiguration zkConfig = new 
ZookeeperConfiguration(props.getProperty("server-lists"), 
props.getProperty("namespace"));
-            // TODO add timeout settings; CoordinatorRegistryCenterInitializer 
could not be used for now since dependency;
-            CoordinatorRegistryCenter result = new 
ZookeeperRegistryCenter(zkConfig);
-            result.init();
-            return result;
-        }
-        log.warn("Unsupported clusterType '{}'", clusterType);
-        return null;
-    }
-    
     /**
-     * Start cron job.
+     * Start schedule.
      *
      * @param job cron job
      */
     @SuppressWarnings("unchecked")
-    public void startCronJob(final CronJob job) {
+    public void startSchedule(final CronJob job) {
         CoordinatorRegistryCenter registryCenter = getRegistryCenter();
-        if (null == registryCenter) {
-            log.warn("registryCenter is null, ignore, jobName={}, cron={}", 
job.getJobName(), job.getCron());
-            return;
-        }
+        Preconditions.checkNotNull(registryCenter, "Coordinator registry 
center failed to initialize.");
         if (null != SCHEDULE_JOB_BOOTSTRAP_MAP.get(job.getJobName())) {
             SCHEDULE_JOB_BOOTSTRAP_MAP.get(job.getJobName()).shutdown();
         }
@@ -114,6 +82,12 @@ public final class ModeScheduleContext {
         return registryCenterLazyInitializer.get();
     }
     
+    private CoordinatorRegistryCenter initRegisterCenter() {
+        CoordinatorRegistryCenter result = new ZookeeperRegistryCenter(new 
ZookeeperConfiguration(serverList, namespace));
+        result.init();
+        return result;
+    }
+    
     @RequiredArgsConstructor
     private static final class ConsumerSimpleJob implements SimpleJob {
         
diff --git 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/type/StandaloneScheduleStrategy.java
similarity index 66%
rename from 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
rename to 
shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/type/StandaloneScheduleStrategy.java
index 36931ebe9ba..a2e6dd75a0b 100644
--- 
a/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/api/JobParameter.java
+++ 
b/shardingsphere-kernel/shardingsphere-schedule/shardingsphere-schedule-core/src/main/java/org/apache/shardingsphere/schedule/core/strategy/type/StandaloneScheduleStrategy.java
@@ -15,10 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.schedule.core.api;
+package org.apache.shardingsphere.schedule.core.strategy.type;
+
+import org.apache.shardingsphere.schedule.core.model.CronJob;
+import org.apache.shardingsphere.schedule.core.strategy.ScheduleStrategy;
 
 /**
- * Schedule job parameter.
+ * Standalone schedule strategy.
  */
-public final class JobParameter {
+public final class StandaloneScheduleStrategy implements ScheduleStrategy {
+    
+    @Override
+    public void startSchedule(final CronJob job) {
+        // TODO
+    }
 }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 9fa46c64eaf..c233ac1b4a9 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -45,7 +45,7 @@ import 
org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryFactory;
-import org.apache.shardingsphere.schedule.core.api.ModeScheduleContextFactory;
+import org.apache.shardingsphere.schedule.core.ScheduleContextFactory;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -60,7 +60,7 @@ public final class ClusterContextManagerBuilder implements 
ContextManagerBuilder
     
     @Override
     public ContextManager build(final ContextManagerBuilderParameter 
parameter) throws SQLException {
-        
ModeScheduleContextFactory.getInstance().init(parameter.getInstanceMetaData().getId(),
 parameter.getModeConfig());
+        
ScheduleContextFactory.getInstance().init(parameter.getInstanceMetaData().getId(),
 parameter.getModeConfig());
         ClusterPersistRepository repository = 
ClusterPersistRepositoryFactory.getInstance((ClusterPersistRepositoryConfiguration)
 parameter.getModeConfig().getRepository());
         MetaDataPersistService persistService = new 
MetaDataPersistService(repository);
         persistConfigurations(persistService, parameter);
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/resources/logback-test.xml
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/resources/logback-test.xml
index 064918a0829..29123bfa8f2 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/resources/logback-test.xml
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/resources/logback-test.xml
@@ -25,7 +25,7 @@
     <logger name="org.apache.shardingsphere" level="warn" additivity="false">
         <appender-ref ref="console" />
     </logger>
-    <logger 
name="org.apache.shardingsphere.schedule.core.api.ModeScheduleContext" 
level="error" />
+    <logger name="org.apache.shardingsphere.schedule.core.ModeScheduleContext" 
level="error" />
     <logger 
name="org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service.ComputeNodeStatusService"
 level="off" />
     
     <root>
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index f309cbee856..e706c291fb0 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -40,6 +40,7 @@ import 
org.apache.shardingsphere.mode.manager.standalone.workerid.generator.Stan
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import 
org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepositoryFactory;
+import org.apache.shardingsphere.schedule.core.ScheduleContextFactory;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -55,6 +56,7 @@ public final class StandaloneContextManagerBuilder implements 
ContextManagerBuil
     @Override
     public ContextManager build(final ContextManagerBuilderParameter 
parameter) throws SQLException {
         ModeConfiguration modeConfig = null == parameter.getModeConfig() ? new 
ModeConfiguration("Standalone", null, true) : parameter.getModeConfig();
+        
ScheduleContextFactory.getInstance().init(parameter.getInstanceMetaData().getId(),
 modeConfig);
         MetaDataPersistService persistService = new 
MetaDataPersistService(StandalonePersistRepositoryFactory.getInstance(modeConfig.getRepository()));
         persistConfigurations(persistService, parameter, modeConfig);
         InstanceContext instanceContext = buildInstanceContext(parameter, 
modeConfig);
diff --git 
a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/resources/logback-test.xml
 
b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/resources/logback-test.xml
index 064918a0829..29123bfa8f2 100644
--- 
a/shardingsphere-test/shardingsphere-integration-driver-test/src/test/resources/logback-test.xml
+++ 
b/shardingsphere-test/shardingsphere-integration-driver-test/src/test/resources/logback-test.xml
@@ -25,7 +25,7 @@
     <logger name="org.apache.shardingsphere" level="warn" additivity="false">
         <appender-ref ref="console" />
     </logger>
-    <logger 
name="org.apache.shardingsphere.schedule.core.api.ModeScheduleContext" 
level="error" />
+    <logger name="org.apache.shardingsphere.schedule.core.ModeScheduleContext" 
level="error" />
     <logger 
name="org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service.ComputeNodeStatusService"
 level="off" />
     
     <root>

Reply via email to