You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/21 03:40:17 UTC
[shardingsphere-elasticjob] branch master updated: Merge spring
boot starter to one module (#1203)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new e61905b Merge spring boot starter to one module (#1203)
e61905b is described below
commit e61905bc08b598c233ca60f7edae26e18b9dfbcf
Author: 吴伟杰 <ro...@me.com>
AuthorDate: Tue Jul 21 11:36:48 2020 +0800
Merge spring boot starter to one module (#1203)
- Merge registry-center, tracing into elasticjob-lite-spring-boot-starter.
- Update pom.xml which referenced elasticjob-tracing-spring-boot-starter.
- Update Spring Boot Starter example.
---
.../elasticjob-lite-distribution/pom.xml | 2 +-
.../pom.xml | 61 ------------------
.../src/main/resources/META-INF/spring.factories | 18 ------
.../reg/boot/RegistryCenterSpringBootTest.java | 58 -----------------
.../reg/boot/fixture/EmbedTestingServer.java | 69 --------------------
.../src/test/resources/application-elasticjob.yml | 21 ------
.../elasticjob-tracing-spring-boot-starter/pom.xml | 75 ----------------------
.../src/main/resources/META-INF/spring.factories | 18 ------
.../boot/TracingConfigurationSpringBootTest.java | 56 ----------------
.../tracing/boot/fixture/EmbedTestingServer.java | 68 --------------------
.../src/test/resources/application-elasticjob.yml | 29 ---------
elasticjob-infra/elasticjob-tracing/pom.xml | 1 -
elasticjob-infra/pom.xml | 1 -
.../elasticjob-lite-spring-boot-starter/pom.xml | 19 +++++-
.../boot/job/ElasticJobLiteAutoConfiguration.java | 8 ++-
.../reg/ElasticJobRegistryCenterConfiguration.java | 6 +-
.../lite/spring/boot/reg}/ZookeeperProperties.java | 2 +-
.../tracing/ElasticJobTracingConfiguration.java | 12 +---
.../spring/boot/job/ElasticJobSpringBootTest.java | 37 ++++++++++-
.../elasticjob-example-lite-springboot/pom.xml | 5 --
.../example/controller/OneOffJobController.java | 2 +-
21 files changed, 64 insertions(+), 504 deletions(-)
diff --git a/elasticjob-distribution/elasticjob-lite-distribution/pom.xml b/elasticjob-distribution/elasticjob-lite-distribution/pom.xml
index 3d91967..0a9e2b1 100644
--- a/elasticjob-distribution/elasticjob-lite-distribution/pom.xml
+++ b/elasticjob-distribution/elasticjob-lite-distribution/pom.xml
@@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-tracing-spring-boot-starter</artifactId>
+ <artifactId>elasticjob-lite-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml
deleted file mode 100644
index 2cc4548..0000000
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-infra</artifactId>
- <version>3.0.0.M1-SNAPSHOT</version>
- </parent>
- <artifactId>elasticjob-registry-center-spring-boot-starter</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-registry-center</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/resources/META-INF/spring.factories b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index 6e85383..0000000
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- org.apache.shardingsphere.elasticjob.reg.boot.ElasticJobRegistryCenterAutoConfiguration
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/RegistryCenterSpringBootTest.java b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/RegistryCenterSpringBootTest.java
deleted file mode 100644
index 7c61d48..0000000
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/RegistryCenterSpringBootTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.elasticjob.reg.boot;
-
-import org.apache.shardingsphere.elasticjob.reg.boot.fixture.EmbedTestingServer;
-import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-@SpringBootTest
-@SpringBootApplication
-@ActiveProfiles("elasticjob")
-public class RegistryCenterSpringBootTest extends AbstractJUnit4SpringContextTests {
-
- @BeforeClass
- public static void init() {
- EmbedTestingServer.start();
- }
-
- @Test
- public void testZookeeperProperties() {
- assertNotNull(applicationContext);
- ZookeeperProperties zookeeperProperties = applicationContext.getBean(ZookeeperProperties.class);
- assertEquals(EmbedTestingServer.getConnectionString(), zookeeperProperties.getServerLists());
- assertEquals("elasticjob-registry-center-spring-boot-starter", zookeeperProperties.getNamespace());
- }
-
- @Test
- public void testRegistryCenterCreation() {
- assertNotNull(applicationContext);
- ZookeeperRegistryCenter zookeeperRegistryCenter = applicationContext.getBean(ZookeeperRegistryCenter.class);
- assertNotNull(zookeeperRegistryCenter);
- zookeeperRegistryCenter.persist("/foo", "bar");
- assertEquals("bar", zookeeperRegistryCenter.get("/foo"));
- }
-}
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/fixture/EmbedTestingServer.java b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/fixture/EmbedTestingServer.java
deleted file mode 100644
index 3e75e7a..0000000
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/fixture/EmbedTestingServer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.elasticjob.reg.boot.fixture;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.curator.test.TestingServer;
-import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
-
-import java.io.File;
-import java.io.IOException;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class EmbedTestingServer {
-
- private static final int PORT = 16181;
-
- private static volatile TestingServer testingServer;
-
- /**
- * Get the connection string.
- *
- * @return connection string
- */
- public static String getConnectionString() {
- return "localhost:" + PORT;
- }
-
- /**
- * Start the server.
- */
- public static void start() {
- if (null != testingServer) {
- return;
- }
- try {
- testingServer = new TestingServer(PORT, new File(String.format("target/test_zk_data/%s/", System.nanoTime())));
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- RegExceptionHandler.handleException(ex);
- } finally {
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- try {
- Thread.sleep(1000);
- testingServer.close();
- } catch (final IOException | InterruptedException ex) {
- RegExceptionHandler.handleException(ex);
- }
- }));
- }
- }
-}
-
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/resources/application-elasticjob.yml b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/resources/application-elasticjob.yml
deleted file mode 100644
index ad20bd2..0000000
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/resources/application-elasticjob.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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.
-#
-
-elasticjob:
- regCenter:
- serverLists: localhost:16181
- namespace: elasticjob-registry-center-spring-boot-starter
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml
deleted file mode 100644
index 5dd5d9a..0000000
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-tracing</artifactId>
- <version>3.0.0.M1-SNAPSHOT</version>
- </parent>
- <artifactId>elasticjob-tracing-spring-boot-starter</artifactId>
- <name>${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-tracing-rdb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-lite-spring-boot-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-jdbc</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/main/resources/META-INF/spring.factories b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index 4d10fa3..0000000
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- org.apache.shardingsphere.elasticjob.tracing.boot.ElasticJobTracingAutoConfiguration
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/TracingConfigurationSpringBootTest.java b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/TracingConfigurationSpringBootTest.java
deleted file mode 100644
index 8b49cf8..0000000
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/TracingConfigurationSpringBootTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.elasticjob.tracing.boot;
-
-import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
-import org.apache.shardingsphere.elasticjob.tracing.boot.fixture.EmbedTestingServer;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@SpringBootTest
-@SpringBootApplication
-@ActiveProfiles("elasticjob")
-public class TracingConfigurationSpringBootTest extends AbstractJUnit4SpringContextTests {
-
- @BeforeClass
- public static void setUp() {
- EmbedTestingServer.start();
- }
-
- @Test
- public void testTracingConfigurationCreation() throws SQLException {
- assertNotNull(applicationContext);
- TracingConfiguration tracingConfiguration = applicationContext.getBean(TracingConfiguration.class);
- assertNotNull(tracingConfiguration);
- assertEquals("RDB", tracingConfiguration.getType());
- assertTrue(tracingConfiguration.getStorage() instanceof DataSource);
- DataSource dataSource = (DataSource) tracingConfiguration.getStorage();
- assertNotNull(dataSource.getConnection());
- }
-}
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/fixture/EmbedTestingServer.java b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/fixture/EmbedTestingServer.java
deleted file mode 100644
index 09a001b..0000000
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/fixture/EmbedTestingServer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.elasticjob.tracing.boot.fixture;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.curator.test.TestingServer;
-import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
-
-import java.io.File;
-import java.io.IOException;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class EmbedTestingServer {
-
- private static final int PORT = 17181;
-
- private static volatile TestingServer testingServer;
-
- /**
- * Get the connection string.
- *
- * @return connection string
- */
- public static String getConnectionString() {
- return "localhost:" + PORT;
- }
-
- /**
- * Start the server.
- */
- public static void start() {
- if (null != testingServer) {
- return;
- }
- try {
- testingServer = new TestingServer(PORT, new File(String.format("target/test_zk_data/%s/", System.nanoTime())));
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- RegExceptionHandler.handleException(ex);
- } finally {
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- try {
- Thread.sleep(1000);
- testingServer.close();
- } catch (final IOException | InterruptedException ex) {
- RegExceptionHandler.handleException(ex);
- }
- }));
- }
- }
-}
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/resources/application-elasticjob.yml b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/resources/application-elasticjob.yml
deleted file mode 100644
index fd69e73..0000000
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/resources/application-elasticjob.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# 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.
-#
-
-spring:
- datasource:
- url: jdbc:h2:mem:job_event_storage
- driver-class-name: org.h2.Driver
- username: sa
- password:
-elasticjob:
- reg-center:
- server-lists: localhost:17181
- namespace: elasticjob-tracing-spring-boot-starter
- tracing:
- type: RDB
diff --git a/elasticjob-infra/elasticjob-tracing/pom.xml b/elasticjob-infra/elasticjob-tracing/pom.xml
index 4627602..83df46b 100644
--- a/elasticjob-infra/elasticjob-tracing/pom.xml
+++ b/elasticjob-infra/elasticjob-tracing/pom.xml
@@ -32,6 +32,5 @@
<modules>
<module>elasticjob-tracing-api</module>
<module>elasticjob-tracing-rdb</module>
- <module>elasticjob-tracing-spring-boot-starter</module>
</modules>
</project>
diff --git a/elasticjob-infra/pom.xml b/elasticjob-infra/pom.xml
index 1fe5f6c..937bddf 100644
--- a/elasticjob-infra/pom.xml
+++ b/elasticjob-infra/pom.xml
@@ -33,6 +33,5 @@
<module>elasticjob-infra-common</module>
<module>elasticjob-registry-center</module>
<module>elasticjob-tracing</module>
- <module>elasticjob-registry-center-spring-boot-starter</module>
</modules>
</project>
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml
index 177bbde..f92a79e 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml
@@ -46,9 +46,22 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-registry-center-spring-boot-starter</artifactId>
- <version>${project.version}</version>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jdbc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobLiteAutoConfiguration.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobLiteAutoConfiguration.java
index 999d043..37a3927 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobLiteAutoConfiguration.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobLiteAutoConfiguration.java
@@ -24,13 +24,15 @@ import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.OneOffJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.internal.config.pojo.JobConfigurationPOJO;
+import org.apache.shardingsphere.elasticjob.lite.spring.boot.reg.ElasticJobRegistryCenterConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.spring.boot.tracing.ElasticJobTracingConfiguration;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
-import org.apache.shardingsphere.elasticjob.reg.boot.ElasticJobRegistryCenterAutoConfiguration;
import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.SingletonBeanRegistry;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -47,9 +49,9 @@ import java.util.Map.Entry;
* ElasticJob-Lite auto configuration.
*/
@Configuration
-@AutoConfigureAfter(ElasticJobRegistryCenterAutoConfiguration.class)
+@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@ConditionalOnProperty(name = "elasticjob.enabled", havingValue = "true", matchIfMissing = true)
-@Import(ElasticJobStartupRunner.class)
+@Import({ElasticJobRegistryCenterConfiguration.class, ElasticJobTracingConfiguration.class, ElasticJobStartupRunner.class})
@EnableConfigurationProperties(ElasticJobProperties.class)
@Setter
public class ElasticJobLiteAutoConfiguration implements ApplicationContextAware {
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/reg/boot/ElasticJobRegistryCenterAutoConfiguration.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ElasticJobRegistryCenterConfiguration.java
similarity index 88%
rename from elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/reg/boot/ElasticJobRegistryCenterAutoConfiguration.java
rename to elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ElasticJobRegistryCenterConfiguration.java
index 862b48f..ea2a4ec 100644
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/reg/boot/ElasticJobRegistryCenterAutoConfiguration.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ElasticJobRegistryCenterConfiguration.java
@@ -15,16 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.reg.boot;
+package org.apache.shardingsphere.elasticjob.lite.spring.boot.reg;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-@Configuration
@EnableConfigurationProperties(ZookeeperProperties.class)
-public class ElasticJobRegistryCenterAutoConfiguration {
+public class ElasticJobRegistryCenterConfiguration {
/**
* Create a ZookeeperRegistryCenter bean via factory.
*
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/reg/boot/ZookeeperProperties.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperProperties.java
similarity index 97%
rename from elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/reg/boot/ZookeeperProperties.java
rename to elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperProperties.java
index 0cbb2aa..e81f379 100644
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/reg/boot/ZookeeperProperties.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/reg/ZookeeperProperties.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.reg.boot;
+package org.apache.shardingsphere.elasticjob.lite.spring.boot.reg;
import lombok.Getter;
import lombok.Setter;
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/tracing/boot/ElasticJobTracingAutoConfiguration.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java
similarity index 72%
rename from elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/tracing/boot/ElasticJobTracingAutoConfiguration.java
rename to elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java
index a587e16..7188ed1 100644
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/tracing/boot/ElasticJobTracingAutoConfiguration.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java
@@ -15,27 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.tracing.boot;
+package org.apache.shardingsphere.elasticjob.lite.spring.boot.tracing;
-import org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobLiteAutoConfiguration;
import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
/**
* ElasticJob tracing auto configuration.
*/
-@Configuration
-@AutoConfigureAfter(DataSourceAutoConfiguration.class)
-@AutoConfigureBefore(ElasticJobLiteAutoConfiguration.class)
-public class ElasticJobTracingAutoConfiguration {
+public class ElasticJobTracingConfiguration {
/**
* Create a bean of tracing configuration.
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java
index 9e531e9..12a8703 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java
@@ -21,6 +21,9 @@ import org.apache.shardingsphere.elasticjob.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.infra.concurrent.BlockUtils;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.OneOffJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.spring.boot.job.fixture.EmbedTestingServer;
+import org.apache.shardingsphere.elasticjob.lite.spring.boot.reg.ZookeeperProperties;
+import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
+import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -28,10 +31,14 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+import javax.sql.DataSource;
+import java.sql.SQLException;
import java.util.Map;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
@SpringBootTest
@SpringBootApplication
@@ -42,7 +49,35 @@ public class ElasticJobSpringBootTest extends AbstractJUnit4SpringContextTests {
public static void init() {
EmbedTestingServer.start();
}
-
+
+ @Test
+ public void testZookeeperProperties() {
+ assertNotNull(applicationContext);
+ ZookeeperProperties zookeeperProperties = applicationContext.getBean(ZookeeperProperties.class);
+ assertEquals(EmbedTestingServer.getConnectionString(), zookeeperProperties.getServerLists());
+ assertEquals("elasticjob-lite-spring-boot-starter", zookeeperProperties.getNamespace());
+ }
+
+ @Test
+ public void testRegistryCenterCreation() {
+ assertNotNull(applicationContext);
+ ZookeeperRegistryCenter zookeeperRegistryCenter = applicationContext.getBean(ZookeeperRegistryCenter.class);
+ assertNotNull(zookeeperRegistryCenter);
+ zookeeperRegistryCenter.persist("/foo", "bar");
+ assertEquals("bar", zookeeperRegistryCenter.get("/foo"));
+ }
+
+ @Test
+ public void testTracingConfigurationCreation() throws SQLException {
+ assertNotNull(applicationContext);
+ TracingConfiguration tracingConfiguration = applicationContext.getBean(TracingConfiguration.class);
+ assertNotNull(tracingConfiguration);
+ assertEquals("RDB", tracingConfiguration.getType());
+ assertTrue(tracingConfiguration.getStorage() instanceof DataSource);
+ DataSource dataSource = (DataSource) tracingConfiguration.getStorage();
+ assertNotNull(dataSource.getConnection());
+ }
+
@Test
public void testJobScheduleCreation() {
assertNotNull(applicationContext);
diff --git a/examples/elasticjob-example-lite-springboot/pom.xml b/examples/elasticjob-example-lite-springboot/pom.xml
index 69aee24..632d2fa 100644
--- a/examples/elasticjob-example-lite-springboot/pom.xml
+++ b/examples/elasticjob-example-lite-springboot/pom.xml
@@ -51,11 +51,6 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
- <artifactId>elasticjob-tracing-spring-boot-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere.elasticjob</groupId>
<artifactId>elasticjob-example-embed-zk</artifactId>
<version>${project.parent.version}</version>
</dependency>
diff --git a/examples/elasticjob-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/controller/OneOffJobController.java b/examples/elasticjob-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/controller/OneOffJobController.java
index 3aee68c..075e750 100644
--- a/examples/elasticjob-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/controller/OneOffJobController.java
+++ b/examples/elasticjob-example-lite-springboot/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/controller/OneOffJobController.java
@@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
-@DependsOn("ElasticJobLiteAutoConfiguration")
+@DependsOn("org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobLiteAutoConfiguration")
public class OneOffJobController {
@Resource(name = "manualScriptJobOneOffJobBootstrap")