Browse Source

Fix start standalone fail because db not init yet (#8191)

3.0.0/version-upgrade
wind 3 years ago committed by GitHub
parent
commit
128ede3ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
  2. 6
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
  3. 2
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertPluginManagerTest.java
  4. 2
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java

6
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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
@ -53,8 +55,8 @@ public final class AlertPluginManager {
this.pluginDao = pluginDao; this.pluginDao = pluginDao;
} }
@PostConstruct @EventListener
public void installPlugin() { public void installPlugin(ApplicationReadyEvent readyEvent) {
final Set<String> names = new HashSet<>(); final Set<String> names = new HashSet<>();
ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> { ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> {

6
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.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.event.EventListener;
@SpringBootApplication @SpringBootApplication
@ComponentScan("org.apache.dolphinscheduler") @ComponentScan("org.apache.dolphinscheduler")
@ -68,8 +70,8 @@ public class AlertServer implements Closeable {
SpringApplication.run(AlertServer.class, args); SpringApplication.run(AlertServer.class, args);
} }
@PostConstruct @EventListener
public void start() { public void start(ApplicationReadyEvent readyEvent) {
logger.info("Starting Alert server"); logger.info("Starting Alert server");
checkTable(); checkTable();

2
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() { public void testAlertPluginManager() {
Mockito.when(pluginDao.addOrUpdatePluginDefine(Mockito.any(PluginDefine.class))).thenReturn(0); Mockito.when(pluginDao.addOrUpdatePluginDefine(Mockito.any(PluginDefine.class))).thenReturn(0);
alertPluginManager.installPlugin(); alertPluginManager.installPlugin(null);
Assert.assertEquals(1, alertPluginManager.size()); Assert.assertEquals(1, alertPluginManager.size());

2
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); Mockito.when(alertConfig.getPort()).thenReturn(50053);
alertServer.start(); alertServer.start(null);
NettyRemotingServer nettyRemotingServer = Whitebox.getInternalState(alertServer, "server"); NettyRemotingServer nettyRemotingServer = Whitebox.getInternalState(alertServer, "server");

Loading…
Cancel
Save