@ -24,6 +24,7 @@ import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODE_
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS ;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS ;
import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT ;
import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT ;
import org.apache.commons.collections.MapUtils ;
import org.apache.dolphinscheduler.api.enums.ExecuteType ;
import org.apache.dolphinscheduler.api.enums.ExecuteType ;
import org.apache.dolphinscheduler.api.enums.Status ;
import org.apache.dolphinscheduler.api.enums.Status ;
import org.apache.dolphinscheduler.api.service.ExecutorService ;
import org.apache.dolphinscheduler.api.service.ExecutorService ;
@ -261,15 +262,22 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
putMsg ( result , Status . TENANT_NOT_SUITABLE ) ;
putMsg ( result , Status . TENANT_NOT_SUITABLE ) ;
}
}
//get the startParams user specified at the first starting while repeat running is needed
Map < String , Object > commandMap = JSONUtils . toMap ( processInstance . getCommandParam ( ) , String . class , Object . class ) ;
String startParams = null ;
if ( MapUtils . isNotEmpty ( commandMap ) & & executeType = = ExecuteType . REPEAT_RUNNING ) {
startParams = ( commandMap . get ( Constants . CMD_PARAM_START_PARAMS ) ) . toString ( ) ;
}
switch ( executeType ) {
switch ( executeType ) {
case REPEAT_RUNNING :
case REPEAT_RUNNING :
result = insertCommand ( loginUser , processInstanceId , processDefinition . getId ( ) , CommandType . REPEAT_RUNNING ) ;
result = insertCommand ( loginUser , processInstanceId , processDefinition . getId ( ) , CommandType . REPEAT_RUNNING , startParams ) ;
break ;
break ;
case RECOVER_SUSPENDED_PROCESS :
case RECOVER_SUSPENDED_PROCESS :
result = insertCommand ( loginUser , processInstanceId , processDefinition . getId ( ) , CommandType . RECOVER_SUSPENDED_PROCESS ) ;
result = insertCommand ( loginUser , processInstanceId , processDefinition . getId ( ) , CommandType . RECOVER_SUSPENDED_PROCESS , startParams ) ;
break ;
break ;
case START_FAILURE_TASK_PROCESS :
case START_FAILURE_TASK_PROCESS :
result = insertCommand ( loginUser , processInstanceId , processDefinition . getId ( ) , CommandType . START_FAILURE_TASK_PROCESS ) ;
result = insertCommand ( loginUser , processInstanceId , processDefinition . getId ( ) , CommandType . START_FAILURE_TASK_PROCESS , startParams ) ;
break ;
break ;
case STOP :
case STOP :
if ( processInstance . getState ( ) = = ExecutionStatus . READY_STOP ) {
if ( processInstance . getState ( ) = = ExecutionStatus . READY_STOP ) {
@ -385,13 +393,20 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
* @param commandType command type
* @param commandType command type
* @return insert result code
* @return insert result code
* /
* /
private Map < String , Object > insertCommand ( User loginUser , Integer instanceId , Integer processDefinitionId , CommandType commandType ) {
private Map < String , Object > insertCommand ( User loginUser , Integer instanceId , Integer processDefinitionId , CommandType commandType , String startParams ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
//To add startParams only when repeat running is needed
Map < String , Object > cmdParam = new HashMap < > ( ) ;
cmdParam . put ( CMD_PARAM_RECOVER_PROCESS_ID_STRING , instanceId ) ;
if ( StringUtils . isNotEmpty ( startParams ) ) {
cmdParam . put ( CMD_PARAM_START_PARAMS , startParams ) ;
}
Command command = new Command ( ) ;
Command command = new Command ( ) ;
command . setCommandType ( commandType ) ;
command . setCommandType ( commandType ) ;
command . setProcessDefinitionId ( processDefinitionId ) ;
command . setProcessDefinitionId ( processDefinitionId ) ;
command . setCommandParam ( String . format ( "{\"%s\":%d}" ,
command . setCommandParam ( JSONUtils . toJsonString ( cmdParam ) ) ;
CMD_PARAM_RECOVER_PROCESS_ID_STRING , instanceId ) ) ;
command . setExecutorId ( loginUser . getId ( ) ) ;
command . setExecutorId ( loginUser . getId ( ) ) ;
if ( ! processService . verifyIsNeedCreateCommand ( command ) ) {
if ( ! processService . verifyIsNeedCreateCommand ( command ) ) {