You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/06/28 07:03:22 UTC

[GitHub] [dolphinscheduler] kezhenxu94 commented on a diff in pull request #10649: Validate master/worker config

kezhenxu94 commented on code in PR #10649:
URL: https://github.com/apache/dolphinscheduler/pull/10649#discussion_r908110486


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/config/MasterConfig.java:
##########
@@ -17,174 +17,87 @@
 
 package org.apache.dolphinscheduler.server.master.config;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 import org.apache.dolphinscheduler.server.master.dispatch.host.assign.HostSelector;
 import org.apache.dolphinscheduler.server.master.processor.queue.TaskExecuteRunnable;
 import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
 
+import java.time.Duration;
+
+import javax.annotation.PostConstruct;
+
 import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.stereotype.Component;
+import org.springframework.context.annotation.Configuration;
+
+import lombok.Data;
 
-@Component
-@EnableConfigurationProperties
-@ConfigurationProperties("master")
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "master")
 public class MasterConfig {
     /**
      * The master RPC server listen port.
      */
-    private int listenPort;
+    private int listenPort = 5678;
     /**
      * The max batch size used to fetch command from database.
      */
-    private int fetchCommandNum;
+    private int fetchCommandNum = 10;
     /**
      * The thread number used to prepare processInstance. This number shouldn't bigger than fetchCommandNum.
      */
-    private int preExecThreads;
+    private int preExecThreads = 10;
     /**
      * todo: We may need to split the process/task into different thread size.
      * The thread number used to handle processInstance and task event.
      * Will create two thread poll to execute {@link WorkflowExecuteRunnable} and {@link TaskExecuteRunnable}.
      */
-    private int execThreads;
+    private int execThreads = 10;
     /**
      * The task dispatch thread pool size.
      */
-    private int dispatchTaskNumber;
+    private int dispatchTaskNumber = 3;
     /**
      * Worker select strategy.
      */
-    private HostSelector hostSelector;
+    private HostSelector hostSelector = HostSelector.LOWER_WEIGHT;
     /**
      * Master heart beat task execute interval.
      */
-    private int heartbeatInterval;
+    private Duration heartbeatInterval = Duration.ofSeconds(10);
     /**
      * task submit max retry times.
      */
-    private int taskCommitRetryTimes;
+    private int taskCommitRetryTimes = 5;
     /**
-     * task submit retry interval/ms.
+     * task submit retry interval.
      */
-    private int taskCommitInterval;
+    private Duration taskCommitInterval = Duration.ofSeconds(1);
     /**
-     * state wheel check interval/ms, if this value is bigger, may increase the delay of task/processInstance.
+     * state wheel check interval, if this value is bigger, may increase the delay of task/processInstance.
      */
-    private int stateWheelInterval;
-    private double maxCpuLoadAvg;
-    private double reservedMemory;
-    private int failoverInterval;
-    private boolean killYarnJobWhenTaskFailover;
-
-    public int getListenPort() {
-        return listenPort;
-    }
-
-    public void setListenPort(int listenPort) {
-        this.listenPort = listenPort;
-    }
-
-    public int getFetchCommandNum() {
-        return fetchCommandNum;
-    }
-
-    public void setFetchCommandNum(int fetchCommandNum) {
-        this.fetchCommandNum = fetchCommandNum;
-    }
-
-    public int getPreExecThreads() {
-        return preExecThreads;
-    }
-
-    public void setPreExecThreads(int preExecThreads) {
-        this.preExecThreads = preExecThreads;
-    }
-
-    public int getExecThreads() {
-        return execThreads;
-    }
-
-    public void setExecThreads(int execThreads) {
-        this.execThreads = execThreads;
-    }
-
-    public int getDispatchTaskNumber() {
-        return dispatchTaskNumber;
-    }
-
-    public void setDispatchTaskNumber(int dispatchTaskNumber) {
-        this.dispatchTaskNumber = dispatchTaskNumber;
-    }
-
-    public HostSelector getHostSelector() {
-        return hostSelector;
-    }
-
-    public void setHostSelector(HostSelector hostSelector) {
-        this.hostSelector = hostSelector;
-    }
-
-    public int getHeartbeatInterval() {
-        return heartbeatInterval;
-    }
-
-    public void setHeartbeatInterval(int heartbeatInterval) {
-        this.heartbeatInterval = heartbeatInterval;
-    }
-
-    public int getTaskCommitRetryTimes() {
-        return taskCommitRetryTimes;
-    }
-
-    public void setTaskCommitRetryTimes(int taskCommitRetryTimes) {
-        this.taskCommitRetryTimes = taskCommitRetryTimes;
-    }
-
-    public int getTaskCommitInterval() {
-        return taskCommitInterval;
-    }
-
-    public void setTaskCommitInterval(int taskCommitInterval) {
-        this.taskCommitInterval = taskCommitInterval;
-    }
-
-    public int getStateWheelInterval() {
-        return stateWheelInterval;
-    }
-
-    public void setStateWheelInterval(int stateWheelInterval) {
-        this.stateWheelInterval = stateWheelInterval;
-    }
-
-    public double getMaxCpuLoadAvg() {
-        return maxCpuLoadAvg > 0 ? maxCpuLoadAvg : Runtime.getRuntime().availableProcessors() * 2;
-    }
-
-    public void setMaxCpuLoadAvg(double maxCpuLoadAvg) {
-        this.maxCpuLoadAvg = maxCpuLoadAvg;
-    }
-
-    public double getReservedMemory() {
-        return reservedMemory;
-    }
-
-    public void setReservedMemory(double reservedMemory) {
-        this.reservedMemory = reservedMemory;
-    }
-
-    public int getFailoverInterval() {
-        return failoverInterval;
-    }
-
-    public void setFailoverInterval(int failoverInterval) {
-        this.failoverInterval = failoverInterval;
-    }
-
-    public boolean isKillYarnJobWhenTaskFailover() {
-        return killYarnJobWhenTaskFailover;
-    }
-
-    public void setKillYarnJobWhenTaskFailover(boolean killYarnJobWhenTaskFailover) {
-        this.killYarnJobWhenTaskFailover = killYarnJobWhenTaskFailover;
+    private Duration stateWheelInterval = Duration.ofMillis(5);
+    private double maxCpuLoadAvg = -1;
+    private double reservedMemory = 0.3;
+    private Duration failoverInterval = Duration.ofMinutes(10);
+    private boolean killYarnJobWhenTaskFailover = true;
+
+    @PostConstruct
+    public void validate() {

Review Comment:
   Can you implement the validation logic via implementing `org.springframework.validation.Validator` interface and add annotation `org.springframework.validation.annotation.Validated` to this class? That's what Spring propose to validate properties



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org