You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2020/12/30 07:29:06 UTC
[shardingsphere] branch master updated: Remove
shardingsphere-governance-core dependency (#8824)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 02649cf Remove shardingsphere-governance-core dependency (#8824)
02649cf is described below
commit 02649cf1e7f234a6f49af7bf9a1391c360e4f2ca
Author: 邱鹿 Lucas <lu...@163.com>
AuthorDate: Wed Dec 30 15:28:35 2020 +0800
Remove shardingsphere-governance-core dependency (#8824)
Co-authored-by: qiulu3 <Lucas209910>
---
.../scaling/util/ServerConfigurationUtil.java | 8 ++--
.../shardingsphere-scaling-core/pom.xml | 2 +-
.../scaling/core/config/DumperConfiguration.java | 4 +-
.../scaling/core/config/ImporterConfiguration.java | 4 +-
.../scaling/core/config/RuleConfiguration.java | 8 ++--
.../scaling/core/config/ServerConfiguration.java | 7 ++-
.../datasource}/ConfigurationYamlConverter.java | 4 +-
.../DataSourceConfigurationYamlSwapper.java | 42 +++++++++++++++++
...on.java => ScalingDataSourceConfiguration.java} | 2 +-
.../ShardingSphereJDBCDataSourceConfiguration.java | 3 +-
.../StandardJDBCDataSourceConfiguration.java | 2 +-
.../YamlDataSourceConfiguration.java} | 18 ++++---
.../YamlDataSourceConfigurationWrap.java} | 20 +++-----
.../GovernanceCenterConfigurationYamlSwapper.java | 41 ++++++++++++++++
.../yaml/GovernanceConfigurationYamlSwapper.java | 51 ++++++++++++++++++++
.../yaml/ServerConfigurationYamlSwapper.java | 55 ++++++++++++++++++++++
.../YamlGovernanceCenterConfiguration.java} | 19 ++++----
.../YamlGovernanceConfiguration.java} | 19 ++++----
.../YamlServerConfiguration.java} | 5 +-
.../scaling/core/datasource/DataSourceFactory.java | 4 +-
.../scaling/core/datasource/DataSourceManager.java | 12 ++---
.../core/job/preparer/ScalingJobPreparer.java | 4 +-
.../core/service/RegistryRepositoryHolder.java | 7 +--
.../scaling/core/spi/ScalingWorkerLoader.java | 7 +--
.../scaling/core/utils/JDBCUtil.java | 27 ++++++-----
.../scaling/core/utils/TaskConfigurationUtil.java | 12 +++--
.../scaling/core/config/RuleConfigurationTest.java | 6 +--
.../importer/AbstractJDBCImporterTest.java | 4 +-
.../check/AbstractDataConsistencyCheckerTest.java | 4 +-
...istryRepositoryResumeBreakPointManagerTest.java | 18 +++----
.../splitter/InventoryTaskSplitterTest.java | 4 +-
.../job/task/incremental/IncrementalTaskTest.java | 4 +-
.../core/job/task/inventory/InventoryTaskTest.java | 6 +--
.../impl/DistributedScalingJobServiceTest.java | 12 ++---
.../impl/StandaloneScalingJobServiceTest.java | 8 ++--
.../scaling/core/spi/ScalingWorkerLoaderTest.java | 10 ++--
.../scaling/core/{utils => util}/JDBCUtilTest.java | 4 +-
37 files changed, 311 insertions(+), 156 deletions(-)
diff --git a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtil.java b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtil.java
index dd5e1ec..563ff34 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtil.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtil.java
@@ -25,7 +25,8 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
-import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
+import org.apache.shardingsphere.scaling.core.config.yaml.ServerConfigurationYamlSwapper;
+import org.apache.shardingsphere.scaling.core.config.yaml.YamlServerConfiguration;
import java.io.File;
import java.io.IOException;
@@ -43,14 +44,13 @@ public final class ServerConfigurationUtil {
/**
* Init scaling config.
- *
*/
@SneakyThrows(IOException.class)
public static void initScalingConfig() {
log.info("Init scaling config");
File yamlFile = new File(Resources.getResource(DEFAULT_CONFIG_PATH + DEFAULT_CONFIG_FILE_NAME).getPath());
- ServerConfiguration serverConfig = YamlEngine.unmarshal(yamlFile, ServerConfiguration.class);
+ YamlServerConfiguration serverConfig = YamlEngine.unmarshal(yamlFile, YamlServerConfiguration.class);
Preconditions.checkNotNull(serverConfig, "Server configuration file `%s` is invalid.", yamlFile.getName());
- ScalingContext.getInstance().init(serverConfig);
+ ScalingContext.getInstance().init(new ServerConfigurationYamlSwapper().swapToObject(serverConfig));
}
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml
index 6ce1cd6..9a3fc32 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml
@@ -41,7 +41,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-governance-core</artifactId>
+ <artifactId>shardingsphere-governance-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/DumperConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/DumperConfiguration.java
index fd2810a..d6ed7fa 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/DumperConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/DumperConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.scaling.core.config;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.job.position.PositionManager;
import java.util.Map;
@@ -33,7 +33,7 @@ public class DumperConfiguration {
private String dataSourceName;
- private DataSourceConfiguration dataSourceConfig;
+ private ScalingDataSourceConfiguration dataSourceConfig;
private PositionManager positionManager;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
index 949bedc..bb10c3c 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.scaling.core.config;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import java.util.Map;
import java.util.Set;
@@ -31,7 +31,7 @@ import java.util.Set;
@Getter
public final class ImporterConfiguration {
- private DataSourceConfiguration dataSourceConfig;
+ private ScalingDataSourceConfiguration dataSourceConfig;
private Map<String, Set<String>> shardingColumnsMap;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/RuleConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/RuleConfiguration.java
index 2c1a60a..6eb56b8 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/RuleConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/RuleConfiguration.java
@@ -23,7 +23,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonElement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
@@ -39,7 +39,7 @@ public final class RuleConfiguration {
private final DataSourceConfigurationWrapper target;
- public RuleConfiguration(final DataSourceConfiguration source, final DataSourceConfiguration target) {
+ public RuleConfiguration(final ScalingDataSourceConfiguration source, final ScalingDataSourceConfiguration target) {
this.source = new DataSourceConfigurationWrapper(source.getConfigType(), new Gson().toJsonTree(source));
this.target = new DataSourceConfigurationWrapper(target.getConfigType(), new Gson().toJsonTree(target));
}
@@ -56,10 +56,10 @@ public final class RuleConfiguration {
*
* @return {@code DataSourceConfiguration}
*/
- public DataSourceConfiguration unwrap() {
+ public ScalingDataSourceConfiguration unwrap() {
Map<String, Class<?>> instances = DataSourceConfigurationHolder.getInstances();
Preconditions.checkArgument(instances.containsKey(type.toLowerCase()), "Unsupported Data Source Type:" + type);
- return (DataSourceConfiguration) new Gson().fromJson(parameter, instances.get(type.toLowerCase()));
+ return (ScalingDataSourceConfiguration) new Gson().fromJson(parameter, instances.get(type.toLowerCase()));
}
private static class DataSourceConfigurationHolder {
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
index cb29adb..ce99ce0 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
@@ -19,15 +19,14 @@ package org.apache.shardingsphere.scaling.core.config;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
/**
* Global server configuration.
*/
@Setter
@Getter
-public final class ServerConfiguration implements YamlConfiguration {
+public final class ServerConfiguration {
private int port = 8080;
@@ -37,5 +36,5 @@ public final class ServerConfiguration implements YamlConfiguration {
private int workerThread = 30;
- private YamlGovernanceConfiguration distributedScalingService;
+ private GovernanceConfiguration distributedScalingService;
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/ConfigurationYamlConverter.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ConfigurationYamlConverter.java
similarity index 93%
rename from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/ConfigurationYamlConverter.java
rename to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ConfigurationYamlConverter.java
index cc09ae8..b671e90 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/ConfigurationYamlConverter.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ConfigurationYamlConverter.java
@@ -15,14 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.utils;
+package org.apache.shardingsphere.scaling.core.config.datasource;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlDataSourceConfigurationWrap;
-import org.apache.shardingsphere.governance.core.yaml.swapper.DataSourceConfigurationYamlSwapper;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/DataSourceConfigurationYamlSwapper.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/DataSourceConfigurationYamlSwapper.java
new file mode 100644
index 0000000..5631efe
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/DataSourceConfigurationYamlSwapper.java
@@ -0,0 +1,42 @@
+/*
+ * 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.scaling.core.config.datasource;
+
+import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+
+/**
+ * Data source configuration YAML swapper.
+ */
+public final class DataSourceConfigurationYamlSwapper implements YamlSwapper<YamlDataSourceConfiguration, DataSourceConfiguration> {
+
+ @Override
+ public YamlDataSourceConfiguration swapToYamlConfiguration(final DataSourceConfiguration config) {
+ YamlDataSourceConfiguration result = new YamlDataSourceConfiguration();
+ result.setDataSourceClassName(config.getDataSourceClassName());
+ result.setProps(config.getProps());
+ return result;
+ }
+
+ @Override
+ public DataSourceConfiguration swapToObject(final YamlDataSourceConfiguration yamlConfig) {
+ DataSourceConfiguration result = new DataSourceConfiguration(yamlConfig.getDataSourceClassName());
+ result.getProps().putAll(yamlConfig.getProps());
+ return result;
+ }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/DataSourceConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ScalingDataSourceConfiguration.java
similarity index 96%
rename from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/DataSourceConfiguration.java
rename to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ScalingDataSourceConfiguration.java
index db0e44c..318689d 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/DataSourceConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ScalingDataSourceConfiguration.java
@@ -25,7 +25,7 @@ import java.sql.SQLException;
/**
* Scaling data source configuration.
*/
-public interface DataSourceConfiguration {
+public interface ScalingDataSourceConfiguration {
/**
* Get config type.
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java
index 7fe00d3..076a297 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/ShardingSphereJDBCDataSourceConfiguration.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConverter;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.scaling.core.utils.ConfigurationYamlConverter;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import javax.sql.DataSource;
@@ -38,7 +37,7 @@ import java.util.Map;
@Setter
@Getter
@EqualsAndHashCode(exclude = "databaseType")
-public final class ShardingSphereJDBCDataSourceConfiguration implements DataSourceConfiguration {
+public final class ShardingSphereJDBCDataSourceConfiguration implements ScalingDataSourceConfiguration {
/**
* Config type.
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
index e435355..5222c4d 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
@@ -32,7 +32,7 @@ import javax.sql.DataSource;
@Getter
@Setter
@EqualsAndHashCode(exclude = "databaseType")
-public final class StandardJDBCDataSourceConfiguration implements DataSourceConfiguration {
+public final class StandardJDBCDataSourceConfiguration implements ScalingDataSourceConfiguration {
/**
* Config type.
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/YamlDataSourceConfiguration.java
similarity index 70%
copy from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
copy to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/YamlDataSourceConfiguration.java
index 949bedc..61a21eb 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/YamlDataSourceConfiguration.java
@@ -15,25 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.config;
+package org.apache.shardingsphere.scaling.core.config.datasource;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
/**
- * Importer configuration.
+ * Data source configuration for YAML.
*/
-@Setter
@Getter
-public final class ImporterConfiguration {
-
- private DataSourceConfiguration dataSourceConfig;
+@Setter
+public final class YamlDataSourceConfiguration implements YamlConfiguration {
- private Map<String, Set<String>> shardingColumnsMap;
+ private String dataSourceClassName;
- private int retryTimes;
+ private Map<String, Object> props = new HashMap<>();
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/YamlDataSourceConfigurationWrap.java
similarity index 70%
copy from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
copy to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/YamlDataSourceConfigurationWrap.java
index 949bedc..a4b3d44 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/YamlDataSourceConfigurationWrap.java
@@ -15,25 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.config;
+package org.apache.shardingsphere.scaling.core.config.datasource;
+import java.util.Map;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
-
-import java.util.Map;
-import java.util.Set;
+import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
/**
- * Importer configuration.
+ * Data source configuration warp for YAML.
*/
-@Setter
@Getter
-public final class ImporterConfiguration {
-
- private DataSourceConfiguration dataSourceConfig;
-
- private Map<String, Set<String>> shardingColumnsMap;
+@Setter
+public final class YamlDataSourceConfigurationWrap implements YamlConfiguration {
- private int retryTimes;
+ private Map<String, YamlDataSourceConfiguration> dataSources;
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/GovernanceCenterConfigurationYamlSwapper.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/GovernanceCenterConfigurationYamlSwapper.java
new file mode 100644
index 0000000..a4bfec6
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/GovernanceCenterConfigurationYamlSwapper.java
@@ -0,0 +1,41 @@
+/*
+ * 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.scaling.core.config.yaml;
+
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+
+/**
+ * Governance center configuration YAML swapper.
+ */
+public final class GovernanceCenterConfigurationYamlSwapper implements YamlSwapper<YamlGovernanceCenterConfiguration, GovernanceCenterConfiguration> {
+
+ @Override
+ public YamlGovernanceCenterConfiguration swapToYamlConfiguration(final GovernanceCenterConfiguration config) {
+ YamlGovernanceCenterConfiguration result = new YamlGovernanceCenterConfiguration();
+ result.setType(config.getType());
+ result.setServerLists(config.getServerLists());
+ result.setProps(config.getProps());
+ return result;
+ }
+
+ @Override
+ public GovernanceCenterConfiguration swapToObject(final YamlGovernanceCenterConfiguration yamlConfig) {
+ return new GovernanceCenterConfiguration(yamlConfig.getType(), yamlConfig.getServerLists(), yamlConfig.getProps());
+ }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/GovernanceConfigurationYamlSwapper.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/GovernanceConfigurationYamlSwapper.java
new file mode 100644
index 0000000..3457505
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/GovernanceConfigurationYamlSwapper.java
@@ -0,0 +1,51 @@
+/*
+ * 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.scaling.core.config.yaml;
+
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+
+/**
+ * Governance configuration YAML swapper.
+ */
+public final class GovernanceConfigurationYamlSwapper implements YamlSwapper<YamlGovernanceConfiguration, GovernanceConfiguration> {
+
+ private final GovernanceCenterConfigurationYamlSwapper governanceCenterConfigurationSwapper = new GovernanceCenterConfigurationYamlSwapper();
+
+ @Override
+ public YamlGovernanceConfiguration swapToYamlConfiguration(final GovernanceConfiguration data) {
+ YamlGovernanceConfiguration result = new YamlGovernanceConfiguration();
+ result.setName(data.getName());
+ result.setRegistryCenter(governanceCenterConfigurationSwapper.swapToYamlConfiguration(data.getRegistryCenterConfiguration()));
+ if (data.getAdditionalConfigCenterConfiguration().isPresent()) {
+ result.setAdditionalConfigCenter(governanceCenterConfigurationSwapper.swapToYamlConfiguration(data.getAdditionalConfigCenterConfiguration().get()));
+ }
+ return result;
+ }
+
+ @Override
+ public GovernanceConfiguration swapToObject(final YamlGovernanceConfiguration yamlConfig) {
+ GovernanceCenterConfiguration registryCenter = governanceCenterConfigurationSwapper.swapToObject(yamlConfig.getRegistryCenter());
+ if (null == yamlConfig.getAdditionalConfigCenter()) {
+ return new GovernanceConfiguration(yamlConfig.getName(), registryCenter, yamlConfig.isOverwrite());
+ }
+ GovernanceCenterConfiguration additionalConfigCenter = governanceCenterConfigurationSwapper.swapToObject(yamlConfig.getAdditionalConfigCenter());
+ return new GovernanceConfiguration(yamlConfig.getName(), registryCenter, additionalConfigCenter, yamlConfig.isOverwrite());
+ }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java
new file mode 100644
index 0000000..e2f2b58
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java
@@ -0,0 +1,55 @@
+/*
+ * 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.scaling.core.config.yaml;
+
+import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
+
+/**
+ * Server configuration yaml swapper.
+ */
+public final class ServerConfigurationYamlSwapper implements YamlSwapper<YamlServerConfiguration, ServerConfiguration> {
+
+ private final GovernanceConfigurationYamlSwapper governanceConfigurationYamlSwapper = new GovernanceConfigurationYamlSwapper();
+
+ @Override
+ public YamlServerConfiguration swapToYamlConfiguration(final ServerConfiguration data) {
+ YamlServerConfiguration result = new YamlServerConfiguration();
+ result.setPort(data.getPort());
+ result.setBlockQueueSize(data.getBlockQueueSize());
+ result.setPushTimeout(data.getPushTimeout());
+ result.setWorkerThread(data.getWorkerThread());
+ if (null != data.getDistributedScalingService()) {
+ result.setDistributedScalingService(governanceConfigurationYamlSwapper.swapToYamlConfiguration(data.getDistributedScalingService()));
+ }
+ return result;
+ }
+
+ @Override
+ public ServerConfiguration swapToObject(final YamlServerConfiguration yamlConfig) {
+ ServerConfiguration result = new ServerConfiguration();
+ result.setPort(yamlConfig.getPort());
+ result.setBlockQueueSize(yamlConfig.getBlockQueueSize());
+ result.setPushTimeout(yamlConfig.getPushTimeout());
+ result.setWorkerThread(yamlConfig.getWorkerThread());
+ if (null != yamlConfig.getDistributedScalingService()) {
+ result.setDistributedScalingService(governanceConfigurationYamlSwapper.swapToObject(yamlConfig.getDistributedScalingService()));
+ }
+ return result;
+ }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlGovernanceCenterConfiguration.java
similarity index 69%
copy from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
copy to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlGovernanceCenterConfiguration.java
index 949bedc..6a93956 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ImporterConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlGovernanceCenterConfiguration.java
@@ -15,25 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.config;
+package org.apache.shardingsphere.scaling.core.config.yaml;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
-import java.util.Map;
-import java.util.Set;
+import java.util.Properties;
/**
- * Importer configuration.
+ * Governance center configuration for YAML.
*/
-@Setter
@Getter
-public final class ImporterConfiguration {
+@Setter
+public final class YamlGovernanceCenterConfiguration implements YamlConfiguration {
- private DataSourceConfiguration dataSourceConfig;
+ private String type;
- private Map<String, Set<String>> shardingColumnsMap;
+ private String serverLists;
- private int retryTimes;
+ private Properties props = new Properties();
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlGovernanceConfiguration.java
similarity index 67%
copy from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
copy to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlGovernanceConfiguration.java
index cb29adb..722daf3 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlGovernanceConfiguration.java
@@ -15,27 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.config;
+package org.apache.shardingsphere.scaling.core.config.yaml;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
/**
- * Global server configuration.
+ * Governance configuration for YAML.
*/
-@Setter
@Getter
-public final class ServerConfiguration implements YamlConfiguration {
-
- private int port = 8080;
+@Setter
+public final class YamlGovernanceConfiguration implements YamlConfiguration {
- private int blockQueueSize = 10000;
+ private String name;
- private int pushTimeout = 1000;
+ private YamlGovernanceCenterConfiguration registryCenter;
- private int workerThread = 30;
+ private YamlGovernanceCenterConfiguration additionalConfigCenter;
- private YamlGovernanceConfiguration distributedScalingService;
+ private boolean overwrite;
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlServerConfiguration.java
similarity index 84%
copy from shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
copy to shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlServerConfiguration.java
index cb29adb..b1e84e6 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/ServerConfiguration.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/YamlServerConfiguration.java
@@ -15,11 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.config;
+package org.apache.shardingsphere.scaling.core.config.yaml;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
/**
@@ -27,7 +26,7 @@ import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
*/
@Setter
@Getter
-public final class ServerConfiguration implements YamlConfiguration {
+public final class YamlServerConfiguration implements YamlConfiguration {
private int port = 8080;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
index 2e47554..299e342 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.scaling.core.datasource;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import java.sql.SQLException;
@@ -34,7 +34,7 @@ public final class DataSourceFactory {
* @return new data source wrapper
*/
@SneakyThrows(SQLException.class)
- public DataSourceWrapper newInstance(final DataSourceConfiguration dataSourceConfig) {
+ public DataSourceWrapper newInstance(final ScalingDataSourceConfiguration dataSourceConfig) {
return new DataSourceWrapper(dataSourceConfig.toDataSource());
}
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceManager.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceManager.java
index e381c5b..a4cd8ca 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceManager.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceManager.java
@@ -21,7 +21,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.scaling.core.config.TaskConfiguration;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -39,10 +39,10 @@ public final class DataSourceManager implements AutoCloseable {
private final DataSourceFactory dataSourceFactory = new DataSourceFactory();
@Getter
- private final Map<DataSourceConfiguration, DataSourceWrapper> cachedDataSources = new ConcurrentHashMap<>();
+ private final Map<ScalingDataSourceConfiguration, DataSourceWrapper> cachedDataSources = new ConcurrentHashMap<>();
@Getter
- private final Map<DataSourceConfiguration, DataSourceWrapper> sourceDataSources = new ConcurrentHashMap<>();
+ private final Map<ScalingDataSourceConfiguration, DataSourceWrapper> sourceDataSources = new ConcurrentHashMap<>();
public DataSourceManager(final List<TaskConfiguration> taskConfigs) {
createDataSources(taskConfigs);
@@ -55,14 +55,14 @@ public final class DataSourceManager implements AutoCloseable {
private void createSourceDataSources(final List<TaskConfiguration> taskConfigs) {
for (TaskConfiguration taskConfig : taskConfigs) {
- DataSourceConfiguration dataSourceConfig = taskConfig.getDumperConfig().getDataSourceConfig();
+ ScalingDataSourceConfiguration dataSourceConfig = taskConfig.getDumperConfig().getDataSourceConfig();
DataSourceWrapper dataSource = dataSourceFactory.newInstance(dataSourceConfig);
cachedDataSources.put(dataSourceConfig, dataSource);
sourceDataSources.put(dataSourceConfig, dataSource);
}
}
- private void createTargetDataSources(final DataSourceConfiguration dataSourceConfig) {
+ private void createTargetDataSources(final ScalingDataSourceConfiguration dataSourceConfig) {
cachedDataSources.put(dataSourceConfig, dataSourceFactory.newInstance(dataSourceConfig));
}
@@ -72,7 +72,7 @@ public final class DataSourceManager implements AutoCloseable {
* @param dataSourceConfig data source configuration
* @return data source
*/
- public DataSource getDataSource(final DataSourceConfiguration dataSourceConfig) {
+ public DataSource getDataSource(final ScalingDataSourceConfiguration dataSourceConfig) {
if (cachedDataSources.containsKey(dataSourceConfig)) {
return cachedDataSources.get(dataSourceConfig);
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/ScalingJobPreparer.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/ScalingJobPreparer.java
index 3a53d8f..2161a5e 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/ScalingJobPreparer.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/preparer/ScalingJobPreparer.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.scaling.core.job.preparer;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.scaling.core.config.TaskConfiguration;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.constant.ScalingConstant;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
import org.apache.shardingsphere.scaling.core.exception.PrepareFailedException;
@@ -96,7 +96,7 @@ public final class ScalingJobPreparer {
private void initIncrementalTasks(final ScalingJob scalingJob, final DataSourceManager dataSourceManager) {
for (TaskConfiguration each : scalingJob.getTaskConfigs()) {
- DataSourceConfiguration dataSourceConfig = each.getDumperConfig().getDataSourceConfig();
+ ScalingDataSourceConfiguration dataSourceConfig = each.getDumperConfig().getDataSourceConfig();
each.getDumperConfig().setPositionManager(PositionManagerFactory.newInstance(scalingJob.getDatabaseType(), dataSourceManager.getDataSource(dataSourceConfig)));
scalingJob.getIncrementalTasks().add(scalingTaskFactory.createIncrementalTask(each.getJobConfig().getConcurrency(), each.getDumperConfig(), each.getImporterConfig()));
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/RegistryRepositoryHolder.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/RegistryRepositoryHolder.java
index b40e016..e71e556 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/RegistryRepositoryHolder.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/RegistryRepositoryHolder.java
@@ -21,8 +21,6 @@ import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
-import org.apache.shardingsphere.governance.core.yaml.swapper.GovernanceConfigurationYamlSwapper;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
@@ -71,9 +69,8 @@ public final class RegistryRepositoryHolder {
if (null != available) {
return;
}
- YamlGovernanceConfiguration distributedScalingService = ScalingContext.getInstance().getServerConfig().getDistributedScalingService();
- if (null != distributedScalingService) {
- GovernanceConfiguration governanceConfig = new GovernanceConfigurationYamlSwapper().swapToObject(distributedScalingService);
+ GovernanceConfiguration governanceConfig = ScalingContext.getInstance().getServerConfig().getDistributedScalingService();
+ if (null != governanceConfig) {
GovernanceCenterConfiguration registryCenterConfig = governanceConfig.getRegistryCenterConfiguration();
Preconditions.checkNotNull(registryCenterConfig, "Registry center configuration cannot be null.");
registryRepository = TypedSPIRegistry.getRegisteredService(RegistryRepository.class, registryCenterConfig.getType(), registryCenterConfig.getProps());
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoader.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoader.java
index 15c8278..5907386 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoader.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoader.java
@@ -17,8 +17,6 @@
package org.apache.shardingsphere.scaling.core.spi;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
-import org.apache.shardingsphere.governance.core.yaml.swapper.GovernanceConfigurationYamlSwapper;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
@@ -38,9 +36,8 @@ public final class ScalingWorkerLoader {
*/
public static Optional<String> initScalingWorker() {
ShardingSphereServiceLoader.register(ScalingWorker.class);
- YamlGovernanceConfiguration distributedScalingService = ScalingContext.getInstance().getServerConfig().getDistributedScalingService();
- if (null != distributedScalingService) {
- GovernanceConfiguration governanceConfig = new GovernanceConfigurationYamlSwapper().swapToObject(distributedScalingService);
+ GovernanceConfiguration governanceConfig = ScalingContext.getInstance().getServerConfig().getDistributedScalingService();
+ if (null != governanceConfig) {
Collection<ScalingWorker> scalingWorkers = ShardingSphereServiceLoader.newServiceInstances(ScalingWorker.class);
for (ScalingWorker each : scalingWorkers) {
each.init(governanceConfig);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtil.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtil.java
index da68987..92f8762 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtil.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtil.java
@@ -17,7 +17,9 @@
package org.apache.shardingsphere.scaling.core.utils;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ConfigurationYamlConverter;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.metadata.JdbcUri;
@@ -34,14 +36,14 @@ public final class JDBCUtil {
/**
* Append jdbc parameter.
*
- * @param dataSourceConfiguration data source configuration
+ * @param scalingDataSourceConfiguration data source configuration
* @param parameters parameters
*/
- public static void appendJDBCParameter(final DataSourceConfiguration dataSourceConfiguration, final Map<String, String> parameters) {
- if (dataSourceConfiguration instanceof StandardJDBCDataSourceConfiguration) {
- append((StandardJDBCDataSourceConfiguration) dataSourceConfiguration, parameters);
- } else if (dataSourceConfiguration instanceof ShardingSphereJDBCDataSourceConfiguration) {
- append((ShardingSphereJDBCDataSourceConfiguration) dataSourceConfiguration, parameters);
+ public static void appendJDBCParameter(final ScalingDataSourceConfiguration scalingDataSourceConfiguration, final Map<String, String> parameters) {
+ if (scalingDataSourceConfiguration instanceof StandardJDBCDataSourceConfiguration) {
+ append((StandardJDBCDataSourceConfiguration) scalingDataSourceConfiguration, parameters);
+ } else if (scalingDataSourceConfiguration instanceof ShardingSphereJDBCDataSourceConfiguration) {
+ append((ShardingSphereJDBCDataSourceConfiguration) scalingDataSourceConfiguration, parameters);
}
}
@@ -50,13 +52,12 @@ public final class JDBCUtil {
}
private static void append(final ShardingSphereJDBCDataSourceConfiguration dataSourceConfig, final Map<String, String> parameters) {
- Map<String, org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration> dataSourceConfigMap = ConfigurationYamlConverter.loadDataSourceConfigs(dataSourceConfig.getDataSource());
- Map<String, org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration> tmp = new HashMap<>(dataSourceConfigMap);
- tmp.entrySet().forEach(each -> {
- String jdbcUrlKey = each.getValue().getProps().containsKey("url") ? "url" : "jdbcUrl";
- each.getValue().getProps().replace(jdbcUrlKey, append(each.getValue().getProps().get(jdbcUrlKey).toString(), parameters));
+ Map<String, DataSourceConfiguration> dataSourceConfigMap = new HashMap<>(ConfigurationYamlConverter.loadDataSourceConfigs(dataSourceConfig.getDataSource()));
+ dataSourceConfigMap.forEach((key, value) -> {
+ String jdbcUrlKey = value.getProps().containsKey("url") ? "url" : "jdbcUrl";
+ value.getProps().replace(jdbcUrlKey, append(value.getProps().get(jdbcUrlKey).toString(), parameters));
});
- dataSourceConfig.setDataSource(ConfigurationYamlConverter.serializeDataSourceConfigs(tmp));
+ dataSourceConfig.setDataSource(ConfigurationYamlConverter.serializeDataSourceConfigs(dataSourceConfigMap));
}
private static String append(final String url, final Map<String, String> parameters) {
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/TaskConfigurationUtil.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/TaskConfigurationUtil.java
index 9d99fa9..245e1c4 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/TaskConfigurationUtil.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/utils/TaskConfigurationUtil.java
@@ -25,12 +25,14 @@ import com.google.common.collect.Sets;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.DumperConfiguration;
import org.apache.shardingsphere.scaling.core.config.ImporterConfiguration;
import org.apache.shardingsphere.scaling.core.config.JobConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingConfiguration;
import org.apache.shardingsphere.scaling.core.config.TaskConfiguration;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ConfigurationYamlConverter;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.metadata.JdbcUri;
@@ -74,7 +76,7 @@ public final class TaskConfigurationUtil {
Collection<TaskConfiguration> result = new LinkedList<>();
ShardingSphereJDBCDataSourceConfiguration sourceConfig = getSourceConfig(scalingConfig);
ShardingRuleConfiguration sourceRuleConfig = ConfigurationYamlConverter.loadShardingRuleConfig(sourceConfig.getRule());
- Map<String, org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration> sourceDataSource = ConfigurationYamlConverter.loadDataSourceConfigs(sourceConfig.getDataSource());
+ Map<String, DataSourceConfiguration> sourceDataSource = ConfigurationYamlConverter.loadDataSourceConfigs(sourceConfig.getDataSource());
Map<String, DataSource> dataSourceMap = sourceDataSource.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().createDataSource()));
Map<String, Map<String, String>> dataSourceTableNameMap = toDataSourceTableNameMap(new ShardingRule(sourceRuleConfig, sourceConfig.getDatabaseType(), dataSourceMap));
Optional<ShardingRuleConfiguration> targetRuleConfig = getTargetRuleConfig(scalingConfig);
@@ -89,13 +91,13 @@ public final class TaskConfigurationUtil {
}
private static ShardingSphereJDBCDataSourceConfiguration getSourceConfig(final ScalingConfiguration scalingConfig) {
- DataSourceConfiguration result = scalingConfig.getRuleConfiguration().getSource().unwrap();
+ ScalingDataSourceConfiguration result = scalingConfig.getRuleConfiguration().getSource().unwrap();
Preconditions.checkArgument(result instanceof ShardingSphereJDBCDataSourceConfiguration, "Only support ShardingSphere source data source.");
return (ShardingSphereJDBCDataSourceConfiguration) result;
}
private static Optional<ShardingRuleConfiguration> getTargetRuleConfig(final ScalingConfiguration scalingConfig) {
- DataSourceConfiguration dataSourceConfig = scalingConfig.getRuleConfiguration().getTarget().unwrap();
+ ScalingDataSourceConfiguration dataSourceConfig = scalingConfig.getRuleConfiguration().getTarget().unwrap();
if (dataSourceConfig instanceof ShardingSphereJDBCDataSourceConfiguration) {
return Optional.of(ConfigurationYamlConverter.loadShardingRuleConfig(((ShardingSphereJDBCDataSourceConfiguration) dataSourceConfig).getRule()));
}
@@ -228,7 +230,7 @@ public final class TaskConfigurationUtil {
}
private static List<String> getShouldScalingActualDataNodes(final ScalingConfiguration scalingConfig) {
- DataSourceConfiguration sourceConfig = scalingConfig.getRuleConfiguration().getSource().unwrap();
+ ScalingDataSourceConfiguration sourceConfig = scalingConfig.getRuleConfiguration().getSource().unwrap();
Preconditions.checkState(sourceConfig instanceof ShardingSphereJDBCDataSourceConfiguration,
"Only ShardingSphereJdbc type of source ScalingDataSourceConfiguration is supported.");
ShardingSphereJDBCDataSourceConfiguration source = (ShardingSphereJDBCDataSourceConfiguration) sourceConfig;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/config/RuleConfigurationTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/config/RuleConfigurationTest.java
index f5e5b56..02adcd2 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/config/RuleConfigurationTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/config/RuleConfigurationTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.scaling.core.config;
import com.google.gson.JsonObject;
import org.apache.shardingsphere.scaling.core.config.RuleConfiguration.DataSourceConfigurationWrapper;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.fixture.FixtureShardingSphereJDBCConfiguration;
@@ -36,7 +36,7 @@ public final class RuleConfigurationTest {
String jdbcUrl = "jdbc:h2:mem:test_db_2;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL";
String username = "root";
String password = "password";
- DataSourceConfiguration actual = mockStandardJDBCDataSourceConfigWrapper(jdbcUrl, username, password).unwrap();
+ ScalingDataSourceConfiguration actual = mockStandardJDBCDataSourceConfigWrapper(jdbcUrl, username, password).unwrap();
assertThat(actual, instanceOf(StandardJDBCDataSourceConfiguration.class));
StandardJDBCDataSourceConfiguration jdbcDataSourceConfig = (StandardJDBCDataSourceConfiguration) actual;
assertThat(jdbcDataSourceConfig.getJdbcUrl(), is(jdbcUrl));
@@ -49,7 +49,7 @@ public final class RuleConfigurationTest {
String dataSource = FixtureShardingSphereJDBCConfiguration.DATA_SOURCE;
String rule = FixtureShardingSphereJDBCConfiguration.RULE;
DataSourceConfigurationWrapper dataSourceConfigurationWrapper = getDataSourceConfigurationWrapper(dataSource, rule);
- DataSourceConfiguration actual = dataSourceConfigurationWrapper.unwrap();
+ ScalingDataSourceConfiguration actual = dataSourceConfigurationWrapper.unwrap();
assertThat(actual, instanceOf(ShardingSphereJDBCDataSourceConfiguration.class));
ShardingSphereJDBCDataSourceConfiguration shardingSphereJDBCConfig = (ShardingSphereJDBCDataSourceConfiguration) actual;
assertThat(shardingSphereJDBCConfig.getDataSource(), is(dataSource));
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
index 4d19ce5..4036706 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.scaling.core.execute.executor.importer;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.shardingsphere.scaling.core.config.ImporterConfiguration;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
import org.apache.shardingsphere.scaling.core.execute.executor.channel.Channel;
import org.apache.shardingsphere.scaling.core.execute.executor.record.Column;
@@ -70,7 +70,7 @@ public final class AbstractJDBCImporterTest {
private ScalingSQLBuilder scalingSqlBuilder;
@Mock
- private DataSourceConfiguration dataSourceConfig;
+ private ScalingDataSourceConfiguration dataSourceConfig;
@Mock
private Channel channel;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/check/AbstractDataConsistencyCheckerTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/check/AbstractDataConsistencyCheckerTest.java
index 8593a1a..a9af3da 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/check/AbstractDataConsistencyCheckerTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/check/AbstractDataConsistencyCheckerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.scaling.core.job.check;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
import org.apache.shardingsphere.scaling.core.job.ScalingJob;
import org.apache.shardingsphere.scaling.core.util.ScalingConfigurationUtil;
@@ -49,7 +49,7 @@ public final class AbstractDataConsistencyCheckerTest {
}
@SneakyThrows(SQLException.class)
- private void initTableData(final DataSourceConfiguration dataSourceConfig) {
+ private void initTableData(final ScalingDataSourceConfiguration dataSourceConfig) {
DataSource dataSource = new DataSourceManager().getDataSource(dataSourceConfig);
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/position/resume/RegistryRepositoryResumeBreakPointManagerTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/position/resume/RegistryRepositoryResumeBreakPointManagerTest.java
index 73875e3..a477b48 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/position/resume/RegistryRepositoryResumeBreakPointManagerTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/position/resume/RegistryRepositoryResumeBreakPointManagerTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.scaling.core.job.position.resume;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
import org.apache.shardingsphere.scaling.core.service.RegistryRepositoryHolder;
@@ -32,15 +32,15 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class RegistryRepositoryResumeBreakPointManagerTest {
-
+
private RegistryRepositoryResumeBreakPointManager resumeBreakPointManager;
-
+
@Before
public void setUp() {
ScalingContext.getInstance().init(mockServerConfiguration());
resumeBreakPointManager = new RegistryRepositoryResumeBreakPointManager("H2", "/base");
}
-
+
@Test
public void assertPersistAndGetPosition() {
resumeBreakPointManager.persistPosition();
@@ -56,14 +56,8 @@ public final class RegistryRepositoryResumeBreakPointManagerTest {
private ServerConfiguration mockServerConfiguration() {
resetRegistryRepositoryAvailable();
- YamlGovernanceConfiguration distributedScalingService = new YamlGovernanceConfiguration();
- distributedScalingService.setName("test");
- YamlGovernanceCenterConfiguration registryCenter = new YamlGovernanceCenterConfiguration();
- registryCenter.setType("REG_FIXTURE");
- registryCenter.setServerLists("");
- distributedScalingService.setRegistryCenter(registryCenter);
ServerConfiguration result = new ServerConfiguration();
- result.setDistributedScalingService(distributedScalingService);
+ result.setDistributedScalingService(new GovernanceConfiguration("test", new GovernanceCenterConfiguration("REG_FIXTURE", "", null), false));
return result;
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/preparer/splitter/InventoryTaskSplitterTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/preparer/splitter/InventoryTaskSplitterTest.java
index c082aa9..b48cc91 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/preparer/splitter/InventoryTaskSplitterTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/preparer/splitter/InventoryTaskSplitterTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.scaling.core.config.DumperConfiguration;
import org.apache.shardingsphere.scaling.core.config.ImporterConfiguration;
import org.apache.shardingsphere.scaling.core.config.JobConfiguration;
import org.apache.shardingsphere.scaling.core.config.TaskConfiguration;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
import org.apache.shardingsphere.scaling.core.job.position.PrimaryKeyPosition;
@@ -151,7 +151,7 @@ public final class InventoryTaskSplitterTest {
}
private DumperConfiguration mockDumperConfig() {
- DataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
+ ScalingDataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
DumperConfiguration result = new DumperConfiguration();
result.setDataSourceConfig(dataSourceConfig);
Map<String, String> tableMap = new HashMap<>();
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/incremental/IncrementalTaskTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/incremental/IncrementalTaskTest.java
index 7596d4f..7ca5243 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/incremental/IncrementalTaskTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/incremental/IncrementalTaskTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.scaling.core.config.DumperConfiguration;
import org.apache.shardingsphere.scaling.core.config.ImporterConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
import org.apache.shardingsphere.scaling.core.job.TaskProgress;
import org.apache.shardingsphere.scaling.core.job.position.PlaceholderPosition;
@@ -75,7 +75,7 @@ public final class IncrementalTaskTest {
}
private DumperConfiguration mockDumperConfig() {
- DataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
+ ScalingDataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
DumperConfiguration result = new DumperConfiguration();
result.setDataSourceName("ds0");
result.setDataSourceConfig(dataSourceConfig);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/inventory/InventoryTaskTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/inventory/InventoryTaskTest.java
index 637913c..dd588b2 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/inventory/InventoryTaskTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/job/task/inventory/InventoryTaskTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.scaling.core.config.InventoryDumperConfiguratio
import org.apache.shardingsphere.scaling.core.config.JobConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
import org.apache.shardingsphere.scaling.core.config.TaskConfiguration;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
@@ -98,7 +98,7 @@ public final class InventoryTaskTest {
}
private DumperConfiguration mockDumperConfig() {
- DataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
+ ScalingDataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
DumperConfiguration result = new DumperConfiguration();
result.setDataSourceConfig(dataSourceConfig);
result.setPositionManager(new PositionManager(new PrimaryKeyPosition(1, 100)));
@@ -107,7 +107,7 @@ public final class InventoryTaskTest {
}
private ImporterConfiguration mockImporterConfig() {
- DataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
+ ScalingDataSourceConfiguration dataSourceConfig = new StandardJDBCDataSourceConfiguration(DATA_SOURCE_URL, USERNAME, PASSWORD);
ImporterConfiguration result = new ImporterConfiguration();
result.setDataSourceConfig(dataSourceConfig);
return result;
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobServiceTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobServiceTest.java
index 1fa422d..b4b1e62 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobServiceTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobServiceTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.scaling.core.service.impl;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
@@ -140,14 +140,8 @@ public final class DistributedScalingJobServiceTest {
private ServerConfiguration mockServerConfiguration() {
resetRegistryRepositoryAvailable();
- YamlGovernanceConfiguration distributedScalingService = new YamlGovernanceConfiguration();
- distributedScalingService.setName("test");
- YamlGovernanceCenterConfiguration registryCenter = new YamlGovernanceCenterConfiguration();
- registryCenter.setType("REG_FIXTURE");
- registryCenter.setServerLists("");
- distributedScalingService.setRegistryCenter(registryCenter);
ServerConfiguration result = new ServerConfiguration();
- result.setDistributedScalingService(distributedScalingService);
+ result.setDistributedScalingService(new GovernanceConfiguration("test", new GovernanceCenterConfiguration("REG_FIXTURE", "", null), false));
return result;
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobServiceTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobServiceTest.java
index f5e5c7c..3b9d490 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobServiceTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobServiceTest.java
@@ -21,7 +21,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.core.config.ScalingConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
-import org.apache.shardingsphere.scaling.core.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
import org.apache.shardingsphere.scaling.core.exception.ScalingJobNotFoundException;
import org.apache.shardingsphere.scaling.core.execute.engine.TaskExecuteEngine;
@@ -132,7 +132,7 @@ public final class StandaloneScalingJobServiceTest {
Optional<ScalingJob> scalingJobOptional = scalingJobService.start(mockScalingConfiguration());
assertTrue(scalingJobOptional.isPresent());
ScalingJob scalingJob = scalingJobOptional.get();
- DataSourceConfiguration dataSourceConfig = scalingJob.getTaskConfigs().get(0).getImporterConfig().getDataSourceConfig();
+ ScalingDataSourceConfiguration dataSourceConfig = scalingJob.getTaskConfigs().get(0).getImporterConfig().getDataSourceConfig();
initTableData(dataSourceConfig);
assertThat(countTableData(dataSourceConfig), is(2L));
scalingJobService.reset(scalingJob.getJobId());
@@ -144,7 +144,7 @@ public final class StandaloneScalingJobServiceTest {
return ScalingConfigurationUtil.initConfig("/config.json");
}
- private void initTableData(final DataSourceConfiguration dataSourceConfig) throws SQLException {
+ private void initTableData(final ScalingDataSourceConfiguration dataSourceConfig) throws SQLException {
DataSource dataSource = new DataSourceManager().getDataSource(dataSourceConfig);
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
@@ -154,7 +154,7 @@ public final class StandaloneScalingJobServiceTest {
}
}
- private long countTableData(final DataSourceConfiguration dataSourceConfig) throws SQLException {
+ private long countTableData(final ScalingDataSourceConfiguration dataSourceConfig) throws SQLException {
DataSource dataSource = new DataSourceManager().getDataSource(dataSourceConfig);
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoaderTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoaderTest.java
index d0484a2..e5e0048 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoaderTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/spi/ScalingWorkerLoaderTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.scaling.core.spi;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
-import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
+import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
import org.apache.shardingsphere.scaling.core.utils.ReflectionUtil;
@@ -46,11 +46,7 @@ public final class ScalingWorkerLoaderTest {
private ServerConfiguration mockServerConfiguration() {
ServerConfiguration result = new ServerConfiguration();
- YamlGovernanceConfiguration distributedScalingService = new YamlGovernanceConfiguration();
- YamlGovernanceCenterConfiguration registryCenter = new YamlGovernanceCenterConfiguration();
- registryCenter.setType("Zookeeper");
- distributedScalingService.setRegistryCenter(registryCenter);
- result.setDistributedScalingService(distributedScalingService);
+ result.setDistributedScalingService(new GovernanceConfiguration("test", new GovernanceCenterConfiguration("Zookeeper", "", null), false));
return result;
}
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtilTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java
similarity index 94%
rename from shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtilTest.java
rename to shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java
index 695e2ca..975719a 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/utils/JDBCUtilTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/util/JDBCUtilTest.java
@@ -15,12 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.core.utils;
+package org.apache.shardingsphere.scaling.core.util;
import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.config.datasource.ConfigurationYamlConverter;
import org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
+import org.apache.shardingsphere.scaling.core.utils.JDBCUtil;
import org.junit.Test;
import java.util.ArrayList;