This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 128ede3  Fix start standalone fail because db not init yet (#8191)
128ede3 is described below

commit 128ede3ee9ddea5770517ce627f259e6a492fcbc
Author: wind <[email protected]>
AuthorDate: Tue Jan 25 18:10:02 2022 +0800

    Fix start standalone fail because db not init yet (#8191)
---
 .../java/org/apache/dolphinscheduler/alert/AlertPluginManager.java  | 6 ++++--
 .../main/java/org/apache/dolphinscheduler/alert/AlertServer.java    | 6 ++++--
 .../org/apache/dolphinscheduler/alert/AlertPluginManagerTest.java   | 2 +-
 .../java/org/apache/dolphinscheduler/alert/AlertServerTest.java     | 2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
index 6107cf6..682a496 100644
--- 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
+++ 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
@@ -39,6 +39,8 @@ import javax.annotation.PostConstruct;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
 import org.springframework.stereotype.Component;
 
 @Component
@@ -53,8 +55,8 @@ public final class AlertPluginManager {
         this.pluginDao = pluginDao;
     }
 
-    @PostConstruct
-    public void installPlugin() {
+    @EventListener
+    public void installPlugin(ApplicationReadyEvent readyEvent) {
         final Set<String> names = new HashSet<>();
 
         ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> {
diff --git 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
index 6304a4c..f8324ac 100644
--- 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
+++ 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
@@ -38,7 +38,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.event.EventListener;
 
 @SpringBootApplication
 @ComponentScan("org.apache.dolphinscheduler")
@@ -68,8 +70,8 @@ public class AlertServer implements Closeable {
         SpringApplication.run(AlertServer.class, args);
     }
 
-    @PostConstruct
-    public void start() {
+    @EventListener
+    public void start(ApplicationReadyEvent readyEvent) {
         logger.info("Starting Alert server");
 
         checkTable();
diff --git 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertPluginManagerTest.java
 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertPluginManagerTest.java
index f7e7e56..912c959 100644
--- 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertPluginManagerTest.java
+++ 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertPluginManagerTest.java
@@ -41,7 +41,7 @@ public class AlertPluginManagerTest extends TestCase {
     public void testAlertPluginManager() {
         
Mockito.when(pluginDao.addOrUpdatePluginDefine(Mockito.any(PluginDefine.class))).thenReturn(0);
         
-        alertPluginManager.installPlugin();
+        alertPluginManager.installPlugin(null);
         
         Assert.assertEquals(1, alertPluginManager.size());
         
diff --git 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
index bd5396a..911b912 100644
--- 
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
+++ 
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
@@ -49,7 +49,7 @@ public class AlertServerTest extends TestCase {
         
         Mockito.when(alertConfig.getPort()).thenReturn(50053);
         
-        alertServer.start();
+        alertServer.start(null);
     
         NettyRemotingServer nettyRemotingServer = 
Whitebox.getInternalState(alertServer, "server");
     

Reply via email to