@ -83,8 +83,6 @@ import py4j.GatewayServer;
public class PythonGateway {
private static final Logger logger = LoggerFactory . getLogger ( PythonGateway . class ) ;
private static final WarningType DEFAULT_WARNING_TYPE = WarningType . NONE ;
private static final int DEFAULT_WARNING_GROUP_ID = 0 ;
private static final FailureStrategy DEFAULT_FAILURE_STRATEGY = FailureStrategy . CONTINUE ;
private static final Priority DEFAULT_PRIORITY = Priority . MEDIUM ;
private static final Long DEFAULT_ENVIRONMENT_CODE = - 1L ;
@ -200,6 +198,8 @@ public class PythonGateway {
* @param globalParams global params
* @param schedule schedule for process definition , will not set schedule if null ,
* and if would always fresh exists schedule if not null
* @param warningType warning type
* @param warningGroupId warning group id
* @param locations locations json object about all tasks
* @param timeout timeout for process definition working , if running time longer than timeout ,
* task will mark as fail
@ -215,6 +215,8 @@ public class PythonGateway {
String description ,
String globalParams ,
String schedule ,
String warningType ,
int warningGroupId ,
String locations ,
int timeout ,
String workerGroup ,
@ -244,7 +246,7 @@ public class PythonGateway {
// Fresh process definition schedule
if ( schedule ! = null ) {
createOrUpdateSchedule ( user , projectCode , processDefinitionCode , schedule , workerGroup ) ;
createOrUpdateSchedule ( user , projectCode , processDefinitionCode , schedule , workerGroup , warningType , warningGroupId ) ;
}
processDefinitionService . releaseProcessDefinition ( user , projectCode , processDefinitionCode , ReleaseState . ONLINE ) ;
return processDefinitionCode ;
@ -283,25 +285,29 @@ public class PythonGateway {
* @param processDefinitionCode process definition code
* @param schedule schedule expression
* @param workerGroup work group
* @param warningType warning type
* @param warningGroupId warning group id
* /
private void createOrUpdateSchedule ( User user ,
long projectCode ,
long processDefinitionCode ,
String schedule ,
String workerGroup ) {
String workerGroup ,
String warningType ,
int warningGroupId ) {
Schedule scheduleObj = scheduleMapper . queryByProcessDefinitionCode ( processDefinitionCode ) ;
// create or update schedule
int scheduleId ;
if ( scheduleObj = = null ) {
processDefinitionService . releaseProcessDefinition ( user , projectCode , processDefinitionCode , ReleaseState . ONLINE ) ;
Map < String , Object > result = schedulerService . insertSchedule ( user , projectCode , processDefinitionCode , schedule , DEFAULT_WARNING_TYPE ,
DEFAULT_WARNING_GROUP_ID , DEFAULT_FAILURE_STRATEGY , DEFAULT_PRIORITY , workerGroup , DEFAULT_ENVIRONMENT_CODE ) ;
Map < String , Object > result = schedulerService . insertSchedule ( user , projectCode , processDefinitionCode , schedule , WarningType . valueOf ( warningType ) ,
warningGroupId , DEFAULT_FAILURE_STRATEGY , DEFAULT_PRIORITY , workerGroup , DEFAULT_ENVIRONMENT_CODE ) ;
scheduleId = ( int ) result . get ( "scheduleId" ) ;
} else {
scheduleId = scheduleObj . getId ( ) ;
processDefinitionService . releaseProcessDefinition ( user , projectCode , processDefinitionCode , ReleaseState . OFFLINE ) ;
schedulerService . updateSchedule ( user , projectCode , scheduleId , schedule , DEFAULT_WARNING_TYPE ,
DEFAULT_WARNING_GROUP_ID , DEFAULT_FAILURE_STRATEGY , DEFAULT_PRIORITY , workerGroup , DEFAULT_ENVIRONMENT_CODE ) ;
schedulerService . updateSchedule ( user , projectCode , scheduleId , schedule , WarningType . valueOf ( warningType ) ,
warningGroupId , DEFAULT_FAILURE_STRATEGY , DEFAULT_PRIORITY , workerGroup , DEFAULT_ENVIRONMENT_CODE ) ;
}
schedulerService . setScheduleState ( user , projectCode , scheduleId , ReleaseState . ONLINE ) ;
}
@ -311,6 +317,8 @@ public class PythonGateway {
String processDefinitionName ,
String cronTime ,
String workerGroup ,
String warningType ,
int warningGroupId ,
Integer timeout
) {
User user = usersService . queryUser ( userName ) ;
@ -328,8 +336,8 @@ public class PythonGateway {
DEFAULT_FAILURE_STRATEGY ,
null ,
DEFAULT_TASK_DEPEND_TYPE ,
DEFAULT_WARNING_TYPE ,
DEFAULT_WARNING_GROUP_ID ,
WarningType . valueOf ( warningType ) ,
warningGroupId ,
DEFAULT_RUN_MODE ,
DEFAULT_PRIORITY ,
workerGroup ,