From 263791a63e4b85f96563eda51704816d2c38e600 Mon Sep 17 00:00:00 2001 From: caishunfeng Date: Mon, 28 Mar 2022 09:38:51 +0800 Subject: [PATCH] [Bug-9137][Server] fix timezone init (#9219) Co-authored-by: caishunfeng <534328519@qq.com> --- .../src/main/bin/start.sh | 2 +- .../dolphinscheduler/alert/AlertServer.java | 13 +- dolphinscheduler-api/src/main/bin/start.sh | 2 +- .../api/ApiApplicationServer.java | 12 -- .../common/utils/JSONUtils.java | 4 + dolphinscheduler-master/src/main/bin/start.sh | 2 +- .../server/master/MasterServer.java | 8 -- dolphinscheduler-python/src/main/bin/start.sh | 2 +- .../server/PythonGatewayServer.java | 123 ++++++++---------- .../dolphinscheduler/spi/utils/JSONUtils.java | 4 + .../src/main/bin/start.sh | 2 +- .../src/main/dist-bin/start.sh | 2 +- .../dolphinscheduler/StandaloneServer.java | 13 -- dolphinscheduler-worker/src/main/bin/start.sh | 2 +- .../server/worker/WorkerServer.java | 7 - 15 files changed, 73 insertions(+), 125 deletions(-) diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/bin/start.sh b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/bin/start.sh index eda02bb6c9..14ed6d169e 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/bin/start.sh +++ b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/bin/start.sh @@ -21,7 +21,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} source "$BIN_DIR/dolphinscheduler_env.sh" -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" 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 f776be5e17..6b18befe39 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 @@ -27,17 +27,14 @@ import org.apache.dolphinscheduler.remote.config.NettyServerConfig; import java.io.Closeable; import java.util.List; -import java.util.TimeZone; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; 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.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -60,9 +57,6 @@ public class AlertServer implements Closeable { @Autowired private AlertConfig config; - @Value("${spring.jackson.time-zone:UTC}") - private String timezone; - public AlertServer(PluginDao pluginDao, AlertDao alertDao, AlertPluginManager alertPluginManager, AlertSender alertSender, AlertRequestProcessor alertRequestProcessor) { this.pluginDao = pluginDao; this.alertDao = alertDao; @@ -75,11 +69,6 @@ public class AlertServer implements Closeable { SpringApplication.run(AlertServer.class, args); } - @PostConstruct - public void init() { - TimeZone.setDefault(TimeZone.getTimeZone(timezone)); - } - @EventListener public void start(ApplicationReadyEvent readyEvent) { logger.info("Starting Alert server"); @@ -88,7 +77,7 @@ public class AlertServer implements Closeable { startServer(); Executors.newScheduledThreadPool(1) - .scheduleAtFixedRate(new Sender(), 5, 5, TimeUnit.SECONDS); + .scheduleAtFixedRate(new Sender(), 5, 5, TimeUnit.SECONDS); } @Override diff --git a/dolphinscheduler-api/src/main/bin/start.sh b/dolphinscheduler-api/src/main/bin/start.sh index 66655069c1..15dc38c537 100644 --- a/dolphinscheduler-api/src/main/bin/start.sh +++ b/dolphinscheduler-api/src/main/bin/start.sh @@ -21,7 +21,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} source "$BIN_DIR/dolphinscheduler_env.sh" -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java index 59e9c7e632..7981f8a48d 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java @@ -17,11 +17,6 @@ package org.apache.dolphinscheduler.api; -import java.util.TimeZone; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; @@ -32,15 +27,8 @@ import org.springframework.context.annotation.ComponentScan; @ComponentScan("org.apache.dolphinscheduler") public class ApiApplicationServer { - @Value("${spring.jackson.time-zone:UTC}") - private String timezone; - public static void main(String[] args) { SpringApplication.run(ApiApplicationServer.class); } - @PostConstruct - public void run() { - TimeZone.setDefault(TimeZone.getTimeZone(timezone)); - } } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java index 92875e8991..dbd7d833b5 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java @@ -63,6 +63,10 @@ public class JSONUtils { private static final Logger logger = LoggerFactory.getLogger(JSONUtils.class); + static { + logger.info("init timezone: {}",TimeZone.getDefault()); + } + /** * can use static singleton, inject: just make sure to reuse! */ diff --git a/dolphinscheduler-master/src/main/bin/start.sh b/dolphinscheduler-master/src/main/bin/start.sh index b9d0c8d044..f4ee3c58f9 100644 --- a/dolphinscheduler-master/src/main/bin/start.sh +++ b/dolphinscheduler-master/src/main/bin/start.sh @@ -21,7 +21,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} source "$BIN_DIR/dolphinscheduler_env.sh" -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms4g -Xmx4g -Xmn2g -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms4g -Xmx4g -Xmn2g -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java index 92eb973f21..22b4a69be6 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java @@ -37,8 +37,6 @@ import org.apache.dolphinscheduler.server.master.runner.FailoverExecuteThread; import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerService; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; -import java.util.TimeZone; - import javax.annotation.PostConstruct; import org.quartz.Scheduler; @@ -46,7 +44,6 @@ import org.quartz.SchedulerException; 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.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; @@ -104,9 +101,6 @@ public class MasterServer implements IStoppable { @Autowired private LoggerRequestProcessor loggerRequestProcessor; - @Value("${spring.jackson.time-zone:UTC}") - private String timezone; - public static void main(String[] args) { Thread.currentThread().setName(Constants.THREAD_NAME_MASTER_SERVER); SpringApplication.run(MasterServer.class); @@ -117,8 +111,6 @@ public class MasterServer implements IStoppable { */ @PostConstruct public void run() throws SchedulerException { - TimeZone.setDefault(TimeZone.getTimeZone(timezone)); - // init remoting server NettyServerConfig serverConfig = new NettyServerConfig(); serverConfig.setListenPort(masterConfig.getListenPort()); diff --git a/dolphinscheduler-python/src/main/bin/start.sh b/dolphinscheduler-python/src/main/bin/start.sh index f189684330..d588a2b2d9 100644 --- a/dolphinscheduler-python/src/main/bin/start.sh +++ b/dolphinscheduler-python/src/main/bin/start.sh @@ -21,7 +21,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} source "$BIN_DIR/dolphinscheduler_env.sh" -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" diff --git a/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java b/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java index 218cf614b3..2f7fc94da7 100644 --- a/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java +++ b/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java @@ -59,6 +59,8 @@ import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.server.config.PythonGatewayConfig; import org.apache.dolphinscheduler.spi.enums.ResourceType; +import org.apache.commons.collections.CollectionUtils; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Date; @@ -66,7 +68,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.TimeZone; import java.util.stream.Collectors; import javax.annotation.PostConstruct; @@ -74,7 +75,6 @@ import javax.annotation.PostConstruct; 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.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @@ -82,8 +82,6 @@ import org.springframework.context.annotation.ComponentScan; import py4j.GatewayServer; -import org.apache.commons.collections.CollectionUtils; - @SpringBootApplication @ComponentScan(value = "org.apache.dolphinscheduler") public class PythonGatewayServer extends SpringBootServletInitializer { @@ -148,14 +146,6 @@ public class PythonGatewayServer extends SpringBootServletInitializer { @Autowired private ProjectUserMapper projectUserMapper; - @Value("${spring.jackson.time-zone:UTC}") - private String timezone; - - @PostConstruct - public void init() { - TimeZone.setDefault(TimeZone.getTimeZone(timezone)); - } - // TODO replace this user to build in admin user if we make sure build in one could not be change private final User dummyAdminUser = new User() { { @@ -207,19 +197,19 @@ public class PythonGatewayServer extends SpringBootServletInitializer { * If process definition do not exists in Project=`projectCode` would create a new one * If process definition already exists in Project=`projectCode` would update it * - * @param userName user name who create or update process definition - * @param projectName project name which process definition belongs to - * @param name process definition name - * @param description description - * @param globalParams global params - * @param schedule schedule for process definition, will not set schedule if null, - * and if would always fresh exists schedule if not null - * @param locations locations json object about all tasks - * @param timeout timeout for process definition working, if running time longer than timeout, - * task will mark as fail - * @param workerGroup run task in which worker group - * @param tenantCode tenantCode - * @param taskRelationJson relation json for nodes + * @param userName user name who create or update process definition + * @param projectName project name which process definition belongs to + * @param name process definition name + * @param description description + * @param globalParams global params + * @param schedule schedule for process definition, will not set schedule if null, + * and if would always fresh exists schedule if not null + * @param locations locations json object about all tasks + * @param timeout timeout for process definition working, if running time longer than timeout, + * task will mark as fail + * @param workerGroup run task in which worker group + * @param tenantCode tenantCode + * @param taskRelationJson relation json for nodes * @param taskDefinitionJson taskDefinitionJson * @return create result code */ @@ -248,10 +238,10 @@ public class PythonGatewayServer extends SpringBootServletInitializer { // make sure process definition offline which could edit processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); Map result = processDefinitionService.updateProcessDefinition(user, projectCode, name, processDefinitionCode, description, globalParams, - locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson, executionType); + locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson, executionType); } else { Map result = processDefinitionService.createProcessDefinition(user, projectCode, name, description, globalParams, - locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson, executionType); + locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson, executionType); processDefinition = (ProcessDefinition) result.get(Constants.DATA_LIST); processDefinitionCode = processDefinition.getCode(); } @@ -266,8 +256,9 @@ public class PythonGatewayServer extends SpringBootServletInitializer { /** * get process definition - * @param user user who create or update schedule - * @param projectCode project which process definition belongs to + * + * @param user user who create or update schedule + * @param projectCode project which process definition belongs to * @param processDefinitionName process definition name */ private ProcessDefinition getProcessDefinition(User user, long projectCode, String processDefinitionName) { @@ -291,11 +282,11 @@ public class PythonGatewayServer extends SpringBootServletInitializer { * It would always use latest schedule define in workflow-as-code, and set schedule online when * it's not null * - * @param user user who create or update schedule - * @param projectCode project which process definition belongs to + * @param user user who create or update schedule + * @param projectCode project which process definition belongs to * @param processDefinitionCode process definition code - * @param schedule schedule expression - * @param workerGroup work group + * @param schedule schedule expression + * @param workerGroup work group */ private void createOrUpdateSchedule(User user, long projectCode, @@ -308,13 +299,13 @@ public class PythonGatewayServer extends SpringBootServletInitializer { if (scheduleObj == null) { processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.ONLINE); Map result = schedulerService.insertSchedule(user, projectCode, processDefinitionCode, schedule, DEFAULT_WARNING_TYPE, - DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); + DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); scheduleId = (int) result.get("scheduleId"); } else { scheduleId = scheduleObj.getId(); processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); schedulerService.updateSchedule(user, projectCode, scheduleId, schedule, DEFAULT_WARNING_TYPE, - DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); + DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); } schedulerService.setScheduleState(user, projectCode, scheduleId, ReleaseState.ONLINE); } @@ -334,24 +325,24 @@ public class PythonGatewayServer extends SpringBootServletInitializer { processDefinitionService.releaseProcessDefinition(user, project.getCode(), processDefinition.getCode(), ReleaseState.ONLINE); executorService.execProcessInstance(user, - project.getCode(), - processDefinition.getCode(), - cronTime, - null, - DEFAULT_FAILURE_STRATEGY, - null, - DEFAULT_TASK_DEPEND_TYPE, - DEFAULT_WARNING_TYPE, - DEFAULT_WARNING_GROUP_ID, - DEFAULT_RUN_MODE, - DEFAULT_PRIORITY, - workerGroup, - DEFAULT_ENVIRONMENT_CODE, - timeout, - null, - null, - DEFAULT_DRY_RUN, - COMPLEMENT_DEPENDENT_MODE + project.getCode(), + processDefinition.getCode(), + cronTime, + null, + DEFAULT_FAILURE_STRATEGY, + null, + DEFAULT_TASK_DEPEND_TYPE, + DEFAULT_WARNING_TYPE, + DEFAULT_WARNING_GROUP_ID, + DEFAULT_RUN_MODE, + DEFAULT_PRIORITY, + workerGroup, + DEFAULT_ENVIRONMENT_CODE, + timeout, + null, + null, + DEFAULT_DRY_RUN, + COMPLEMENT_DEPENDENT_MODE ); } @@ -468,8 +459,8 @@ public class PythonGatewayServer extends SpringBootServletInitializer { * Get processDefinition by given processDefinitionName name. It return map contain processDefinition id, name, code. * Useful in Python API create subProcess task which need processDefinition information. * - * @param userName user who create or update schedule - * @param projectName project name which process definition belongs to + * @param userName user who create or update schedule + * @param projectName project name which process definition belongs to * @param processDefinitionName process definition name */ public Map getProcessDefinitionInfo(String userName, String projectName, String processDefinitionName) { @@ -499,9 +490,9 @@ public class PythonGatewayServer extends SpringBootServletInitializer { * Get project, process definition, task code. * Useful in Python API create dependent task which need processDefinition information. * - * @param projectName project name which process definition belongs to + * @param projectName project name which process definition belongs to * @param processDefinitionName process definition name - * @param taskName task name + * @param taskName task name */ public Map getDependentInfo(String projectName, String processDefinitionName, String taskName) { Map result = new HashMap<>(); @@ -535,7 +526,7 @@ public class PythonGatewayServer extends SpringBootServletInitializer { * Useful in Python API create flink or spark task which need processDefinition information. * * @param programType program type one of SCALA, JAVA and PYTHON - * @param fullName full name of the resource + * @param fullName full name of the resource */ public Map getResourcesFileInfo(String programType, String fullName) { Map result = new HashMap<>(); @@ -561,14 +552,14 @@ public class PythonGatewayServer extends SpringBootServletInitializer { InetAddress gatewayHost = InetAddress.getByName(pythonGatewayConfig.getGatewayServerAddress()); InetAddress pythonHost = InetAddress.getByName(pythonGatewayConfig.getPythonAddress()); server = new GatewayServer( - this, - pythonGatewayConfig.getGatewayServerPort(), - pythonGatewayConfig.getPythonPort(), - gatewayHost, - pythonHost, - pythonGatewayConfig.getConnectTimeout(), - pythonGatewayConfig.getReadTimeout(), - null + this, + pythonGatewayConfig.getGatewayServerPort(), + pythonGatewayConfig.getPythonPort(), + gatewayHost, + pythonHost, + pythonGatewayConfig.getConnectTimeout(), + pythonGatewayConfig.getReadTimeout(), + null ); GatewayServer.turnLoggingOn(); logger.info("PythonGatewayServer started on: " + gatewayHost.toString()); diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java index 5183a16149..3bbe770a43 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java @@ -55,6 +55,10 @@ public class JSONUtils { private static final Logger logger = LoggerFactory.getLogger(JSONUtils.class); + static { + logger.info("init timezone: {}",TimeZone.getDefault()); + } + /** * can use static singleton, inject: just make sure to reuse! */ diff --git a/dolphinscheduler-standalone-server/src/main/bin/start.sh b/dolphinscheduler-standalone-server/src/main/bin/start.sh index 6e1a4f4b1a..935db38bb9 100755 --- a/dolphinscheduler-standalone-server/src/main/bin/start.sh +++ b/dolphinscheduler-standalone-server/src/main/bin/start.sh @@ -21,7 +21,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} source "$BIN_DIR/dolphinscheduler_env.sh" -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" diff --git a/dolphinscheduler-standalone-server/src/main/dist-bin/start.sh b/dolphinscheduler-standalone-server/src/main/dist-bin/start.sh index b90a6dbe05..4ef3a11d36 100755 --- a/dolphinscheduler-standalone-server/src/main/dist-bin/start.sh +++ b/dolphinscheduler-standalone-server/src/main/dist-bin/start.sh @@ -21,7 +21,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} source "$BIN_DIR/dolphinscheduler_env.sh" -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" diff --git a/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java b/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java index 35a9cd3551..3866c53066 100644 --- a/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java +++ b/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java @@ -19,28 +19,15 @@ package org.apache.dolphinscheduler; import org.apache.curator.test.TestingServer; -import java.util.TimeZone; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class StandaloneServer { - @Value("${spring.jackson.time-zone:UTC}") - private String timezone; - public static void main(String[] args) throws Exception { final TestingServer server = new TestingServer(true); System.setProperty("registry.zookeeper.connect-string", server.getConnectString()); SpringApplication.run(StandaloneServer.class, args); } - - @PostConstruct - public void run() { - TimeZone.setDefault(TimeZone.getTimeZone(timezone)); - } } diff --git a/dolphinscheduler-worker/src/main/bin/start.sh b/dolphinscheduler-worker/src/main/bin/start.sh index 1d8b378609..514be53116 100644 --- a/dolphinscheduler-worker/src/main/bin/start.sh +++ b/dolphinscheduler-worker/src/main/bin/start.sh @@ -22,7 +22,7 @@ DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} chmod -R 700 ${DOLPHINSCHEDULER_HOME}/config export DOLPHINSCHEDULER_WORK_HOME=${DOLPHINSCHEDULER_HOME} -JAVA_OPTS=${JAVA_OPTS:-"-server -Xms4g -Xmx4g -Xmn2g -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} +JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms4g -Xmx4g -Xmn2g -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} if [[ "$DOCKER" == "true" ]]; then JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java index d5ce17a340..4311612802 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java @@ -44,14 +44,12 @@ import org.apache.commons.collections4.CollectionUtils; import java.util.Collection; import java.util.Set; -import java.util.TimeZone; import javax.annotation.PostConstruct; 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.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @@ -124,9 +122,6 @@ public class WorkerServer implements IStoppable { @Autowired private LoggerRequestProcessor loggerRequestProcessor; - @Value("${spring.jackson.time-zone:UTC}") - private String timezone; - /** * worker server startup, not use web service * @@ -142,8 +137,6 @@ public class WorkerServer implements IStoppable { */ @PostConstruct public void run() { - TimeZone.setDefault(TimeZone.getTimeZone(timezone)); - // init remoting server NettyServerConfig serverConfig = new NettyServerConfig(); serverConfig.setListenPort(workerConfig.getListenPort());