From c8b0c1f105c1e3bee378a70b343e114c0143db80 Mon Sep 17 00:00:00 2001 From: Baoqi Wu Date: Sun, 17 Nov 2019 14:44:17 +0800 Subject: [PATCH] make combined server works in new dev-db branch (#1257) --- .../api/CombinedApplicationServer.java | 6 ++--- .../resources/application-combined.properties | 23 +++++++++++++++++++ .../server/worker/WorkerServer.java | 15 +++++++++--- script/dolphinscheduler-daemon.sh | 3 +++ 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 dolphinscheduler-api/src/main/resources/application-combined.properties diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/CombinedApplicationServer.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/CombinedApplicationServer.java index 1c84829755..6baadb3ea5 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/CombinedApplicationServer.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/CombinedApplicationServer.java @@ -24,11 +24,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication @ServletComponentScan @ComponentScan("org.apache.dolphinscheduler") +@Import({MasterServer.class, WorkerServer.class}) @EnableSwagger2 public class CombinedApplicationServer extends SpringBootServletInitializer { @@ -36,10 +38,6 @@ public class CombinedApplicationServer extends SpringBootServletInitializer { ApiApplicationServer.main(args); - MasterServer.main(args); - - WorkerServer.main(args); - LoggerServer server = new LoggerServer(); server.start(); diff --git a/dolphinscheduler-api/src/main/resources/application-combined.properties b/dolphinscheduler-api/src/main/resources/application-combined.properties new file mode 100644 index 0000000000..ddd833ee51 --- /dev/null +++ b/dolphinscheduler-api/src/main/resources/application-combined.properties @@ -0,0 +1,23 @@ +logging.config=classpath:combined_logback.xml + +# server port +server.port=12345 + +# session config +server.servlet.session.timeout=7200 + +server.servlet.context-path=/dolphinscheduler/ + +# file size limit for upload +spring.servlet.multipart.max-file-size=1024MB +spring.servlet.multipart.max-request-size=1024MB + +#post content +server.jetty.max-http-post-size=5000000 + +spring.messages.encoding=UTF-8 + +#i18n classpath folder , file prefix messages, if have many files, use "," seperator +spring.messages.basename=i18n/messages + +server.is-combined-server=true diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java index 4d52e5f259..14b5a2ca0c 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java @@ -42,6 +42,7 @@ import org.apache.dolphinscheduler.server.zk.ZKWorkerClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.context.annotation.ComponentScan; @@ -114,6 +115,12 @@ public class WorkerServer extends AbstractServer { */ private CountDownLatch latch; + /** + * If inside combined server, WorkerServer no need to await on CountDownLatch + */ + @Value("${server.is-combined-server:false}") + private Boolean isCombinedServer; + /** * master server startup * @@ -196,9 +203,11 @@ public class WorkerServer extends AbstractServer { //let the main thread await latch = new CountDownLatch(1); - try { - latch.await(); - } catch (InterruptedException ignore) { + if (!isCombinedServer) { + try { + latch.await(); + } catch (InterruptedException ignore) { + } } } diff --git a/script/dolphinscheduler-daemon.sh b/script/dolphinscheduler-daemon.sh index f6dbf0ac21..7f84a39ddc 100644 --- a/script/dolphinscheduler-daemon.sh +++ b/script/dolphinscheduler-daemon.sh @@ -54,6 +54,9 @@ elif [ "$command" = "alert-server" ]; then CLASS=org.apache.dolphinscheduler.alert.AlertServer elif [ "$command" = "logger-server" ]; then CLASS=org.apache.dolphinscheduler.server.rpc.LoggerServer +elif [ "$command" = "combined-server" ]; then + LOG_FILE="-Dspring.profiles.active=combined" + CLASS=org.apache.dolphinscheduler.api.CombinedApplicationServer else echo "Error: No command named \`$command' was found." exit 1