You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2021/01/01 16:39:44 UTC
[shardingsphere] branch master updated: Minor change of scaling
(#8859)
This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 9cebfe8 Minor change of scaling (#8859)
9cebfe8 is described below
commit 9cebfe8078162981076b7194654d6c6f252cd5fa
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Jan 2 00:39:08 2021 +0800
Minor change of scaling (#8859)
* Adjust module order
* Adjust dependency order
* Rename ServerConfigurationInitializer
* For code format
* For code format
* Remove useless codes
---
shardingsphere-scaling/pom.xml | 4 ++--
.../shardingsphere-scaling-bootstrap/pom.xml | 10 ++++++----
.../apache/shardingsphere/scaling/ServerBootstrap.java | 4 ++--
.../apache/shardingsphere/scaling/WorkerBootstrap.java | 4 ++--
...tionUtil.java => ServerConfigurationInitializer.java} | 16 +++++++---------
.../scaling/util/ServerConfigurationUtilTest.java | 2 +-
.../shardingsphere-scaling-core/pom.xml | 2 +-
.../scaling/core/datasource/DataSourceManager.java | 8 ++++----
.../scaling/core/exception/PrepareFailedException.java | 2 +-
.../core/exception/ScalingTaskExecuteException.java | 1 -
.../scaling/core/execute/executor/ScalingExecutor.java | 4 ++--
.../core/service/impl/DistributedScalingJobService.java | 3 +--
.../core/service/impl/StandaloneScalingJobService.java | 3 +--
.../shardingsphere/scaling/core/spi/ScalingEntry.java | 4 ++--
.../shardingsphere-scaling-elasticjob/pom.xml | 4 +++-
.../shardingsphere-scaling-mysql/pom.xml | 1 +
.../shardingsphere-scaling-postgresql/pom.xml | 1 +
17 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/shardingsphere-scaling/pom.xml b/shardingsphere-scaling/pom.xml
index 143b50b..94f9673 100755
--- a/shardingsphere-scaling/pom.xml
+++ b/shardingsphere-scaling/pom.xml
@@ -29,10 +29,10 @@
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-scaling-core</module>
<module>shardingsphere-scaling-bootstrap</module>
+ <module>shardingsphere-scaling-core</module>
+ <module>shardingsphere-scaling-elasticjob</module>
<module>shardingsphere-scaling-mysql</module>
<module>shardingsphere-scaling-postgresql</module>
- <module>shardingsphere-scaling-elasticjob</module>
</modules>
</project>
diff --git a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/pom.xml
index 5d54d54..8835bf8 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/pom.xml
@@ -36,20 +36,20 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-scaling-mysql</artifactId>
+ <artifactId>shardingsphere-scaling-elasticjob</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-scaling-postgresql</artifactId>
+ <artifactId>shardingsphere-scaling-mysql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-scaling-elasticjob</artifactId>
+ <artifactId>shardingsphere-scaling-postgresql</artifactId>
<version>${project.version}</version>
</dependency>
-
+
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
@@ -67,6 +67,7 @@
<artifactId>HikariCP</artifactId>
<scope>compile</scope>
</dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
@@ -77,6 +78,7 @@
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
diff --git a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/ServerBootstrap.java b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/ServerBootstrap.java
index a10889e..35d7eae 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/ServerBootstrap.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/ServerBootstrap.java
@@ -29,7 +29,7 @@ import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
-import org.apache.shardingsphere.scaling.util.ServerConfigurationUtil;
+import org.apache.shardingsphere.scaling.util.ServerConfigurationInitializer;
import org.apache.shardingsphere.scaling.web.HttpServerInitializer;
/**
@@ -48,7 +48,7 @@ public final class ServerBootstrap {
public static void main(final String[] args) {
// CHECKSTYLE:ON
log.info("ShardingSphere-Scaling Server Startup");
- ServerConfigurationUtil.initScalingConfig();
+ ServerConfigurationInitializer.init();
startScalingServer();
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/WorkerBootstrap.java b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/WorkerBootstrap.java
index 5edf619..3063433 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/WorkerBootstrap.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/WorkerBootstrap.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.scaling.core.spi.ScalingWorkerLoader;
-import org.apache.shardingsphere.scaling.util.ServerConfigurationUtil;
+import org.apache.shardingsphere.scaling.util.ServerConfigurationInitializer;
import java.util.Optional;
@@ -41,7 +41,7 @@ public final class WorkerBootstrap {
public static void main(final String[] args) {
// CHECKSTYLE:ON
log.info("ShardingSphere-Scaling Worker Startup");
- ServerConfigurationUtil.initScalingConfig();
+ ServerConfigurationInitializer.init();
Optional<String> type = ScalingWorkerLoader.initScalingWorker();
if (!type.isPresent()) {
log.error("None worker found.");
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/ServerConfigurationInitializer.java
similarity index 81%
rename from shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtil.java
rename to shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/main/java/org/apache/shardingsphere/scaling/util/ServerConfigurationInitializer.java
index 563ff34..cb4b899 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/ServerConfigurationInitializer.java
@@ -32,23 +32,21 @@ import java.io.File;
import java.io.IOException;
/**
- * Scaling config util.
+ * Scaling configuration initializer.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Slf4j
-public final class ServerConfigurationUtil {
+public final class ServerConfigurationInitializer {
- private static final String DEFAULT_CONFIG_PATH = "conf/";
-
- private static final String DEFAULT_CONFIG_FILE_NAME = "server.yaml";
+ private static final String SERVER_FILE = "conf/server.yaml";
/**
- * Init scaling config.
+ * Init scaling configuration.
*/
@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());
+ public static void init() {
+ log.info("Initialize scaling configuration.");
+ File yamlFile = new File(Resources.getResource(SERVER_FILE).getPath());
YamlServerConfiguration serverConfig = YamlEngine.unmarshal(yamlFile, YamlServerConfiguration.class);
Preconditions.checkNotNull(serverConfig, "Server configuration file `%s` is invalid.", yamlFile.getName());
ScalingContext.getInstance().init(new ServerConfigurationYamlSwapper().swapToObject(serverConfig));
diff --git a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/test/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtilTest.java b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/test/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtilTest.java
index f659abe..31930b5 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/test/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtilTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/test/java/org/apache/shardingsphere/scaling/util/ServerConfigurationUtilTest.java
@@ -26,7 +26,7 @@ public final class ServerConfigurationUtilTest {
@Test
public void assertInitScalingConfig() {
- ServerConfigurationUtil.initScalingConfig();
+ ServerConfigurationInitializer.init();
assertNotNull(ScalingContext.getInstance().getServerConfig());
}
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml
index 9a3fc32..c18b682 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/pom.xml
@@ -69,7 +69,7 @@
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
-
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
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 a4cd8ca..eb21df7 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
@@ -32,18 +32,18 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Data source manager.
*/
-@Slf4j
@NoArgsConstructor
+@Slf4j
public final class DataSourceManager implements AutoCloseable {
private final DataSourceFactory dataSourceFactory = new DataSourceFactory();
-
+
@Getter
private final Map<ScalingDataSourceConfiguration, DataSourceWrapper> cachedDataSources = new ConcurrentHashMap<>();
-
+
@Getter
private final Map<ScalingDataSourceConfiguration, DataSourceWrapper> sourceDataSources = new ConcurrentHashMap<>();
-
+
public DataSourceManager(final List<TaskConfiguration> taskConfigs) {
createDataSources(taskConfigs);
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/PrepareFailedException.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/PrepareFailedException.java
index 2bdcd01..a520116 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/PrepareFailedException.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/PrepareFailedException.java
@@ -27,7 +27,7 @@ public final class PrepareFailedException extends RuntimeException {
public PrepareFailedException(final String message) {
super(message);
}
-
+
public PrepareFailedException(final String message, final Throwable cause) {
super(message, cause);
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/ScalingTaskExecuteException.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/ScalingTaskExecuteException.java
index 63cc1e8..b24bd23 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/ScalingTaskExecuteException.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/exception/ScalingTaskExecuteException.java
@@ -35,5 +35,4 @@ public final class ScalingTaskExecuteException extends RuntimeException {
public ScalingTaskExecuteException(final String message, final Throwable cause) {
super(message, cause);
}
-
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/ScalingExecutor.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/ScalingExecutor.java
index 9ab19d7..699ca8c 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/ScalingExecutor.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/ScalingExecutor.java
@@ -21,12 +21,12 @@ package org.apache.shardingsphere.scaling.core.execute.executor;
* Scaling executor.
*/
public interface ScalingExecutor extends Runnable {
-
+
/**
* Start run execute.
*/
void start();
-
+
/**
* Stop running execute.
*/
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobService.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobService.java
index bac4f70..40eaef9 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobService.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/DistributedScalingJobService.java
@@ -34,7 +34,6 @@ import org.apache.shardingsphere.scaling.core.job.task.inventory.InventoryTaskGr
import org.apache.shardingsphere.scaling.core.job.task.inventory.InventoryTaskProgress;
import org.apache.shardingsphere.scaling.core.service.AbstractScalingJobService;
import org.apache.shardingsphere.scaling.core.service.RegistryRepositoryHolder;
-import org.apache.shardingsphere.scaling.core.service.ScalingJobService;
import org.apache.shardingsphere.scaling.core.utils.ScalingTaskUtil;
import org.apache.shardingsphere.scaling.core.utils.TaskConfigurationUtil;
@@ -45,7 +44,7 @@ import java.util.stream.Collectors;
/**
* Distributed scaling job service.
*/
-public final class DistributedScalingJobService extends AbstractScalingJobService implements ScalingJobService {
+public final class DistributedScalingJobService extends AbstractScalingJobService {
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().serializeNulls().create();
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobService.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobService.java
index dff7a80..49ee135 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobService.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/service/impl/StandaloneScalingJobService.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.scaling.core.job.task.inventory.InventoryTaskPr
import org.apache.shardingsphere.scaling.core.schedule.JobStatus;
import org.apache.shardingsphere.scaling.core.schedule.ScalingTaskScheduler;
import org.apache.shardingsphere.scaling.core.service.AbstractScalingJobService;
-import org.apache.shardingsphere.scaling.core.service.ScalingJobService;
import java.util.Collection;
import java.util.LinkedList;
@@ -39,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Standalone scaling job service.
*/
-public final class StandaloneScalingJobService extends AbstractScalingJobService implements ScalingJobService {
+public final class StandaloneScalingJobService extends AbstractScalingJobService {
private final Map<Long, ScalingJob> scalingJobMap = new ConcurrentHashMap<>();
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java
index 692504e..247895c 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java
@@ -44,7 +44,7 @@ public interface ScalingEntry extends DatabaseTypeAwareSPI {
* @return log dumper type
*/
Class<? extends LogDumper> getLogDumperClass();
-
+
/**
* Get position manager type.
*
@@ -58,7 +58,7 @@ public interface ScalingEntry extends DatabaseTypeAwareSPI {
* @return importer type
*/
Class<? extends Importer> getImporterClass();
-
+
/**
* Get data source checker.
*
diff --git a/shardingsphere-scaling/shardingsphere-scaling-elasticjob/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-elasticjob/pom.xml
index 91a6264..1274885 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-elasticjob/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-elasticjob/pom.xml
@@ -27,13 +27,14 @@
</parent>
<artifactId>shardingsphere-scaling-elasticjob</artifactId>
<name>${project.artifactId}</name>
-
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-scaling-core</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
<artifactId>elasticjob-lite-core</artifactId>
@@ -49,6 +50,7 @@
<artifactId>elasticjob-lite-lifecycle</artifactId>
<version>${elasticjob.version}</version>
</dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
diff --git a/shardingsphere-scaling/shardingsphere-scaling-mysql/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-mysql/pom.xml
index b5bef91..6619f9d 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-mysql/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-mysql/pom.xml
@@ -44,6 +44,7 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
diff --git a/shardingsphere-scaling/shardingsphere-scaling-postgresql/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-postgresql/pom.xml
index 91b1b80..0956096 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-postgresql/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-postgresql/pom.xml
@@ -40,6 +40,7 @@
<artifactId>postgresql</artifactId>
<scope>compile</scope>
</dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>