Browse Source

Merge remote-tracking branch 'upstream/dev' into json_split

# Conflicts:
#	dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
#	dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java
pull/3/MERGE
baoliang 4 years ago
parent
commit
7aa8b518ac
  1. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java
  2. 19
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java
  3. 18
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/procedure/ProcedureTask.java

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java

@ -38,7 +38,6 @@ import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
import org.apache.dolphinscheduler.api.utils.RegexUtils;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.ReleaseState;

19
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java

@ -74,6 +74,7 @@ public class DependentExecute {
/** /**
* constructor * constructor
*
* @param itemList item list * @param itemList item list
* @param relation relation * @param relation relation
*/ */
@ -84,6 +85,7 @@ public class DependentExecute {
/** /**
* get dependent item for one dependent item * get dependent item for one dependent item
*
* @param dependentItem dependent item * @param dependentItem dependent item
* @param currentTime current time * @param currentTime current time
* @return DependResult * @return DependResult
@ -95,6 +97,7 @@ public class DependentExecute {
/** /**
* calculate dependent result for one dependent item. * calculate dependent result for one dependent item.
*
* @param dependentItem dependent item * @param dependentItem dependent item
* @param dateIntervals date intervals * @param dateIntervals date intervals
* @return dateIntervals * @return dateIntervals
@ -103,17 +106,17 @@ public class DependentExecute {
List<DateInterval> dateIntervals) { List<DateInterval> dateIntervals) {
DependResult result = DependResult.FAILED; DependResult result = DependResult.FAILED;
for(DateInterval dateInterval : dateIntervals){ for (DateInterval dateInterval : dateIntervals) {
ProcessInstance processInstance = findLastProcessInterval(dependentItem.getDefinitionCode(), ProcessInstance processInstance = findLastProcessInterval(dependentItem.getDefinitionCode(),
dateInterval); dateInterval);
if(processInstance == null){ if (processInstance == null) {
return DependResult.WAITING; return DependResult.WAITING;
} }
// need to check workflow for updates, so get all task and check the task state // need to check workflow for updates, so get all task and check the task state
if (dependentItem.getDepTasks().equals(Constants.DEPENDENT_ALL)) { if (dependentItem.getDepTasks().equals(Constants.DEPENDENT_ALL)) {
result = dependResultByProcessInstance(processInstance); result = dependResultByProcessInstance(processInstance);
} else { } else {
result = getDependTaskResult(dependentItem.getDepTasks(),processInstance); result = getDependTaskResult(dependentItem.getDepTasks(), processInstance);
} }
if (result != DependResult.SUCCESS) { if (result != DependResult.SUCCESS) {
break; break;
@ -124,6 +127,7 @@ public class DependentExecute {
/** /**
* depend type = depend_all * depend type = depend_all
*
* @return * @return
*/ */
private DependResult dependResultByProcessInstance(ProcessInstance processInstance) { private DependResult dependResultByProcessInstance(ProcessInstance processInstance) {
@ -138,6 +142,7 @@ public class DependentExecute {
/** /**
* get depend task result * get depend task result
*
* @param taskName * @param taskName
* @param processInstance * @param processInstance
* @return * @return
@ -173,6 +178,7 @@ public class DependentExecute {
* find the last one process instance that : * find the last one process instance that :
* 1. manual run and finish between the interval * 1. manual run and finish between the interval
* 2. schedule run and schedule time between the interval * 2. schedule run and schedule time between the interval
*
* @param definitionCode definition code * @param definitionCode definition code
* @param dateInterval date interval * @param dateInterval date interval
* @return ProcessInstance * @return ProcessInstance
@ -180,7 +186,7 @@ public class DependentExecute {
private ProcessInstance findLastProcessInterval(Long definitionCode, DateInterval dateInterval) { private ProcessInstance findLastProcessInterval(Long definitionCode, DateInterval dateInterval) {
ProcessInstance runningProcess = processService.findLastRunningProcess(definitionCode, dateInterval.getStartTime(), dateInterval.getEndTime()); ProcessInstance runningProcess = processService.findLastRunningProcess(definitionCode, dateInterval.getStartTime(), dateInterval.getEndTime());
if(runningProcess != null){ if (runningProcess != null) {
return runningProcess; return runningProcess;
} }
@ -200,6 +206,7 @@ public class DependentExecute {
/** /**
* get dependent result by task/process instance state * get dependent result by task/process instance state
*
* @param state state * @param state state
* @return DependResult * @return DependResult
*/ */
@ -216,6 +223,7 @@ public class DependentExecute {
/** /**
* get dependent result by task instance state when task instance is null * get dependent result by task instance state when task instance is null
*
* @param state state * @param state state
* @return DependResult * @return DependResult
*/ */
@ -232,6 +240,7 @@ public class DependentExecute {
/** /**
* judge depend item finished * judge depend item finished
*
* @param currentTime current time * @param currentTime current time
* @return boolean * @return boolean
*/ */
@ -245,6 +254,7 @@ public class DependentExecute {
/** /**
* get model depend result * get model depend result
*
* @param currentTime current time * @param currentTime current time
* @return DependResult * @return DependResult
*/ */
@ -265,6 +275,7 @@ public class DependentExecute {
/** /**
* get dependent item result * get dependent item result
*
* @param item item * @param item item
* @param currentTime current time * @param currentTime current time
* @return DependResult * @return DependResult

18
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/procedure/ProcedureTask.java

@ -118,7 +118,6 @@ public class ProcedureTask extends AbstractTask {
// get jdbc connection // get jdbc connection
connection = DatasourceUtil.getConnection(dbType, connectionParam); connection = DatasourceUtil.getConnection(dbType, connectionParam);
// combining local and global parameters // combining local and global parameters
Map<String, Property> paramsMap = ParamUtils.convert(ParamUtils.getUserDefParamsMap(taskExecutionContext.getDefinedParams()), Map<String, Property> paramsMap = ParamUtils.convert(ParamUtils.getUserDefParamsMap(taskExecutionContext.getDefinedParams()),
taskExecutionContext.getDefinedParams(), taskExecutionContext.getDefinedParams(),
@ -146,7 +145,7 @@ public class ProcedureTask extends AbstractTask {
logger.error("procedure task error", e); logger.error("procedure task error", e);
throw e; throw e;
} finally { } finally {
close(stmt,connection); close(stmt, connection);
} }
} }
@ -181,7 +180,7 @@ public class ProcedureTask extends AbstractTask {
* @throws Exception Exception * @throws Exception Exception
*/ */
private Map<Integer, Property> getOutParameterMap(CallableStatement stmt, Map<String, Property> paramsMap) throws Exception { private Map<Integer, Property> getOutParameterMap(CallableStatement stmt, Map<String, Property> paramsMap) throws Exception {
Map<Integer,Property> outParameterMap = new HashMap<>(); Map<Integer, Property> outParameterMap = new HashMap<>();
if (procedureParameters.getLocalParametersMap() == null) { if (procedureParameters.getLocalParametersMap() == null) {
return outParameterMap; return outParameterMap;
} }
@ -195,7 +194,7 @@ public class ProcedureTask extends AbstractTask {
int index = 1; int index = 1;
for (Property property : userDefParamsList) { for (Property property : userDefParamsList) {
logger.info("localParams : prop : {} , dirct : {} , type : {} , value : {}" logger.info("localParams : prop : {} , dirct : {} , type : {} , value : {}"
,property.getProp(), , property.getProp(),
property.getDirect(), property.getDirect(),
property.getType(), property.getType(),
property.getValue()); property.getValue());
@ -203,9 +202,9 @@ public class ProcedureTask extends AbstractTask {
if (property.getDirect().equals(Direct.IN)) { if (property.getDirect().equals(Direct.IN)) {
ParameterUtils.setInParameter(index, stmt, property.getType(), paramsMap.get(property.getProp()).getValue()); ParameterUtils.setInParameter(index, stmt, property.getType(), paramsMap.get(property.getProp()).getValue());
} else if (property.getDirect().equals(Direct.OUT)) { } else if (property.getDirect().equals(Direct.OUT)) {
setOutParameter(index,stmt,property.getType(),paramsMap.get(property.getProp()).getValue()); setOutParameter(index, stmt, property.getType(), paramsMap.get(property.getProp()).getValue());
property.setValue(paramsMap.get(property.getProp()).getValue()); property.setValue(paramsMap.get(property.getProp()).getValue());
outParameterMap.put(index,property); outParameterMap.put(index, property);
} }
index++; index++;
} }
@ -237,20 +236,21 @@ public class ProcedureTask extends AbstractTask {
try { try {
stmt.close(); stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("close prepared statement error : {}",e.getMessage(),e); logger.error("close prepared statement error : {}", e.getMessage(), e);
} }
} }
if (connection != null) { if (connection != null) {
try { try {
connection.close(); connection.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("close connection error : {}",e.getMessage(),e); logger.error("close connection error : {}", e.getMessage(), e);
} }
} }
} }
/** /**
* get output parameter * get output parameter
*
* @param stmt stmt * @param stmt stmt
* @param index index * @param index index
* @param prop prop * @param prop prop
@ -305,7 +305,7 @@ public class ProcedureTask extends AbstractTask {
* @param value value * @param value value
* @throws Exception exception * @throws Exception exception
*/ */
private void setOutParameter(int index,CallableStatement stmt,DataType dataType,String value)throws Exception { private void setOutParameter(int index, CallableStatement stmt, DataType dataType, String value) throws Exception {
int sqlType; int sqlType;
switch (dataType) { switch (dataType) {
case VARCHAR: case VARCHAR:

Loading…
Cancel
Save