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