From 67aef1128cb66b13da87a3e457f8e343f7426dca Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Thu, 25 Apr 2024 14:43:11 +0800 Subject: [PATCH 01/11] 3.2.5-SNAPSHOT KeelSundial use Verticle to wrap a plan to execute. Signed-off-by: Sinri Edogawa --- pom.xml | 4 ++-- .../io/github/sinri/keel/servant/sundial/KeelSundial.java | 8 +++++++- .../sinri/keel/servant/sundial/KeelSundialVerticle.java | 1 + .../keel/test/lab/elasticsearch/ESCatIndicesTest.java | 8 ++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 13a71cc..97a6f5c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ io.github.sinri Keel - - 3.2.4 + 3.2.5-SNAPSHOT + Keel diff --git a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java index 1a2583a..d0c3cfc 100644 --- a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java +++ b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java @@ -5,7 +5,9 @@ import io.github.sinri.keel.logger.event.KeelEventLogger; import io.github.sinri.keel.logger.issue.center.KeelIssueRecordCenter; import io.github.sinri.keel.verticles.KeelVerticleImplWithEventLogger; +import io.vertx.core.DeploymentOptions; import io.vertx.core.Future; +import io.vertx.core.ThreadingModel; import io.vertx.core.json.JsonObject; import java.util.*; @@ -48,7 +50,11 @@ private void handleEveryMinute(Calendar now) { .put("plan_cron", plan.cronExpression()) .put("now", parsedCalenderElements.toString()) ); - plan.execute(now); + + // since 3.2.5 + new KeelSundialVerticle(plan, now).deployMe(new DeploymentOptions() + .setThreadingModel(ThreadingModel.WORKER) + ); } else { getLogger().debug("Sundial Plan Not Match", new JsonObject() .put("plan_key", plan.key()) diff --git a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java index c512904..d0d60e8 100644 --- a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java +++ b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java @@ -8,6 +8,7 @@ /** * @since 3.2.4 + * @since 3.2.5 Used in KeelSundial */ public class KeelSundialVerticle extends KeelVerticleImplPure { private final KeelSundialPlan sundialPlan; diff --git a/src/test/java/io/github/sinri/keel/test/lab/elasticsearch/ESCatIndicesTest.java b/src/test/java/io/github/sinri/keel/test/lab/elasticsearch/ESCatIndicesTest.java index fa35dfb..e6ec7bc 100644 --- a/src/test/java/io/github/sinri/keel/test/lab/elasticsearch/ESCatIndicesTest.java +++ b/src/test/java/io/github/sinri/keel/test/lab/elasticsearch/ESCatIndicesTest.java @@ -1,5 +1,6 @@ package io.github.sinri.keel.test.lab.elasticsearch; +import io.github.sinri.keel.elasticsearch.ESApiMixin; import io.github.sinri.keel.elasticsearch.ElasticSearchKit; import io.github.sinri.keel.tesuto.KeelTest; import io.github.sinri.keel.tesuto.TestUnit; @@ -21,11 +22,14 @@ protected Future starting() { @TestUnit public Future test() { // {"client_code":"ai-test","timestamp":1712023360984,"checksum":"d6abf7d98af34907d97f6a6578a429b5","http_method":"GET","endpoint":"/_cat/indices"} + ESApiMixin.ESApiQueries esApiQueries = new ESApiMixin.ESApiQueries(); + //esApiQueries.put("format", "application/json"); return new ElasticSearchKit("kumori") .call( HttpMethod.GET, - "/_cat/indices", - null, + //"/_cat/indices", + "/*", + esApiQueries, null ) .compose(resp -> { From a2a8b00975c200eb7ea3554628dcbaa630f6a1e4 Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Fri, 26 Apr 2024 14:32:27 +0800 Subject: [PATCH 02/11] 3.2.5-SNAPSHOT GC: GarbageCollectorMXBean Name categorized for ZGC Pauses and ZGC Cycles Signed-off-by: Sinri Edogawa --- .../java/io/github/sinri/keel/helper/runtime/GCStatResult.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java b/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java index a465ab0..73c67ed 100644 --- a/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java +++ b/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java @@ -137,6 +137,8 @@ public JsonObject toJsonObject() { majorGCNames.add("G1 Old Generation"); // ZGC (Z Garbage Collector): "ZGC" minorGCNames.add("ZGC"); + majorGCNames.add("ZGC Pauses"); // since 3.2.5 + minorGCNames.add("ZGC Cycles"); // since 3.2.5 // Shenandoah: "Shenandoah Pauses" minorGCNames.add("Shenandoah Pauses"); } From 3ae60a2770d018078e5f9e1d841dad6f67f091eb Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Fri, 26 Apr 2024 17:45:02 +0800 Subject: [PATCH 03/11] 3.2.5-SNAPSHOT GC: GarbageCollectorMXBean Name categorized for ZGC Pauses and ZGC Cycles Signed-off-by: Sinri Edogawa --- .../sinri/keel/helper/runtime/GCStatResult.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java b/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java index 73c67ed..d192986 100644 --- a/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java +++ b/src/main/java/io/github/sinri/keel/helper/runtime/GCStatResult.java @@ -118,10 +118,12 @@ public JsonObject toJsonObject() { private static final Set minorGCNames; private static final Set majorGCNames; + private static final Set ignoreGCNames; static { minorGCNames = new HashSet<>(); majorGCNames = new HashSet<>(); + ignoreGCNames = new HashSet<>(); // Serial Collector: "Copy"(年轻代),"MarkSweepCompact"(老年代) minorGCNames.add("Copy"); @@ -136,9 +138,10 @@ public JsonObject toJsonObject() { minorGCNames.add("G1 Young Generation"); majorGCNames.add("G1 Old Generation"); // ZGC (Z Garbage Collector): "ZGC" - minorGCNames.add("ZGC"); - majorGCNames.add("ZGC Pauses"); // since 3.2.5 - minorGCNames.add("ZGC Cycles"); // since 3.2.5 + // @see https://armsword.com/2023/08/10/es-jdk17-and-zgc/ + //minorGCNames.add("ZGC"); + ignoreGCNames.add("ZGC Pauses"); // since 3.2.5 统计的是ZGC在GC过程中暂停的次数及暂停时间,这是JDK17新增的指标bean,无法统计Allocation Stall导致的线程挂起时间 + minorGCNames.add("ZGC Cycles"); // since 3.2.5 统计的是ZGC发生的次数以及总耗时 // Shenandoah: "Shenandoah Pauses" minorGCNames.add("Shenandoah Pauses"); } @@ -157,7 +160,7 @@ public GCStatResult refreshWithGC(@Nonnull GarbageCollectorMXBean gc) { if (gc.getCollectionTime() >= 0) { this.addGCTimeAsOld(gc.getCollectionTime()); } - } else { + } else if (!ignoreGCNames.contains(gc.getName())) { Keel.getLogger().error(log -> log .message("Found Unknown GarbageCollectorMXBean Name") .context(new JsonObject() From 28d9f56854a4ecc1a5f200090d67138fcb342277 Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Sun, 28 Apr 2024 19:35:44 +0800 Subject: [PATCH 04/11] 3.2.5 Signed-off-by: Sinri Edogawa --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 97a6f5c..1f18d43 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ io.github.sinri Keel - 3.2.5-SNAPSHOT - + + 3.2.5 Keel From 67a6b9b0920546541c6f6e0b8a31b275f3ecda6b Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Tue, 30 Apr 2024 16:59:38 +0800 Subject: [PATCH 05/11] 3.2.6-SNAPSHOT to be add doc Signed-off-by: Sinri Edogawa --- pom.xml | 4 ++-- .../io/github/sinri/keel/mysql/KeelMySQLConfiguration.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1f18d43..3bf52a4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ io.github.sinri Keel - - 3.2.5 + 3.2.6-SNAPSHOT + Keel diff --git a/src/main/java/io/github/sinri/keel/mysql/KeelMySQLConfiguration.java b/src/main/java/io/github/sinri/keel/mysql/KeelMySQLConfiguration.java index a6a9d70..070eb37 100644 --- a/src/main/java/io/github/sinri/keel/mysql/KeelMySQLConfiguration.java +++ b/src/main/java/io/github/sinri/keel/mysql/KeelMySQLConfiguration.java @@ -119,6 +119,10 @@ public Integer getPoolMaxSize() { return x.getValueAsInteger(); } + /** + * This data source name would be used in MySQL client pool name. + * Use different name for actually different data sources. + */ @Nonnull public String getDataSourceName() { return getName(); From a3421aca9af4d7119b6500caf52d55304a475c56 Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Mon, 6 May 2024 15:31:35 +0800 Subject: [PATCH 06/11] 3.2.6 Fix the Table Row Class Generate Source Code, to avoid non-null check in nullable declared field. Signed-off-by: Sinri Edogawa --- pom.xml | 4 +-- .../keel/mysql/dev/TableRowClassField.java | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 3bf52a4..f486059 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ io.github.sinri Keel - 3.2.6-SNAPSHOT - + + 3.2.6 Keel diff --git a/src/main/java/io/github/sinri/keel/mysql/dev/TableRowClassField.java b/src/main/java/io/github/sinri/keel/mysql/dev/TableRowClassField.java index 0e22269..73bf11f 100644 --- a/src/main/java/io/github/sinri/keel/mysql/dev/TableRowClassField.java +++ b/src/main/java/io/github/sinri/keel/mysql/dev/TableRowClassField.java @@ -163,12 +163,14 @@ public String build() { } code .append("\tpublic ").append(looseEnum.looseEnumName()).append(" ").append(getter).append("() {\n") - .append("\t\treturn ").append(looseEnum.looseEnumName()).append(".valueOf(\n") - .append("\t\t\t") - .append(nullable ? "" : "Objects.requireNonNull(") - .append(readMethod).append("(\"").append(field).append("\")") - .append(nullable ? "" : ")").append("\n") - .append("\t\t);\n") + .append("\t\t@Nullable String enumExpression=").append(readMethod).append("(\"").append(field).append("\");\n"); + if (nullable) { + code.append("\t\tif (enumExpression==null) return null;\n"); + } else { + code.append("\t\tObjects.requireNonNull(enumExpression,\"The Enum Field `").append(field).append("` should not be null!\");\n"); + } + code + .append("\t\treturn ").append(looseEnum.looseEnumName()).append(".valueOf(enumExpression);\n") .append("\t}\n"); } else if (strictEnum != null) { code.append("\t/*\n") @@ -185,12 +187,14 @@ public String build() { } code .append("\tpublic ").append(strictEnum.fullEnumRef()).append(" ").append(getter).append("() {\n") - .append("\t\treturn ").append(strictEnum.fullEnumRef()).append(".valueOf(\n") - .append("\t\t\t") - .append(nullable ? "" : "Objects.requireNonNull(") - .append(readMethod).append("(\"").append(field).append("\")") - .append(nullable ? "" : ")").append("\n") - .append("\t\t);\n") + .append("\t\t@Nullable String enumExpression=").append(readMethod).append("(\"").append(field).append("\");\n"); + if (nullable) { + code.append("\t\tif (enumExpression==null) return null;\n"); + } else { + code.append("\t\tObjects.requireNonNull(enumExpression,\"The Enum Field `").append(field).append("` should not be null!\");\n"); + } + code + .append("\t\treturn ").append(strictEnum.fullEnumRef()).append(".valueOf(enumExpression);\n") .append("\t}\n"); } else { code.append("\t/*\n"); From cba9c9031caca383f02ffcc5b2131b5d2eab75e7 Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Tue, 7 May 2024 14:24:03 +0800 Subject: [PATCH 07/11] 3.2.7-SNAPSHOT Signed-off-by: Sinri Edogawa --- pom.xml | 4 +-- .../keel/logger/event/KeelEventLogger.java | 5 ++++ .../logger/event/KeelEventLoggerImpl.java | 27 ++++++++++++------- .../io/github/sinri/keel/tesuto/KeelTest.java | 9 +++++++ .../sinri/keel/tesuto/TestUnitWrapper.java | 3 +++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index f486059..e78cd69 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ io.github.sinri Keel - - 3.2.6 + 3.2.7-SNAPSHOT + Keel diff --git a/src/main/java/io/github/sinri/keel/logger/event/KeelEventLogger.java b/src/main/java/io/github/sinri/keel/logger/event/KeelEventLogger.java index 59db117..1889848 100644 --- a/src/main/java/io/github/sinri/keel/logger/event/KeelEventLogger.java +++ b/src/main/java/io/github/sinri/keel/logger/event/KeelEventLogger.java @@ -26,6 +26,11 @@ static KeelEventLogger from(@Nonnull KeelIssueRecorder issueRecord @Nullable Handler templateEventLogEditor(); + /** + * @since 3.2.7 + */ + void setDynamicEventLogFormatter(@Nullable Handler formatter); + /** * @return Logs of this level or higher are visible. */ diff --git a/src/main/java/io/github/sinri/keel/logger/event/KeelEventLoggerImpl.java b/src/main/java/io/github/sinri/keel/logger/event/KeelEventLoggerImpl.java index 7fadbeb..427dd2c 100644 --- a/src/main/java/io/github/sinri/keel/logger/event/KeelEventLoggerImpl.java +++ b/src/main/java/io/github/sinri/keel/logger/event/KeelEventLoggerImpl.java @@ -16,6 +16,7 @@ class KeelEventLoggerImpl implements KeelEventLogger { private final @Nonnull KeelIssueRecorder issueRecorder; private final @Nullable Handler templateEventLogEditor; private final @Nonnull List bypassLoggers; + private @Nullable Handler dynamicFormatter; KeelEventLoggerImpl(@Nonnull KeelIssueRecorder issueRecorder, @Nullable Handler templateEventLogEditor) { this.issueRecorder = issueRecorder; @@ -29,6 +30,14 @@ public Handler templateEventLogEditor() { return templateEventLogEditor; } + /** + * @since 3.2.7 + */ + @Override + public void setDynamicEventLogFormatter(@Nullable Handler formatter) { + this.dynamicFormatter = formatter; + } + @Nonnull private KeelIssueRecorder getIssueRecorder() { return issueRecorder; @@ -64,22 +73,22 @@ public String getPresetTopic() { @Override public void log(@Nonnull Handler eventLogHandler) { - this.getIssueRecorder().record(r -> { + Handler h = r -> { var x = templateEventLogEditor(); if (x != null) { x.handle(r); } eventLogHandler.handle(r); - }); + // since 3.2.7 + if (dynamicFormatter != null) { + dynamicFormatter.handle(r); + } + }; + + this.getIssueRecorder().record(h); getBypassLoggers().forEach(bypassLogger -> { - bypassLogger.log(r -> { - var x = templateEventLogEditor(); - if (x != null) { - x.handle(r); - } - eventLogHandler.handle(r); - }); + bypassLogger.log(h); }); } } diff --git a/src/main/java/io/github/sinri/keel/tesuto/KeelTest.java b/src/main/java/io/github/sinri/keel/tesuto/KeelTest.java index f0d37ea..27ee77a 100644 --- a/src/main/java/io/github/sinri/keel/tesuto/KeelTest.java +++ b/src/main/java/io/github/sinri/keel/tesuto/KeelTest.java @@ -32,6 +32,9 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth String calledClass = System.getProperty("sun.java.command"); eventLogger = KeelIssueRecordCenter.outputCenter().generateEventLogger("KeelTest"); + eventLogger.setDynamicEventLogFormatter(eventLog -> { + eventLog.classification("preparing"); + }); eventLogger.debug(r -> r.message("Keel Test Class: " + calledClass)); @@ -77,6 +80,9 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth eventLogger.info(r -> r.message("RUNNING TEST UNITS...")); return KeelAsyncKit.iterativelyCall(testUnits, testUnit -> { + eventLogger.setDynamicEventLogFormatter(eventLogger -> { + eventLogger.classification(testUnit.getName()); + }); return testUnit.runTest((KeelTest) testInstance) .compose(testUnitResult -> { testUnitResults.add(testUnitResult); @@ -84,6 +90,9 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth }); }) .onComplete(vv -> { + eventLogger.setDynamicEventLogFormatter(eventLogger -> { + eventLogger.classification("conclusion"); + }); AtomicInteger totalNonSkippedRef = new AtomicInteger(0); testUnitResults.forEach(testUnitResult -> { if (testUnitResult.isSkipped()) { diff --git a/src/main/java/io/github/sinri/keel/tesuto/TestUnitWrapper.java b/src/main/java/io/github/sinri/keel/tesuto/TestUnitWrapper.java index e4beab2..811d139 100644 --- a/src/main/java/io/github/sinri/keel/tesuto/TestUnitWrapper.java +++ b/src/main/java/io/github/sinri/keel/tesuto/TestUnitWrapper.java @@ -32,6 +32,9 @@ public Future runTest(KeelTest testInstance) { } else { return Future.succeededFuture() .compose(vv -> { +// testInstance.getLogger().setDynamicEventLogFormatter(keelEventLog -> { +// keelEventLog.classification(this.getName()); +// }); try { return (Future) this.method.invoke(testInstance); } catch (Throwable e) { From e41e947580e785a04b7f3336dedc2783d9b6ba46 Mon Sep 17 00:00:00 2001 From: sinri Date: Tue, 7 May 2024 14:25:46 +0800 Subject: [PATCH 08/11] 3.2.7-SNAPSHOT --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33519bb..959f6be 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A Java framework with VERT.X eco, for projects for web, job and more. io.github.sinri Keel - 3.2.2 + 3.2.6 ``` From cbbbb091df3a4f1f570893194557192ec69f8bf8 Mon Sep 17 00:00:00 2001 From: Everstray Jun Sinri Edogawa Date: Wed, 15 May 2024 15:46:33 +0800 Subject: [PATCH 09/11] 3.2.7-SNAPSHOT Make `io.github.sinri.keel.logger.issue.center.KeelIssueRecordCenter.outputCenter` return a singleton. Signed-off-by: sinri --- .../logger/issue/center/KeelIssueRecordCenter.java | 5 ++++- .../issue/center/KeelIssueRecordCenterAsSync.java | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenter.java b/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenter.java index a040346..fb95755 100644 --- a/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenter.java +++ b/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenter.java @@ -18,8 +18,11 @@ */ @TechnicalPreview(since = "3.1.10") public interface KeelIssueRecordCenter { + /** + * @since 3.2.7 Use a static singleton impl. + */ static KeelIssueRecordCenter outputCenter() { - return new KeelIssueRecordCenterAsSync(SyncStdoutAdapter.getInstance()); + return KeelIssueRecordCenterAsSync.getInstanceWithStdout(); } static KeelIssueRecordCenter silentCenter() { diff --git a/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenterAsSync.java b/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenterAsSync.java index 409f644..7d80bfa 100644 --- a/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenterAsSync.java +++ b/src/main/java/io/github/sinri/keel/logger/issue/center/KeelIssueRecordCenterAsSync.java @@ -2,6 +2,7 @@ import io.github.sinri.keel.core.TechnicalPreview; import io.github.sinri.keel.logger.issue.recorder.adapter.KeelIssueRecorderAdapter; +import io.github.sinri.keel.logger.issue.recorder.adapter.SyncStdoutAdapter; import javax.annotation.Nonnull; @@ -21,4 +22,16 @@ public KeelIssueRecordCenterAsSync(@Nonnull KeelIssueRecorderAdapter adapter) { public KeelIssueRecorderAdapter getAdapter() { return adapter; } + + /** + * @since 3.2.7 + */ + private static final KeelIssueRecordCenterAsSync outputCenter = new KeelIssueRecordCenterAsSync(SyncStdoutAdapter.getInstance()); + + /** + * @since 3.2.7 + */ + public static KeelIssueRecordCenter getInstanceWithStdout() { + return outputCenter; + } } From eb5159c0ece201c186b155e71c78db62a89e793a Mon Sep 17 00:00:00 2001 From: sinri Date: Mon, 20 May 2024 17:49:43 +0800 Subject: [PATCH 10/11] 3.2.7-SNAPSHOT Fix Bug: Logging initialization is too early in KeelVerticle Impls. Signed-off-by: sinri --- .../sinri/keel/facade/async/KeelAsyncKit.java | 3 ++- .../sinri/keel/maids/gatling/KeelGatling.java | 2 +- .../keel/maids/watchman/KeelCronWatchman.java | 2 +- .../keel/maids/watchman/KeelWatchmanImpl.java | 2 +- .../sinri/keel/servant/funnel/KeelFunnel.java | 3 ++- .../intravenous/KeelIntravenousBase.java | 2 +- .../sinri/keel/servant/queue/KeelQueue.java | 3 ++- .../keel/servant/queue/KeelQueueTask.java | 4 ++-- .../keel/servant/sundial/KeelSundial.java | 3 +-- .../servant/sundial/KeelSundialVerticle.java | 2 +- .../keel/verticles/KeelVerticleImplPure.java | 17 +++++++++++++ .../KeelVerticleImplWithEventLogger.java | 24 +++++++++++++++++-- .../KeelVerticleImplWithIssueRecorder.java | 24 +++++++++++++++++-- .../sinri/keel/web/http/KeelHttpServer.java | 2 +- .../lab/blocking/BlockingVerticlePlanA.java | 4 +++- .../lab/blocking/BlockingVerticlePlanB.java | 3 +-- .../test/lab/launcher/TestMainVerticle.java | 2 +- 17 files changed, 81 insertions(+), 21 deletions(-) diff --git a/src/main/java/io/github/sinri/keel/facade/async/KeelAsyncKit.java b/src/main/java/io/github/sinri/keel/facade/async/KeelAsyncKit.java index e060f04..8761da5 100644 --- a/src/main/java/io/github/sinri/keel/facade/async/KeelAsyncKit.java +++ b/src/main/java/io/github/sinri/keel/facade/async/KeelAsyncKit.java @@ -216,8 +216,9 @@ static Future vertxizedRawFuture(@Nonnull java.util.concurrent.Future static Future executeBlocking(@Nonnull Handler> blockingCodeHandler) { Promise promise = Promise.promise(); KeelVerticle verticle = new KeelVerticleImplPure() { + @Override - public void start() { + protected void startAsPureKeelVerticle() { blockingCodeHandler.handle(promise); promise.future().onComplete(ar -> this.undeployMe()); } diff --git a/src/main/java/io/github/sinri/keel/maids/gatling/KeelGatling.java b/src/main/java/io/github/sinri/keel/maids/gatling/KeelGatling.java index aa59bea..42cc09b 100644 --- a/src/main/java/io/github/sinri/keel/maids/gatling/KeelGatling.java +++ b/src/main/java/io/github/sinri/keel/maids/gatling/KeelGatling.java @@ -42,7 +42,7 @@ protected Future rest() { } @Override - public void start() throws Exception { + protected void startAsKeelVerticle() { barrelUsed.set(0); KeelAsyncKit.repeatedlyCall(routineResult -> { return fireOnce(); diff --git a/src/main/java/io/github/sinri/keel/maids/watchman/KeelCronWatchman.java b/src/main/java/io/github/sinri/keel/maids/watchman/KeelCronWatchman.java index 4efd3eb..d3e07ed 100644 --- a/src/main/java/io/github/sinri/keel/maids/watchman/KeelCronWatchman.java +++ b/src/main/java/io/github/sinri/keel/maids/watchman/KeelCronWatchman.java @@ -207,7 +207,7 @@ public final KeelWatchmanEventHandler regularHandler() { } @Override - public void start() { + protected void startAsKeelVerticle() { Future.succeededFuture() .compose(v -> cronTabUpdateStartup.apply(eventBusAddress())) .onSuccess(v -> super.start()) diff --git a/src/main/java/io/github/sinri/keel/maids/watchman/KeelWatchmanImpl.java b/src/main/java/io/github/sinri/keel/maids/watchman/KeelWatchmanImpl.java index 6c30c97..09870e0 100644 --- a/src/main/java/io/github/sinri/keel/maids/watchman/KeelWatchmanImpl.java +++ b/src/main/java/io/github/sinri/keel/maids/watchman/KeelWatchmanImpl.java @@ -29,7 +29,7 @@ protected String eventBusAddress() { } @Override - public void start() { + protected void startAsKeelVerticle() { this.consumer = Keel.getVertx().eventBus().consumer(eventBusAddress()); this.consumer.handler(this::consumeHandleMassage); this.consumer.exceptionHandler(throwable -> getLogger() diff --git a/src/main/java/io/github/sinri/keel/servant/funnel/KeelFunnel.java b/src/main/java/io/github/sinri/keel/servant/funnel/KeelFunnel.java index ae25f71..6ffa99f 100644 --- a/src/main/java/io/github/sinri/keel/servant/funnel/KeelFunnel.java +++ b/src/main/java/io/github/sinri/keel/servant/funnel/KeelFunnel.java @@ -58,7 +58,7 @@ private Promise getCurrentInterrupt() { } @Override - public void start() throws Exception { + protected void startAsKeelVerticle() { KeelAsyncKit.endless(promise -> { this.interruptRef.set(null); //System.out.println("ENDLESS "+System.currentTimeMillis()); @@ -95,6 +95,7 @@ public void start() throws Exception { }); } + // @Deprecated // public static void main(String[] args) { // Keel.initializeVertxStandalone(new VertxOptions()); diff --git a/src/main/java/io/github/sinri/keel/servant/intravenous/KeelIntravenousBase.java b/src/main/java/io/github/sinri/keel/servant/intravenous/KeelIntravenousBase.java index f593427..00adff4 100644 --- a/src/main/java/io/github/sinri/keel/servant/intravenous/KeelIntravenousBase.java +++ b/src/main/java/io/github/sinri/keel/servant/intravenous/KeelIntravenousBase.java @@ -48,7 +48,7 @@ private Promise getCurrentInterrupt() { } @Override - public void start() { + protected void startAsKeelVerticle() { queueAcceptTask = true; int configuredBatchSize = getBatchSize(); diff --git a/src/main/java/io/github/sinri/keel/servant/queue/KeelQueue.java b/src/main/java/io/github/sinri/keel/servant/queue/KeelQueue.java index acc8b83..caf77be 100644 --- a/src/main/java/io/github/sinri/keel/servant/queue/KeelQueue.java +++ b/src/main/java/io/github/sinri/keel/servant/queue/KeelQueue.java @@ -54,7 +54,8 @@ protected KeelQueue setQueueStatus(QueueStatus queueStatus) { */ abstract protected @Nonnull SignalReader getSignalReader(); - public void start() { + @Override + protected void startAsKeelVerticle() { this.queueStatus = QueueStatus.RUNNING; try { diff --git a/src/main/java/io/github/sinri/keel/servant/queue/KeelQueueTask.java b/src/main/java/io/github/sinri/keel/servant/queue/KeelQueueTask.java index 3acf781..4ff6e22 100644 --- a/src/main/java/io/github/sinri/keel/servant/queue/KeelQueueTask.java +++ b/src/main/java/io/github/sinri/keel/servant/queue/KeelQueueTask.java @@ -21,8 +21,8 @@ final void setQueueWorkerPoolManager(QueueWorkerPoolManager queueWorkerPoolManag @Nonnull abstract public String getTaskCategory(); - // as verticle - public final void start() { + @Override + protected final void startAsKeelVerticle() { this.queueWorkerPoolManager.whenOneWorkerStarts(); Future.succeededFuture() diff --git a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java index d0c3cfc..281429a 100644 --- a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java +++ b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundial.java @@ -32,8 +32,7 @@ protected KeelEventLogger buildEventLogger() { } @Override - - public void start() throws Exception { + protected void startAsKeelVerticle() { int delaySeconds = 61 - KeelCronExpression.parseCalenderToElements(Calendar.getInstance()).second; this.timerID = Keel.getVertx().setPeriodic(delaySeconds * 1000L, 60_000L, timerID -> { handleEveryMinute(Calendar.getInstance()); diff --git a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java index d0d60e8..2fc5338 100644 --- a/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java +++ b/src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java @@ -20,7 +20,7 @@ public KeelSundialVerticle(@Nonnull KeelSundialPlan sundialPlan, Calendar now) { } @Override - public void start() throws Exception { + protected void startAsPureKeelVerticle() { Future.succeededFuture() .compose(v -> { return sundialPlan.execute(now); diff --git a/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplPure.java b/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplPure.java index 45afddc..1456532 100644 --- a/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplPure.java +++ b/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplPure.java @@ -1,9 +1,26 @@ package io.github.sinri.keel.verticles; import io.vertx.core.AbstractVerticle; +import io.vertx.core.Promise; /** * @since 3.2.0 */ public abstract class KeelVerticleImplPure extends AbstractVerticle implements KeelVerticle { + @Override + public final void start(Promise startPromise) { + this.startAsPureKeelVerticle(startPromise); + } + + @Override + public final void start() { + this.startAsPureKeelVerticle(); + } + + protected void startAsPureKeelVerticle(Promise startPromise) { + startAsPureKeelVerticle(); + startPromise.complete(); + } + + abstract protected void startAsPureKeelVerticle(); } diff --git a/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithEventLogger.java b/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithEventLogger.java index 9977925..90a125a 100644 --- a/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithEventLogger.java +++ b/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithEventLogger.java @@ -1,14 +1,16 @@ package io.github.sinri.keel.verticles; import io.github.sinri.keel.logger.event.KeelEventLogger; +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Promise; import javax.annotation.Nonnull; /** * @since 3.2.0 */ -abstract public class KeelVerticleImplWithEventLogger extends KeelVerticleImplPure { - private final @Nonnull KeelEventLogger logger; +abstract public class KeelVerticleImplWithEventLogger extends AbstractVerticle implements KeelVerticle { + private @Nonnull KeelEventLogger logger; public KeelVerticleImplWithEventLogger() { super(); @@ -22,4 +24,22 @@ public KeelEventLogger getLogger() { abstract protected KeelEventLogger buildEventLogger(); + @Override + public final void start(Promise startPromise) { + this.logger = buildEventLogger(); + start(); + startPromise.complete(); + } + + @Override + public final void start() { + this.startAsKeelVerticle(); + } + + protected void startAsKeelVerticle(Promise startPromise) { + startAsKeelVerticle(); + startPromise.complete(); + } + + abstract protected void startAsKeelVerticle(); } diff --git a/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithIssueRecorder.java b/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithIssueRecorder.java index 2412386..e8bfa4c 100644 --- a/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithIssueRecorder.java +++ b/src/main/java/io/github/sinri/keel/verticles/KeelVerticleImplWithIssueRecorder.java @@ -2,11 +2,13 @@ import io.github.sinri.keel.logger.issue.record.KeelIssueRecord; import io.github.sinri.keel.logger.issue.recorder.KeelIssueRecorder; +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Promise; import javax.annotation.Nonnull; -abstract public class KeelVerticleImplWithIssueRecorder> extends KeelVerticleImplPure { - private final @Nonnull KeelIssueRecorder issueRecorder; +abstract public class KeelVerticleImplWithIssueRecorder> extends AbstractVerticle implements KeelVerticle { + private @Nonnull KeelIssueRecorder issueRecorder; public KeelVerticleImplWithIssueRecorder() { this.issueRecorder = buildIssueRecorder(); @@ -18,4 +20,22 @@ public KeelIssueRecorder getIssueRecorder() { } abstract protected @Nonnull KeelIssueRecorder buildIssueRecorder(); + + @Override + public final void start(Promise startPromise) { + this.issueRecorder = buildIssueRecorder(); + this.start(); + } + + @Override + public final void start() { + this.startAsKeelVerticle(); + } + + protected void startAsKeelVerticle(Promise startPromise) { + startAsKeelVerticle(); + startPromise.complete(); + } + + abstract protected void startAsKeelVerticle(); } diff --git a/src/main/java/io/github/sinri/keel/web/http/KeelHttpServer.java b/src/main/java/io/github/sinri/keel/web/http/KeelHttpServer.java index 0678586..205174e 100644 --- a/src/main/java/io/github/sinri/keel/web/http/KeelHttpServer.java +++ b/src/main/java/io/github/sinri/keel/web/http/KeelHttpServer.java @@ -38,7 +38,7 @@ protected boolean isMainService() { protected abstract void configureRoutes(Router router); @Override - public void start() throws Exception { + protected void startAsKeelVerticle() { this.server = Keel.getVertx().createHttpServer(getHttpServerOptions()); Router router = Router.router(Keel.getVertx()); diff --git a/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanA.java b/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanA.java index 3210f21..4875696 100644 --- a/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanA.java +++ b/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanA.java @@ -91,9 +91,11 @@ private static Future blockPiece(BlockingVerticlePlanA futureForBlocking, } @Override - public void start() throws Exception { + protected void startAsKeelVerticle() { + } + public Future executeBlocking(Handler> promiseHandler) { Promise promise = Promise.promise(); this.context.runOnContext(new Handler() { diff --git a/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanB.java b/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanB.java index 7d67a39..b943a31 100644 --- a/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanB.java +++ b/src/test/java/io/github/sinri/keel/test/lab/blocking/BlockingVerticlePlanB.java @@ -26,8 +26,7 @@ public KeelIssueRecorder buildIssueRecorder() { } @Override - public void start() throws Exception { - + protected void startAsKeelVerticle() { getIssueRecorder().info(r -> r.message("in verticle " + deploymentID())); blockCode.handle(promise); diff --git a/src/test/java/io/github/sinri/keel/test/lab/launcher/TestMainVerticle.java b/src/test/java/io/github/sinri/keel/test/lab/launcher/TestMainVerticle.java index 84a390b..b92b3f3 100644 --- a/src/test/java/io/github/sinri/keel/test/lab/launcher/TestMainVerticle.java +++ b/src/test/java/io/github/sinri/keel/test/lab/launcher/TestMainVerticle.java @@ -10,7 +10,7 @@ public class TestMainVerticle extends KeelVerticleImplWithEventLogger { @Override - public void start() throws Exception { + protected void startAsKeelVerticle() { KeelAsyncKit.endless(() -> { getLogger().info(r -> r.message("X")); return Future.succeededFuture(); From 16fe38d65fcb0e89c3921be4d4179c71ae7eff2f Mon Sep 17 00:00:00 2001 From: sinri Date: Mon, 20 May 2024 20:54:11 +0800 Subject: [PATCH 11/11] 3.2.7 Signed-off-by: sinri --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e78cd69..ddf5b5a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ io.github.sinri Keel - 3.2.7-SNAPSHOT - + + 3.2.7 Keel @@ -309,7 +309,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.7 + 1.6.13 true ossrh