diff --git a/disjob-admin/ruoyi-disjob/src/main/resources/application-disjob-redis.yml b/disjob-admin/ruoyi-disjob/src/main/resources/application-disjob-redis.yml
index 027cbc5a8..0fb727873 100644
--- a/disjob-admin/ruoyi-disjob/src/main/resources/application-disjob-redis.yml
+++ b/disjob-admin/ruoyi-disjob/src/main/resources/application-disjob-redis.yml
@@ -28,5 +28,5 @@ spring.redis:
# 使用redis做注册中心
disjob.registry.redis:
- namespace: redis_namespace
+ namespace: disjob_registry
session-timeout-ms: 60000
diff --git a/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerPszymczyk.java b/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerPszymczyk.java
index ecfc26d13..d5231252d 100644
--- a/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerPszymczyk.java
+++ b/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerPszymczyk.java
@@ -29,7 +29,7 @@ public static void main(String[] args) {
System.out.println("Embedded pszymczyk consul server starting...");
ConsulProcess consul = ConsulStarterBuilder.consulStarter()
- .withConsulVersion("1.14.2")
+ .withConsulVersion("1.15.4")
.withConsulBinaryDownloadDirectory(createConsulBinaryDownloadDirectory())
.withHttpPort(8500)
.buildAndStart();
@@ -39,7 +39,7 @@ public static void main(String[] args) {
}
private static Path createConsulBinaryDownloadDirectory() {
- File file = new File(MavenProjects.getProjectBaseDir() + "/target/consul/");
+ File file = new File(MavenProjects.getProjectBaseDir() + "/src/bin/consul/");
file.mkdirs();
return file.toPath();
}
diff --git a/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerTestcontainers.java b/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerTestcontainers.java
index e4663b277..be2622f3d 100644
--- a/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerTestcontainers.java
+++ b/disjob-registry/disjob-registry-consul/src/test/java/cn/ponfee/disjob/registry/consul/EmbeddedConsulServerTestcontainers.java
@@ -21,9 +21,13 @@
* Embedded consul server based testcontainers.
* testcontainers consul
* 1、startup local docker environment
- * 2、pull docker consul image: docker pull consul:1.14.2
+ * 2、pull docker consul image: docker pull consul:1.15.4
* 3、"consul:1.14.2" is docker {image-name:version}
*
+ * Other:
+ * 本地搜索:docker search consul --limit 20
+ * docker官网查看版本:https://hub.docker.com/_/consul/tags
+ *
* 查看latest的具体版本号:docker image inspect {image-name}:latest | grep -i version
*
*
@@ -31,7 +35,7 @@
*/
public final class EmbeddedConsulServerTestcontainers {
- private static final String CONSUL_DOCKER_IMAGE_NAME = "consul:1.14.2";
+ private static final String CONSUL_DOCKER_IMAGE_NAME = "consul:1.15.4";
private static final List PORT_BINDINGS = Arrays.asList("8500:8500/tcp", "8502:8502/tcp");
public static void main(String[] args) {
diff --git a/disjob-registry/disjob-registry-etcd/src/test/java/cn/ponfee/disjob/registry/etcd/EmbeddedEtcdServerTestcontainers.java b/disjob-registry/disjob-registry-etcd/src/test/java/cn/ponfee/disjob/registry/etcd/EmbeddedEtcdServerTestcontainers.java
index d4b665eea..465442a86 100644
--- a/disjob-registry/disjob-registry-etcd/src/test/java/cn/ponfee/disjob/registry/etcd/EmbeddedEtcdServerTestcontainers.java
+++ b/disjob-registry/disjob-registry-etcd/src/test/java/cn/ponfee/disjob/registry/etcd/EmbeddedEtcdServerTestcontainers.java
@@ -10,6 +10,7 @@
import io.etcd.jetcd.launcher.Etcd;
import io.etcd.jetcd.launcher.EtcdCluster;
+import org.assertj.core.api.Assertions;
import java.util.Arrays;
import java.util.List;
@@ -25,7 +26,7 @@
public final class EmbeddedEtcdServerTestcontainers {
private static final String ETCD_DOCKER_IMAGE_NAME = "gcr.io/etcd-development/etcd:v3.5.4";
- private static final List PORT_BINDINGS = Arrays.asList("2379:2379", "2380:2380", "8080:8080");
+ private static final List PORT_BINDINGS = Arrays.asList("2379:2379/tcp", "2380:2380/tcp", "8080:8080/tcp");
public static void main(String[] args) throws Exception {
EtcdCluster etcd = Etcd.builder()
@@ -42,6 +43,8 @@ public static void main(String[] args) throws Exception {
try {
System.out.println("Embedded docker etcd server starting...");
etcd.start();
+ Assertions.assertThat(etcd.containers()).hasSize(1);
+ Assertions.assertThat(etcd.containers().get(0).getPortBindings()).hasSameElementsAs(PORT_BINDINGS);
System.out.println("Embedded docker etcd server started!");
new CountDownLatch(1).await();
} finally {
diff --git a/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java b/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java
index 2891f90c6..b4458a0a2 100644
--- a/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java
+++ b/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java
@@ -8,6 +8,7 @@
package cn.ponfee.disjob.samples.worker;
+import cn.ponfee.disjob.common.base.LazyLoader;
import cn.ponfee.disjob.common.base.TimingWheel;
import cn.ponfee.disjob.common.collect.Collects;
import cn.ponfee.disjob.common.exception.Throwables.ThrowingRunnable;
@@ -63,8 +64,6 @@ public class WorkerFramelessMain {
private static final Logger LOG = LoggerFactory.getLogger(WorkerFramelessMain.class);
- private static StringRedisTemplate stringRedisTemplate = null;
-
public static void main(String[] args) throws Exception {
printBanner();
@@ -91,6 +90,9 @@ public static void main(String[] args) throws Exception {
props.getInt(WORKER_KEY_PREFIX + ".timing-wheel-ring-size", 60)
);
+ LazyLoader stringRedisTemplateLoader = LazyLoader.of(
+ () -> AbstractRedisTemplateCreator.create(DISJOB_KEY_PREFIX + ".redis.", props, null).getStringRedisTemplate()
+ );
@@ -98,7 +100,7 @@ public static void main(String[] args) throws Exception {
WorkerRegistry workerRegistry;
{
// redis registry
- workerRegistry = createRedisWorkerRegistry(JobConstants.DISJOB_REGISTRY_KEY_PREFIX + ".redis", props);
+ workerRegistry = createRedisWorkerRegistry(JobConstants.DISJOB_REGISTRY_KEY_PREFIX + ".redis", props, stringRedisTemplateLoader);
// consul registry
//workerRegistry = createConsulWorkerRegistry(JobConstants.DISJOB_REGISTRY_KEY_PREFIX + ".consul", props);
@@ -114,7 +116,7 @@ public static void main(String[] args) throws Exception {
WorkerRpcService workerRpcProvider = new WorkerRpcProvider(currentWorker, workerRegistry);
{
// redis dispatching
- //taskReceiver = new RedisTaskReceiver(currentWorker, timingWheel, stringRedisTemplate) {
+ //taskReceiver = new RedisTaskReceiver(currentWorker, timingWheel, stringRedisTemplateLoader.get()) {
// @Override
// public boolean receive(ExecuteTaskParam param) {
// JobHandlerParser.parse(param, "jobHandler");
@@ -175,11 +177,12 @@ private static void printBanner() throws IOException {
System.out.println(banner);
}
- private static WorkerRegistry createRedisWorkerRegistry(String keyPrefix, YamlProperties props) {
+ private static WorkerRegistry createRedisWorkerRegistry(String keyPrefix, YamlProperties props,
+ LazyLoader stringRedisTemplateLoader) {
RedisRegistryProperties config = new RedisRegistryProperties();
config.setNamespace(props.getString(keyPrefix + ".namespace"));
config.setSessionTimeoutMs(props.getLong(keyPrefix + ".session-timeout-ms", 30000));
- return new RedisWorkerRegistry(stringRedisTemplate(props), config);
+ return new RedisWorkerRegistry(stringRedisTemplateLoader.get(), config);
}
/*
@@ -193,12 +196,4 @@ private static WorkerRegistry createConsulWorkerRegistry(String keyPrefix, YamlP
}
*/
- private static synchronized StringRedisTemplate stringRedisTemplate(YamlProperties props) {
- if (stringRedisTemplate == null) {
- String keyPrefix = DISJOB_KEY_PREFIX + ".redis.";
- stringRedisTemplate = AbstractRedisTemplateCreator.create(keyPrefix, props, null).getStringRedisTemplate();
- }
- return stringRedisTemplate;
- }
-
}
diff --git a/disjob-samples/disjob-samples-frameless-worker/src/main/resources/worker-conf.yml b/disjob-samples/disjob-samples-frameless-worker/src/main/resources/worker-conf.yml
index 049801304..85cb97160 100644
--- a/disjob-samples/disjob-samples-frameless-worker/src/main/resources/worker-conf.yml
+++ b/disjob-samples/disjob-samples-frameless-worker/src/main/resources/worker-conf.yml
@@ -20,11 +20,11 @@ disjob:
registry:
# redis做注册中心时需要配置
redis:
- namespace: redis_namespace
+ namespace: disjob_registry
session-timeout-ms: 60000
# consul做注册中心时需要配置
consul:
- namespace: consul_namespace
+ namespace: disjob_registry
host: localhost
port: 8500
token:
diff --git a/disjob-samples/disjob-samples-springboot-common/src/main/resources/application-redis.yml b/disjob-samples/disjob-samples-springboot-common/src/main/resources/application-redis.yml
index 027cbc5a8..0fb727873 100644
--- a/disjob-samples/disjob-samples-springboot-common/src/main/resources/application-redis.yml
+++ b/disjob-samples/disjob-samples-springboot-common/src/main/resources/application-redis.yml
@@ -28,5 +28,5 @@ spring.redis:
# 使用redis做注册中心
disjob.registry.redis:
- namespace: redis_namespace
+ namespace: disjob_registry
session-timeout-ms: 60000
diff --git a/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedH2DatabaseServer.java b/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedH2DatabaseServer.java
index 393cd14d7..93577e205 100644
--- a/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedH2DatabaseServer.java
+++ b/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedH2DatabaseServer.java
@@ -50,7 +50,6 @@ public static void main(String[] args) throws Exception {
new org.h2.server.TcpServer().start();
//new org.h2.server.web.WebServer().start();
//new org.h2.server.pg.PgServer().start();
- System.out.println("Embedded h2 database started!");
JdbcTemplate jdbcTemplate = DBUtils.createJdbcTemplate(jdbcUrl, username, password);
@@ -62,6 +61,7 @@ public static void main(String[] args) throws Exception {
System.out.println("\n--------------------------------------------------------testScript");
testScript(jdbcTemplate);
+ System.out.println("Embedded h2 database started!");
new CountDownLatch(1).await();
}
diff --git a/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedMysqlServerTestcontainers.java b/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedMysqlServerTestcontainers.java
index 8e77a59d2..0cac5170e 100644
--- a/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedMysqlServerTestcontainers.java
+++ b/disjob-test/src/main/java/cn/ponfee/disjob/test/db/EmbeddedMysqlServerTestcontainers.java
@@ -58,7 +58,6 @@ public static void main(String[] args) throws Exception {
System.out.println("Embedded docker mysql starting...");
mySQLContainer.start();
- System.out.println("Embedded docker mysql started!");
//mySQLContainer.execInContainer("mysqld --skip-grant-tables");
// scriptPath只用于打印日志,此处直接设置为空字符串
@@ -78,6 +77,7 @@ public static void main(String[] args) throws Exception {
System.out.println("\n--------------------------------------------------------testQuerySql");
DBUtils.testQuerySchedJob(jdbcTemplate);
+ System.out.println("Embedded docker mysql started!");
new CountDownLatch(1).await();
}
}
diff --git a/disjob-worker/src/main/java/cn/ponfee/disjob/worker/base/TimingWheelRotator.java b/disjob-worker/src/main/java/cn/ponfee/disjob/worker/base/TimingWheelRotator.java
index 93e7af1af..688c66c7c 100644
--- a/disjob-worker/src/main/java/cn/ponfee/disjob/worker/base/TimingWheelRotator.java
+++ b/disjob-worker/src/main/java/cn/ponfee/disjob/worker/base/TimingWheelRotator.java
@@ -92,7 +92,7 @@ private void process() {
// check has available supervisors
if (!discoverySupervisor.hasDiscoveredServers()) {
if (System.currentTimeMillis() > nextLogTimeMillis) {
- nextLogTimeMillis = System.currentTimeMillis() + 5000L;
+ this.nextLogTimeMillis = System.currentTimeMillis() + 5000L;
LOG.warn("Not found available supervisor.");
}
return;