Browse Source

[Fix-6792] resolve API and alert port conflicts (#6792) (#6815)

* [Fix-6792]Multiple ApplicationRunners on classpath make SpringApplication.run only run one (#6792)
3.0.0/version-upgrade
mask 3 years ago committed by GitHub
parent
commit
e36d18b588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
  2. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java
  3. 6
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerServer.java
  4. 11
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
  5. 11
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java
  6. 6
      dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java

4
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java

@ -38,10 +38,10 @@ import javax.annotation.PreDestroy;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication @EnableAutoConfiguration
@ComponentScan(value = { @ComponentScan(value = {
"org.apache.dolphinscheduler.alert", "org.apache.dolphinscheduler.alert",
"org.apache.dolphinscheduler.dao" "org.apache.dolphinscheduler.dao"

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java

@ -17,21 +17,25 @@
package org.apache.dolphinscheduler.api; package org.apache.dolphinscheduler.api;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
@SpringBootApplication @EnableAutoConfiguration
@ServletComponentScan @ServletComponentScan
@ComponentScan(value = "org.apache.dolphinscheduler", @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.apache.dolphinscheduler.server.*")) @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
"org.apache.dolphinscheduler.server.*",
"org.apache.dolphinscheduler.alert.*"
})
})
public class ApiApplicationServer extends SpringBootServletInitializer { public class ApiApplicationServer extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ApiApplicationServer.class, args); new SpringApplicationBuilder(ApiApplicationServer.class).profiles("api").run(args);
} }
} }

6
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerServer.java

@ -17,11 +17,11 @@
package org.apache.dolphinscheduler.server.log; package org.apache.dolphinscheduler.server.log;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.remote.NettyRemotingServer; import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig; import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -47,7 +47,7 @@ public class LoggerServer {
*/ */
private final LoggerRequestProcessor requestProcessor; private final LoggerRequestProcessor requestProcessor;
public LoggerServer(){ public LoggerServer() {
this.serverConfig = new NettyServerConfig(); this.serverConfig = new NettyServerConfig();
this.serverConfig.setListenPort(Constants.RPC_PORT); this.serverConfig.setListenPort(Constants.RPC_PORT);
this.server = new NettyRemotingServer(serverConfig); this.server = new NettyRemotingServer(serverConfig);
@ -72,7 +72,7 @@ public class LoggerServer {
*/ */
public void start() { public void start() {
this.server.start(); this.server.start();
logger.info("logger server started, listening on port : {}" , Constants.RPC_PORT); logger.info("logger server started, listening on port : {}", Constants.RPC_PORT);
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
@Override @Override
public void run() { public void run() {

11
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java

@ -50,11 +50,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* master server * master server
*/ */
@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX, pattern = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
"org.apache.dolphinscheduler.server.worker.*", "org.apache.dolphinscheduler.server.worker.*",
"org.apache.dolphinscheduler.server.monitor.*", "org.apache.dolphinscheduler.server.monitor.*",
"org.apache.dolphinscheduler.server.log.*" "org.apache.dolphinscheduler.server.log.*",
}) "org.apache.dolphinscheduler.alert.*"
})
}) })
@EnableTransactionManagement @EnableTransactionManagement
public class MasterServer implements IStoppable { public class MasterServer implements IStoppable {

11
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java

@ -54,11 +54,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* worker server * worker server
*/ */
@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX, pattern = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
"org.apache.dolphinscheduler.server.master.*", "org.apache.dolphinscheduler.server.master.*",
"org.apache.dolphinscheduler.server.monitor.*", "org.apache.dolphinscheduler.server.monitor.*",
"org.apache.dolphinscheduler.server.log.*" "org.apache.dolphinscheduler.server.log.*",
}) "org.apache.dolphinscheduler.alert.*"
})
}) })
@EnableTransactionManagement @EnableTransactionManagement
public class WorkerServer implements IStoppable { public class WorkerServer implements IStoppable {

6
dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java

@ -24,10 +24,12 @@ import org.apache.dolphinscheduler.server.worker.WorkerServer;
import org.apache.curator.test.TestingServer; import org.apache.curator.test.TestingServer;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication @EnableAutoConfiguration
@ComponentScan
public class StandaloneServer { public class StandaloneServer {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
final TestingServer server = new TestingServer(true); final TestingServer server = new TestingServer(true);

Loading…
Cancel
Save