Browse Source

Fix process definitions exists check error (#6668)

* Fix process definitions exists check error

* Add error log while verify status neither success or exists
3.0.0/version-upgrade
Jiajie Zhong 3 years ago committed by GitHub
parent
commit
9060f8b462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java

13
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java

@ -52,6 +52,8 @@ import java.util.Objects;
import javax.annotation.PostConstruct; 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.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@ -69,6 +71,8 @@ import py4j.GatewayServer;
}) })
}) })
public class PythonGatewayServer extends SpringBootServletInitializer { public class PythonGatewayServer extends SpringBootServletInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(PythonGatewayServer.class);
@Autowired @Autowired
private ProcessDefinitionMapper processDefinitionMapper; private ProcessDefinitionMapper processDefinitionMapper;
@ -177,7 +181,8 @@ public class PythonGatewayServer extends SpringBootServletInitializer {
long projectCode = project.getCode(); long projectCode = project.getCode();
Map<String, Object> verifyProcessDefinitionExists = processDefinitionService.verifyProcessDefinitionName(user, projectCode, name); Map<String, Object> verifyProcessDefinitionExists = processDefinitionService.verifyProcessDefinitionName(user, projectCode, name);
if (verifyProcessDefinitionExists.get(Constants.STATUS) != Status.SUCCESS) { Status verifyStatus = (Status) verifyProcessDefinitionExists.get(Constants.STATUS);
if (verifyStatus == Status.PROCESS_DEFINITION_NAME_EXIST) {
// update process definition // update process definition
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name); ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name);
long processDefinitionCode = processDefinition.getCode(); long processDefinitionCode = processDefinition.getCode();
@ -186,12 +191,16 @@ public class PythonGatewayServer extends SpringBootServletInitializer {
Map<String, Object> result = processDefinitionService.updateProcessDefinition(user, projectCode, name, processDefinitionCode, description, globalParams, Map<String, Object> result = processDefinitionService.updateProcessDefinition(user, projectCode, name, processDefinitionCode, description, globalParams,
locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson); locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson);
return processDefinitionCode; return processDefinitionCode;
} else { } else if (verifyStatus == Status.SUCCESS) {
// create process definition // create process definition
Map<String, Object> result = processDefinitionService.createProcessDefinition(user, projectCode, name, description, globalParams, Map<String, Object> result = processDefinitionService.createProcessDefinition(user, projectCode, name, description, globalParams,
locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson); locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson);
ProcessDefinition processDefinition = (ProcessDefinition) result.get(Constants.DATA_LIST); ProcessDefinition processDefinition = (ProcessDefinition) result.get(Constants.DATA_LIST);
return processDefinition.getCode(); return processDefinition.getCode();
} else {
String msg = "Verify process definition exists status is invalid, neither SUCCESS or PROCESS_DEFINITION_NAME_EXIST.";
LOGGER.error(msg);
throw new RuntimeException(msg);
} }
} }

Loading…
Cancel
Save