Browse Source

fix some code smell problems

1. use Collections.isEmpt() instead of size() > 0
2. make if statements more readable
pull/3/MERGE
Zhou Zheng 4 years ago
parent
commit
6e5145f7c4
  1. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
  2. 28
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
  3. 2
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java

@ -635,7 +635,7 @@ public class ExecutorService extends BaseService{
*/
private boolean checkValidForcedSuccessTask(int processInstanceId) {
List<Integer> forcedSuccessList = processService.findTaskIdByInstanceState(processInstanceId, ExecutionStatus.FORCED_SUCCESS);
if (forcedSuccessList != null && forcedSuccessList.size() > 0) {
if (forcedSuccessList != null && !forcedSuccessList.isEmpty()) {
return true;
}

28
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java

@ -1180,34 +1180,32 @@ public class MasterExecThread implements Runnable {
/**
* handling the list of tasks to be submitted
*/
private void submitStandByTask(){
for(Map.Entry<String, TaskInstance> entry: readyToSubmitTaskList.entrySet()) {
private void submitStandByTask() {
for (Map.Entry<String, TaskInstance> entry : readyToSubmitTaskList.entrySet()) {
TaskInstance task = entry.getValue();
// stop tasks which is retrying if forced success happens
if (task.taskCanRetry()) {
TaskInstance tmpTask = processService.findTaskInstanceById(task.getId());
if (tmpTask != null) {
if (tmpTask.getState().equals(ExecutionStatus.FORCED_SUCCESS)) {
task.setState(tmpTask.getState());
logger.info("task: {} has been forced success, put it into complete task list and stop retrying", task.getName());
removeTaskFromStandbyList(task);
completeTaskList.put(task.getName(), task);
submitPostNode(task.getName());
continue;
}
if (tmpTask != null && tmpTask.getState().equals(ExecutionStatus.FORCED_SUCCESS)) {
task.setState(tmpTask.getState());
logger.info("task: {} has been forced success, put it into complete task list and stop retrying", task.getName());
removeTaskFromStandbyList(task);
completeTaskList.put(task.getName(), task);
submitPostNode(task.getName());
continue;
}
}
DependResult dependResult = getDependResultForTask(task);
if(DependResult.SUCCESS == dependResult){
if(retryTaskIntervalOverTime(task)){
if (DependResult.SUCCESS == dependResult) {
if (retryTaskIntervalOverTime(task)) {
submitTaskExec(task);
removeTaskFromStandbyList(task);
}
}else if(DependResult.FAILED == dependResult){
} else if (DependResult.FAILED == dependResult) {
// if the dependency fails, the current node is not submitted and the state changes to failure.
dependFailedTask.put(entry.getKey(), task);
removeTaskFromStandbyList(task);
logger.info("task {},id:{} depend result : {}",task.getName(), task.getId(), dependResult);
logger.info("task {},id:{} depend result : {}", task.getName(), task.getId(), dependResult);
}
}
}

2
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -790,7 +790,7 @@ public class ProcessService {
List<Integer> forcedSuccessList = this.findTaskIdInSubProcessByStatusAndType(taskInstanceId,
new ExecutionStatus[]{ExecutionStatus.FORCED_SUCCESS},
null);
if (forcedSuccessList != null && forcedSuccessList.size() > 0) {
if (forcedSuccessList != null && !forcedSuccessList.isEmpty()) {
return true;
}

Loading…
Cancel
Save