status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | * set schedule online or offline
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param scheduleStatus schedule status
* @return publish result code
*/
Map<String, Object> setScheduleState(User loginUser,
String projectName,
Integer id,
ReleaseState scheduleStatus);
/**
* query schedule
*
* @param loginUser login user
* @param projectName project name
* @param processDefineId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value
* @return schedule list page
*/
Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize);
/**
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @return schedule list |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | */
Map<String, Object> queryScheduleList(User loginUser, String projectName);
/**
* delete schedule
*
* @param projectId project id
* @param scheduleId schedule id
* @throws RuntimeException runtime exception
*/
void deleteSchedule(int projectId, int scheduleId);
/**
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param scheduleId scheule id
* @return delete result code
*/
Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId);
/**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
Map<String, Object> previewSchedule(User loginUser, String projectName, String schedule);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import org.apache.dolphinscheduler.api.dto.ScheduleParam;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ExecutorService;
import org.apache.dolphinscheduler.api.service.MonitorService;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.model.Server;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.quartz.ProcessScheduleJob;
import org.apache.dolphinscheduler.service.quartz.QuartzExecutors;
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* scheduler service impl
*/
@Service
public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerService {
private static final Logger logger = LoggerFactory.getLogger(SchedulerServiceImpl.class); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | @Autowired
private ProjectService projectService;
@Autowired
private ExecutorService executorService;
@Autowired
private MonitorService monitorService;
@Autowired
private ProcessService processService;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private ProjectMapper projectMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
/**
* save schedule
*
* @param loginUser login user
* @param projectCode project name
* @param processDefineCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group
* @return create result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | public Map<String, Object> insertSchedule(User loginUser,
long projectCode,
long processDefineCode,
String schedule,
WarningType warningType,
int warningGroupId,
FailureStrategy failureStrategy,
Priority processInstancePriority,
String workerGroup) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefineCode);
result = executorService.checkProcessDefinitionValid(processDefinition, processDefineCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
Schedule scheduleObj = new Schedule();
Date now = new Date();
scheduleObj.setProjectName(project.getName());
scheduleObj.setProcessDefinitionId(processDefinition.getId());
scheduleObj.setProcessDefinitionName(processDefinition.getName());
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);
if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) {
logger.warn("The start time must not be the same as the end"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME);
return result;
}
scheduleObj.setStartTime(scheduleParam.getStartTime());
scheduleObj.setEndTime(scheduleParam.getEndTime());
if (!org.quartz.CronExpression.isValidExpression(scheduleParam.getCrontab())) {
logger.error("{} verify failure", scheduleParam.getCrontab());
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, scheduleParam.getCrontab());
return result;
}
scheduleObj.setCrontab(scheduleParam.getCrontab());
scheduleObj.setTimezoneId(scheduleParam.getTimezoneId());
scheduleObj.setWarningType(warningType);
scheduleObj.setWarningGroupId(warningGroupId);
scheduleObj.setFailureStrategy(failureStrategy);
scheduleObj.setCreateTime(now);
scheduleObj.setUpdateTime(now);
scheduleObj.setUserId(loginUser.getId());
scheduleObj.setUserName(loginUser.getUserName());
scheduleObj.setReleaseState(ReleaseState.OFFLINE);
scheduleObj.setProcessInstancePriority(processInstancePriority);
scheduleObj.setWorkerGroup(workerGroup);
scheduleMapper.insert(scheduleObj);
/**
* updateProcessInstance receivers and cc by process definition id
*/
processDefinition.setWarningGroupId(warningGroupId);
processDefinitionMapper.updateById(processDefinition);
result.put(Constants.DATA_LIST, scheduleMapper.selectById(scheduleObj.getId())); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | putMsg(result, Status.SUCCESS);
result.put("scheduleId", scheduleObj.getId());
return result;
}
/**
* updateProcessInstance schedule
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param scheduleExpression scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @param scheduleStatus schedule status
* @return update result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> updateSchedule(User loginUser,
String projectName,
Integer id,
String scheduleExpression,
WarningType warningType,
int warningGroupId,
FailureStrategy failureStrategy,
ReleaseState scheduleStatus,
Priority processInstancePriority, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | String workerGroup) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
Schedule schedule = scheduleMapper.selectById(id);
if (schedule == null) {
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, id);
return result;
}
ProcessDefinition processDefinition = processService.findProcessDefineById(schedule.getProcessDefinitionId());
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, schedule.getProcessDefinitionId());
return result;
}
/**
* scheduling on-line status forbid modification
*/
if (checkValid(result, schedule.getReleaseState() == ReleaseState.ONLINE, Status.SCHEDULE_CRON_ONLINE_FORBID_UPDATE)) {
return result;
}
Date now = new Date();
if (StringUtils.isNotEmpty(scheduleExpression)) {
ScheduleParam scheduleParam = JSONUtils.parseObject(scheduleExpression, ScheduleParam.class);
if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | logger.warn("The start time must not be the same as the end");
putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME);
return result;
}
schedule.setStartTime(scheduleParam.getStartTime());
schedule.setEndTime(scheduleParam.getEndTime());
if (!org.quartz.CronExpression.isValidExpression(scheduleParam.getCrontab())) {
putMsg(result, Status.SCHEDULE_CRON_CHECK_FAILED, scheduleParam.getCrontab());
return result;
}
schedule.setCrontab(scheduleParam.getCrontab());
schedule.setTimezoneId(scheduleParam.getTimezoneId());
}
if (warningType != null) {
schedule.setWarningType(warningType);
}
schedule.setWarningGroupId(warningGroupId);
if (failureStrategy != null) {
schedule.setFailureStrategy(failureStrategy);
}
if (scheduleStatus != null) {
schedule.setReleaseState(scheduleStatus);
}
schedule.setWorkerGroup(workerGroup);
schedule.setUpdateTime(now);
schedule.setProcessInstancePriority(processInstancePriority);
scheduleMapper.updateById(schedule);
/**
* updateProcessInstance recipients and cc by process definition ID
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | processDefinition.setWarningGroupId(warningGroupId);
processDefinitionMapper.updateById(processDefinition);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* set schedule online or offline
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param scheduleStatus schedule status
* @return publish result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> setScheduleState(User loginUser,
String projectName,
Integer id,
ReleaseState scheduleStatus) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
Schedule scheduleObj = scheduleMapper.selectById(id);
if (scheduleObj == null) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, id);
return result;
}
if (scheduleObj.getReleaseState() == scheduleStatus) {
logger.info("schedule release is already {},needn't to change schedule id: {} from {} to {}",
scheduleObj.getReleaseState(), scheduleObj.getId(), scheduleObj.getReleaseState(), scheduleStatus);
putMsg(result, Status.SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE, scheduleStatus);
return result;
}
ProcessDefinition processDefinition = processService.findProcessDefineById(scheduleObj.getProcessDefinitionId());
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, scheduleObj.getProcessDefinitionId());
return result;
}
if (scheduleStatus == ReleaseState.ONLINE) {
if (processDefinition.getReleaseState() != ReleaseState.ONLINE) {
logger.info("not release process definition id: {} , name : {}",
processDefinition.getId(), processDefinition.getName());
putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinition.getName());
return result;
}
List<Integer> subProcessDefineIds = new ArrayList<>();
processService.recurseFindSubProcessId(scheduleObj.getProcessDefinitionId(), subProcessDefineIds);
Integer[] idArray = subProcessDefineIds.toArray(new Integer[subProcessDefineIds.size()]);
if (!subProcessDefineIds.isEmpty()) {
List<ProcessDefinition> subProcessDefinitionList =
processDefinitionMapper.queryDefinitionListByIdList(idArray); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | if (subProcessDefinitionList != null && !subProcessDefinitionList.isEmpty()) {
for (ProcessDefinition subProcessDefinition : subProcessDefinitionList) {
/**
* if there is no online process, exit directly
*/
if (subProcessDefinition.getReleaseState() != ReleaseState.ONLINE) {
logger.info("not release process definition id: {} , name : {}",
subProcessDefinition.getId(), subProcessDefinition.getName());
putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, subProcessDefinition.getId());
return result;
}
}
}
}
}
List<Server> masterServers = monitorService.getServerListFromRegistry(true);
if (masterServers.isEmpty()) {
putMsg(result, Status.MASTER_NOT_EXISTS);
return result;
}
scheduleObj.setReleaseState(scheduleStatus);
scheduleMapper.updateById(scheduleObj);
try {
switch (scheduleStatus) {
case ONLINE:
logger.info("Call master client set schedule online, project id: {}, flow id: {},host: {}", project.getId(), processDefinition.getId(), masterServers);
setSchedule(project.getId(), scheduleObj);
break; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | case OFFLINE:
logger.info("Call master client set schedule offline, project id: {}, flow id: {},host: {}", project.getId(), processDefinition.getId(), masterServers);
deleteSchedule(project.getId(), id);
break;
default:
putMsg(result, Status.SCHEDULE_STATUS_UNKNOWN, scheduleStatus.toString());
return result;
}
} catch (Exception e) {
result.put(Constants.MSG, scheduleStatus == ReleaseState.ONLINE ? "set online failure" : "set offline failure");
throw new ServiceException(result.get(Constants.MSG).toString());
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query schedule
*
* @param loginUser login user
* @param projectName project name
* @param processDefineId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value
* @return schedule list page
*/
@Override
public Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize) {
HashMap<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
ProcessDefinition processDefinition = processService.findProcessDefineById(processDefineId);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineId);
return result;
}
Page<Schedule> page = new Page<>(pageNo, pageSize);
IPage<Schedule> scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging(
page, processDefineId, searchVal
);
PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int) scheduleIPage.getTotal());
pageInfo.setLists(scheduleIPage.getRecords());
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @return schedule list
*/
@Override
public Map<String, Object> queryScheduleList(User loginUser, String projectName) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(projectName);
result.put(Constants.DATA_LIST, schedules);
putMsg(result, Status.SUCCESS);
return result;
}
public void setSchedule(int projectId, Schedule schedule) {
logger.info("set schedule, project id: {}, scheduleId: {}", projectId, schedule.getId());
QuartzExecutors.getInstance().addJob(ProcessScheduleJob.class, projectId, schedule);
}
/**
* delete schedule
*
* @param projectId project id
* @param scheduleId schedule id
* @throws RuntimeException runtime exception
*/
@Override
public void deleteSchedule(int projectId, int scheduleId) {
logger.info("delete schedules of project id:{}, schedule id:{}", projectId, scheduleId);
String jobName = QuartzExecutors.buildJobName(scheduleId);
String jobGroupName = QuartzExecutors.buildJobGroupName(projectId);
if (!QuartzExecutors.getInstance().deleteJob(jobName, jobGroupName)) {
logger.warn("set offline failure:projectId:{},scheduleId:{}", projectId, scheduleId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | throw new ServiceException("set offline failure");
}
}
/**
* check valid
*
* @param result result
* @param bool bool
* @param status status
* @return check result code
*/
private boolean checkValid(Map<String, Object> result, boolean bool, Status status) {
if (bool) {
putMsg(result, status);
return true;
}
return false;
}
/**
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param scheduleId scheule id
* @return delete result code
*/
@Override
public Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId) {
Map<String, Object> result = new HashMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Status resultEnum = (Status) checkResult.get(Constants.STATUS);
if (resultEnum != Status.SUCCESS) {
return checkResult;
}
Schedule schedule = scheduleMapper.selectById(scheduleId);
if (schedule == null) {
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, scheduleId);
return result;
}
if (loginUser.getId() != schedule.getUserId()
&& loginUser.getUserType() != UserType.ADMIN_USER) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (schedule.getReleaseState() == ReleaseState.ONLINE) {
putMsg(result, Status.SCHEDULE_CRON_STATE_ONLINE, schedule.getId());
return result;
}
int delete = scheduleMapper.deleteById(scheduleId);
if (delete > 0) {
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR);
}
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | /**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
@Override
public Map<String, Object> previewSchedule(User loginUser, String projectName, String schedule) {
Map<String, Object> result = new HashMap<>();
CronExpression cronExpression;
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);
Date now = new Date();
Date startTime = now.after(scheduleParam.getStartTime()) ? now : scheduleParam.getStartTime();
Date endTime = scheduleParam.getEndTime();
try {
cronExpression = CronUtils.parse2CronExpression(scheduleParam.getCrontab());
} catch (ParseException e) {
logger.error(e.getMessage(), e);
putMsg(result, Status.PARSE_TO_CRON_EXPRESSION_ERROR);
return result;
}
List<Date> selfFireDateList = CronUtils.getSelfFireDateList(startTime, endTime, cronExpression, Constants.PREVIEW_SCHEDULE_EXECUTE_COUNT);
result.put(Constants.DATA_LIST, selfFireDateList.stream().map(DateUtils::dateToString));
putMsg(result, Status.SUCCESS);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller;
import static org.mockito.Mockito.doNothing;
import java.text.MessageFormat;
import java.util.Map;
import org.apache.dolphinscheduler.api.ApiApplicationServer;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.SessionService;
import org.apache.dolphinscheduler.common.Constants; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java | import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.service.registry.RegistryClient;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
/**
* abstract controller test
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class)
public class AbstractControllerTest {
public static final String SESSION_ID = "sessionId";
protected MockMvc mockMvc;
@Autowired
private WebApplicationContext webApplicationContext;
@Autowired
private SessionService sessionService;
protected User user;
protected String sessionId;
@MockBean |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java | RegistryClient registryClient;
@Before
public void setUp() {
doNothing().when(registryClient).init();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
createSession();
}
@After
public void after() throws Exception {
sessionService.signOut("127.0.0.1", user);
}
private void createSession() {
User loginUser = new User();
loginUser.setId(1);
loginUser.setUserType(UserType.GENERAL_USER);
user = loginUser;
String session = sessionService.createSession(loginUser, "127.0.0.1");
sessionId = session;
Assert.assertTrue(StringUtils.isNotEmpty(session));
}
public void putMsg(Map<String, Object> result, Status status, Object... statusParams) {
result.put(Constants.STATUS, status);
if (statusParams != null && statusParams.length > 0) {
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams));
} else {
result.put(Constants.MSG, status.getMsg());
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | import static org.mockito.ArgumentMatchers.isA;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.HashMap;
import java.util.Map;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* scheduler controller test
*/
public class SchedulerControllerTest extends AbstractControllerTest { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | private static Logger logger = LoggerFactory.getLogger(SchedulerControllerTest.class);
@MockBean
private SchedulerService schedulerService;
@Test
public void testCreateSchedule() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("processDefinitionCode","40");
paramsMap.add("schedule","{'startTime':'2019-12-16 00:00:00','endTime':'2019-12-17 00:00:00','crontab':'0 0 6 * * ? *'}");
paramsMap.add("warningType",String.valueOf(WarningType.NONE));
paramsMap.add("warningGroupId","1");
paramsMap.add("failureStrategy",String.valueOf(FailureStrategy.CONTINUE));
paramsMap.add("receivers","");
paramsMap.add("receiversCc","");
paramsMap.add("workerGroupId","1");
paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH));
Map<String, Object> serviceResult = new HashMap<>();
putMsg(serviceResult, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | serviceResult.put(Constants.DATA_LIST, 1);
Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class),
isA(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class),
isA(Priority.class), isA(String.class))).thenReturn(serviceResult);
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateSchedule() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","37");
paramsMap.add("schedule","{'startTime':'2019-12-16 00:00:00','endTime':'2019-12-17 00:00:00','crontab':'0 0 7 * * ? *'}");
paramsMap.add("warningType",String.valueOf(WarningType.NONE));
paramsMap.add("warningGroupId","1");
paramsMap.add("failureStrategy",String.valueOf(FailureStrategy.CONTINUE));
paramsMap.add("receivers","");
paramsMap.add("receiversCc","");
paramsMap.add("workerGroupId","1");
paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH));
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/update","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk()) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testOnline() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","37");
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/online","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testOffline() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","28");
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/offline","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryScheduleListPaging() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("processDefinitionId","40");
paramsMap.add("searchVal","test");
paramsMap.add("pageNo","1");
paramsMap.add("pageSize","30");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/list-paging","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryScheduleList() throws Exception {
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/list","cxc_1113")
.header(SESSION_ID, sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testPreviewSchedule() throws Exception {
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/preview","cxc_1113")
.header(SESSION_ID, sessionId)
.param("schedule","{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testDeleteScheduleById() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("scheduleId","37");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/delete","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.OFFLINE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.PREVIEW_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.PUBLISH_SCHEDULE_ONLINE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_PAGING_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore;
/**
* scheduler controller
*/
@Api(tags = "SCHEDULER_TAG") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | @RestController
@RequestMapping("/projects/{projectCode}/schedule")
public class SchedulerController extends BaseController {
public static final String DEFAULT_WARNING_TYPE = "NONE";
public static final String DEFAULT_NOTIFY_GROUP_ID = "1";
public static final String DEFAULT_FAILURE_POLICY = "CONTINUE";
public static final String DEFAULT_PROCESS_INSTANCE_PRIORITY = "MEDIUM";
@Autowired
private SchedulerService schedulerService;
/**
* create schedule
*
* @param loginUser login user
* @param projectCode project code
* @param processDefinitionCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group
* @return create result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | */
@ApiOperation(value = "createSchedule", notes = "CREATE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "100"),
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String",
example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','timezoneId':'America/Phoenix','crontab':'0 0 3/6 * * ? *'}"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"),
@ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"),
})
@PostMapping("/create")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result createSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "processDefinitionCode") long processDefinitionCode,
@RequestParam(value = "schedule") String schedule,
@RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false, defaultValue = DEFAULT_NOTIFY_GROUP_ID) int warningGroupId,
@RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectCode, processDefinitionCode, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
return returnDataList(result);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * updateProcessInstance schedule
*
* @param loginUser login user
* @param projectCode project code
* @param id scheduler id
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @return update result code
*/
@ApiOperation(value = "updateSchedule", notes = "UPDATE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"),
@ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"),
})
@PostMapping("/update")
@ApiException(UPDATE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "id") Integer id,
@RequestParam(value = "schedule") String schedule, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false) int warningGroupId,
@RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectCode, id, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
return returnDataList(result);
}
/**
* publish schedule setScheduleState
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @return publish result code
*/
@ApiOperation(value = "online", notes = "ONLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@PostMapping("/online")
@ApiException(PUBLISH_SCHEDULE_ONLINE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result online(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam("id") Integer id) {
Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.ONLINE);
return returnDataList(result);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | /**
* offline schedule
*
* @param loginUser login user
* @param projectName project name
* @param id schedule id
* @return operation result code
*/
@ApiOperation(value = "offline", notes = "OFFLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@PostMapping("/offline")
@ApiException(OFFLINE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result offline(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam("id") Integer id) {
Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.OFFLINE);
return returnDataList(result);
}
/**
* query schedule list paging
*
* @param loginUser login user
* @param projectName project name
* @param processDefinitionId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * @return schedule list page
*/
@ApiOperation(value = "queryScheduleListPaging", notes = "QUERY_SCHEDULE_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100")
})
@GetMapping("/list-paging")
@ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryScheduleListPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam Integer processDefinitionId,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return returnDataListPaging(result);
}
searchVal = ParameterUtils.handleEscapes(searchVal);
result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize);
return returnDataListPaging(result);
}
/**
* delete schedule by id
*
* @param loginUser login user |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * @param projectName project name
* @param scheduleId scheule id
* @return delete result code
*/
@ApiOperation(value = "deleteScheduleById", notes = "OFFLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "scheduleId", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/delete")
@ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_SCHEDULE_CRON_BY_ID_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result deleteScheduleById(@RequestAttribute(value = SESSION_USER) User loginUser,
@PathVariable String projectName,
@RequestParam("scheduleId") Integer scheduleId
) {
Map<String, Object> result = schedulerService.deleteScheduleById(loginUser, projectName, scheduleId);
return returnDataList(result);
}
/**
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @return schedule list
*/
@ApiOperation(value = "queryScheduleList", notes = "QUERY_SCHEDULE_LIST_NOTES")
@PostMapping("/list")
@ApiException(QUERY_SCHEDULE_LIST_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName) {
Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectName);
return returnDataList(result);
}
/**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
@ApiOperation(value = "previewSchedule", notes = "PREVIEW_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"),
})
@PostMapping("/preview")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(PREVIEW_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result previewSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam(value = "schedule") String schedule
) {
Map<String, Object> result = schedulerService.previewSchedule(loginUser, projectName, schedule);
return returnDataList(result);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
/**
* scheduler service
*/
public interface SchedulerService { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | /**
* save schedule
*
* @param loginUser login user
* @param projectCode project code
* @param processDefineCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group
* @return create result code
*/
Map<String, Object> insertSchedule(User loginUser,
long projectCode,
long processDefineCode, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | String schedule,
WarningType warningType,
int warningGroupId,
FailureStrategy failureStrategy,
Priority processInstancePriority,
String workerGroup);
/**
* updateProcessInstance schedule
*
* @param loginUser login user
* @param projectCode project code
* @param id scheduler id
* @param scheduleExpression scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @return update result code
*/
Map<String, Object> updateSchedule(User loginUser,
long projectCode,
Integer id,
String scheduleExpression,
WarningType warningType,
int warningGroupId,
FailureStrategy failureStrategy,
Priority processInstancePriority,
String workerGroup);
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | * set schedule online or offline
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param scheduleStatus schedule status
* @return publish result code
*/
Map<String, Object> setScheduleState(User loginUser,
String projectName,
Integer id,
ReleaseState scheduleStatus);
/**
* query schedule
*
* @param loginUser login user
* @param projectName project name
* @param processDefineId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value
* @return schedule list page
*/
Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize);
/**
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @return schedule list |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | */
Map<String, Object> queryScheduleList(User loginUser, String projectName);
/**
* delete schedule
*
* @param projectId project id
* @param scheduleId schedule id
* @throws RuntimeException runtime exception
*/
void deleteSchedule(int projectId, int scheduleId);
/**
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param scheduleId scheule id
* @return delete result code
*/
Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId);
/**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
Map<String, Object> previewSchedule(User loginUser, String projectName, String schedule);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | * The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import org.apache.dolphinscheduler.api.dto.ScheduleParam;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ExecutorService;
import org.apache.dolphinscheduler.api.service.MonitorService;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.model.Server;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.quartz.ProcessScheduleJob;
import org.apache.dolphinscheduler.service.quartz.QuartzExecutors;
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* scheduler service impl
*/
@Service |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerService {
private static final Logger logger = LoggerFactory.getLogger(SchedulerServiceImpl.class);
@Autowired
private ProjectService projectService;
@Autowired
private ExecutorService executorService;
@Autowired
private MonitorService monitorService;
@Autowired
private ProcessService processService;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private ProjectMapper projectMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
/**
* save schedule
*
* @param loginUser login user
* @param projectCode project name
* @param processDefineCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | * @return create result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> insertSchedule(User loginUser,
long projectCode,
long processDefineCode,
String schedule,
WarningType warningType,
int warningGroupId,
FailureStrategy failureStrategy,
Priority processInstancePriority,
String workerGroup) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefineCode);
result = executorService.checkProcessDefinitionValid(processDefinition, processDefineCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
Schedule scheduleObj = new Schedule();
Date now = new Date();
scheduleObj.setProjectName(project.getName());
scheduleObj.setProcessDefinitionId(processDefinition.getId()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | scheduleObj.setProcessDefinitionName(processDefinition.getName());
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);
if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) {
logger.warn("The start time must not be the same as the end");
putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME);
return result;
}
scheduleObj.setStartTime(scheduleParam.getStartTime());
scheduleObj.setEndTime(scheduleParam.getEndTime());
if (!org.quartz.CronExpression.isValidExpression(scheduleParam.getCrontab())) {
logger.error("{} verify failure", scheduleParam.getCrontab());
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, scheduleParam.getCrontab());
return result;
}
scheduleObj.setCrontab(scheduleParam.getCrontab());
scheduleObj.setTimezoneId(scheduleParam.getTimezoneId());
scheduleObj.setWarningType(warningType);
scheduleObj.setWarningGroupId(warningGroupId);
scheduleObj.setFailureStrategy(failureStrategy);
scheduleObj.setCreateTime(now);
scheduleObj.setUpdateTime(now);
scheduleObj.setUserId(loginUser.getId());
scheduleObj.setUserName(loginUser.getUserName());
scheduleObj.setReleaseState(ReleaseState.OFFLINE);
scheduleObj.setProcessInstancePriority(processInstancePriority);
scheduleObj.setWorkerGroup(workerGroup);
scheduleMapper.insert(scheduleObj);
/**
* updateProcessInstance receivers and cc by process definition id
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | processDefinition.setWarningGroupId(warningGroupId);
processDefinitionMapper.updateById(processDefinition);
result.put(Constants.DATA_LIST, scheduleMapper.selectById(scheduleObj.getId()));
putMsg(result, Status.SUCCESS);
result.put("scheduleId", scheduleObj.getId());
return result;
}
/**
* updateProcessInstance schedule
*
* @param loginUser login user
* @param projectCode project code
* @param id scheduler id
* @param scheduleExpression scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @param scheduleStatus schedule status
* @return update result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> updateSchedule(User loginUser,
long projectCode,
Integer id,
String scheduleExpression,
WarningType warningType, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | int warningGroupId,
FailureStrategy failureStrategy,
Priority processInstancePriority,
String workerGroup) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
Schedule schedule = scheduleMapper.selectById(id);
if (schedule == null) {
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, id);
return result;
}
ProcessDefinition processDefinition = processService.findProcessDefineById(schedule.getProcessDefinitionId());
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, schedule.getProcessDefinitionId());
return result;
}
/**
* scheduling on-line status forbid modification
*/
if (checkValid(result, schedule.getReleaseState() == ReleaseState.ONLINE, Status.SCHEDULE_CRON_ONLINE_FORBID_UPDATE)) {
return result;
}
Date now = new Date(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | if (StringUtils.isNotEmpty(scheduleExpression)) {
ScheduleParam scheduleParam = JSONUtils.parseObject(scheduleExpression, ScheduleParam.class);
if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) {
logger.warn("The start time must not be the same as the end");
putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME);
return result;
}
schedule.setStartTime(scheduleParam.getStartTime());
schedule.setEndTime(scheduleParam.getEndTime());
if (!org.quartz.CronExpression.isValidExpression(scheduleParam.getCrontab())) {
putMsg(result, Status.SCHEDULE_CRON_CHECK_FAILED, scheduleParam.getCrontab());
return result;
}
schedule.setCrontab(scheduleParam.getCrontab());
schedule.setTimezoneId(scheduleParam.getTimezoneId());
}
if (warningType != null) {
schedule.setWarningType(warningType);
}
schedule.setWarningGroupId(warningGroupId);
if (failureStrategy != null) {
schedule.setFailureStrategy(failureStrategy);
}
schedule.setWorkerGroup(workerGroup);
schedule.setUpdateTime(now);
schedule.setProcessInstancePriority(processInstancePriority);
scheduleMapper.updateById(schedule);
/**
* updateProcessInstance recipients and cc by process definition ID
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | processDefinition.setWarningGroupId(warningGroupId);
processDefinitionMapper.updateById(processDefinition);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* set schedule online or offline
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param scheduleStatus schedule status
* @return publish result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> setScheduleState(User loginUser,
String projectName,
Integer id,
ReleaseState scheduleStatus) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
Schedule scheduleObj = scheduleMapper.selectById(id);
if (scheduleObj == null) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, id);
return result;
}
if (scheduleObj.getReleaseState() == scheduleStatus) {
logger.info("schedule release is already {},needn't to change schedule id: {} from {} to {}",
scheduleObj.getReleaseState(), scheduleObj.getId(), scheduleObj.getReleaseState(), scheduleStatus);
putMsg(result, Status.SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE, scheduleStatus);
return result;
}
ProcessDefinition processDefinition = processService.findProcessDefineById(scheduleObj.getProcessDefinitionId());
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, scheduleObj.getProcessDefinitionId());
return result;
}
if (scheduleStatus == ReleaseState.ONLINE) {
if (processDefinition.getReleaseState() != ReleaseState.ONLINE) {
logger.info("not release process definition id: {} , name : {}",
processDefinition.getId(), processDefinition.getName());
putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinition.getName());
return result;
}
List<Integer> subProcessDefineIds = new ArrayList<>();
processService.recurseFindSubProcessId(scheduleObj.getProcessDefinitionId(), subProcessDefineIds);
Integer[] idArray = subProcessDefineIds.toArray(new Integer[subProcessDefineIds.size()]);
if (!subProcessDefineIds.isEmpty()) {
List<ProcessDefinition> subProcessDefinitionList =
processDefinitionMapper.queryDefinitionListByIdList(idArray); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | if (subProcessDefinitionList != null && !subProcessDefinitionList.isEmpty()) {
for (ProcessDefinition subProcessDefinition : subProcessDefinitionList) {
/**
* if there is no online process, exit directly
*/
if (subProcessDefinition.getReleaseState() != ReleaseState.ONLINE) {
logger.info("not release process definition id: {} , name : {}",
subProcessDefinition.getId(), subProcessDefinition.getName());
putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, subProcessDefinition.getId());
return result;
}
}
}
}
}
List<Server> masterServers = monitorService.getServerListFromRegistry(true);
if (masterServers.isEmpty()) {
putMsg(result, Status.MASTER_NOT_EXISTS);
return result;
}
scheduleObj.setReleaseState(scheduleStatus);
scheduleMapper.updateById(scheduleObj);
try {
switch (scheduleStatus) {
case ONLINE:
logger.info("Call master client set schedule online, project id: {}, flow id: {},host: {}", project.getId(), processDefinition.getId(), masterServers);
setSchedule(project.getId(), scheduleObj);
break; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | case OFFLINE:
logger.info("Call master client set schedule offline, project id: {}, flow id: {},host: {}", project.getId(), processDefinition.getId(), masterServers);
deleteSchedule(project.getId(), id);
break;
default:
putMsg(result, Status.SCHEDULE_STATUS_UNKNOWN, scheduleStatus.toString());
return result;
}
} catch (Exception e) {
result.put(Constants.MSG, scheduleStatus == ReleaseState.ONLINE ? "set online failure" : "set offline failure");
throw new ServiceException(result.get(Constants.MSG).toString());
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query schedule
*
* @param loginUser login user
* @param projectName project name
* @param processDefineId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value
* @return schedule list page
*/
@Override
public Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize) {
HashMap<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
ProcessDefinition processDefinition = processService.findProcessDefineById(processDefineId);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineId);
return result;
}
Page<Schedule> page = new Page<>(pageNo, pageSize);
IPage<Schedule> scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging(
page, processDefineId, searchVal
);
PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int) scheduleIPage.getTotal());
pageInfo.setLists(scheduleIPage.getRecords());
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @return schedule list
*/
@Override
public Map<String, Object> queryScheduleList(User loginUser, String projectName) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) {
return result;
}
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(projectName);
result.put(Constants.DATA_LIST, schedules);
putMsg(result, Status.SUCCESS);
return result;
}
public void setSchedule(int projectId, Schedule schedule) {
logger.info("set schedule, project id: {}, scheduleId: {}", projectId, schedule.getId());
QuartzExecutors.getInstance().addJob(ProcessScheduleJob.class, projectId, schedule);
}
/**
* delete schedule
*
* @param projectId project id
* @param scheduleId schedule id
* @throws RuntimeException runtime exception
*/
@Override
public void deleteSchedule(int projectId, int scheduleId) {
logger.info("delete schedules of project id:{}, schedule id:{}", projectId, scheduleId);
String jobName = QuartzExecutors.buildJobName(scheduleId);
String jobGroupName = QuartzExecutors.buildJobGroupName(projectId);
if (!QuartzExecutors.getInstance().deleteJob(jobName, jobGroupName)) {
logger.warn("set offline failure:projectId:{},scheduleId:{}", projectId, scheduleId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | throw new ServiceException("set offline failure");
}
}
/**
* check valid
*
* @param result result
* @param bool bool
* @param status status
* @return check result code
*/
private boolean checkValid(Map<String, Object> result, boolean bool, Status status) {
if (bool) {
putMsg(result, status);
return true;
}
return false;
}
/**
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param scheduleId scheule id
* @return delete result code
*/
@Override
public Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId) {
Map<String, Object> result = new HashMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Status resultEnum = (Status) checkResult.get(Constants.STATUS);
if (resultEnum != Status.SUCCESS) {
return checkResult;
}
Schedule schedule = scheduleMapper.selectById(scheduleId);
if (schedule == null) {
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, scheduleId);
return result;
}
if (loginUser.getId() != schedule.getUserId()
&& loginUser.getUserType() != UserType.ADMIN_USER) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (schedule.getReleaseState() == ReleaseState.ONLINE) {
putMsg(result, Status.SCHEDULE_CRON_STATE_ONLINE, schedule.getId());
return result;
}
int delete = scheduleMapper.deleteById(scheduleId);
if (delete > 0) {
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR);
}
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java | /**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
@Override
public Map<String, Object> previewSchedule(User loginUser, String projectName, String schedule) {
Map<String, Object> result = new HashMap<>();
CronExpression cronExpression;
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);
Date now = new Date();
Date startTime = now.after(scheduleParam.getStartTime()) ? now : scheduleParam.getStartTime();
Date endTime = scheduleParam.getEndTime();
try {
cronExpression = CronUtils.parse2CronExpression(scheduleParam.getCrontab());
} catch (ParseException e) {
logger.error(e.getMessage(), e);
putMsg(result, Status.PARSE_TO_CRON_EXPRESSION_ERROR);
return result;
}
List<Date> selfFireDateList = CronUtils.getSelfFireDateList(startTime, endTime, cronExpression, Constants.PREVIEW_SCHEDULE_EXECUTE_COUNT);
result.put(Constants.DATA_LIST, selfFireDateList.stream().map(DateUtils::dateToString));
putMsg(result, Status.SUCCESS);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | * limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller;
import static org.mockito.ArgumentMatchers.isA;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* scheduler controller test
*/
public class SchedulerControllerTest extends AbstractControllerTest { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | private static Logger logger = LoggerFactory.getLogger(SchedulerControllerTest.class);
@MockBean
private SchedulerService schedulerService;
@Test
public void testCreateSchedule() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("processDefinitionCode","40");
paramsMap.add("schedule","{'startTime':'2019-12-16 00:00:00','endTime':'2019-12-17 00:00:00','crontab':'0 0 6 * * ? *'}");
paramsMap.add("warningType",String.valueOf(WarningType.NONE));
paramsMap.add("warningGroupId","1");
paramsMap.add("failureStrategy",String.valueOf(FailureStrategy.CONTINUE));
paramsMap.add("receivers","");
paramsMap.add("receiversCc","");
paramsMap.add("workerGroupId","1");
paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH));
Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class),
isA(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class), |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | isA(Priority.class), isA(String.class))).thenReturn(successResult());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateSchedule() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","37");
paramsMap.add("schedule","{'startTime':'2019-12-16 00:00:00','endTime':'2019-12-17 00:00:00','crontab':'0 0 7 * * ? *'}");
paramsMap.add("warningType",String.valueOf(WarningType.NONE));
paramsMap.add("warningGroupId","1");
paramsMap.add("failureStrategy",String.valueOf(FailureStrategy.CONTINUE));
paramsMap.add("receivers","");
paramsMap.add("receiversCc","");
paramsMap.add("workerGroupId","1");
paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH));
Mockito.when(schedulerService.updateSchedule(isA(User.class), isA(Long.class), isA(Integer.class),
isA(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class),
isA(Priority.class), isA(String.class))).thenReturn(successResult());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk()) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testOnline() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","37");
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/online","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testOffline() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","28");
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/offline","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryScheduleListPaging() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("processDefinitionId","40");
paramsMap.add("searchVal","test");
paramsMap.add("pageNo","1");
paramsMap.add("pageSize","30");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/list-paging","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryScheduleList() throws Exception {
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/list","cxc_1113")
.header(SESSION_ID, sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java | logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testPreviewSchedule() throws Exception {
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/preview","cxc_1113")
.header(SESSION_ID, sessionId)
.param("schedule","{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testDeleteScheduleById() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("scheduleId","37");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/delete","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
import org.apache.dolphinscheduler.api.service.impl.SchedulerServiceImpl;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.model.Server;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java | import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.quartz.QuartzExecutors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
/**
* scheduler service test
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(QuartzExecutors.class)
public class SchedulerServiceTest {
@InjectMocks
private SchedulerServiceImpl schedulerService;
@Mock |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java | private MonitorService monitorService;
@Mock
private ProcessService processService;
@Mock
private ScheduleMapper scheduleMapper;
@Mock
private ProjectMapper projectMapper;
@Mock
private ProjectServiceImpl projectService;
@Mock
private QuartzExecutors quartzExecutors;
@Before
public void setUp() {
quartzExecutors = PowerMockito.mock(QuartzExecutors.class);
PowerMockito.mockStatic(QuartzExecutors.class);
try {
PowerMockito.doReturn(quartzExecutors).when(QuartzExecutors.class, "getInstance");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testSetScheduleState() {
String projectName = "test";
User loginUser = new User();
loginUser.setId(1);
Map<String, Object> result = new HashMap<String, Object>();
Project project = getProject(projectName);
ProcessDefinition processDefinition = new ProcessDefinition();
Schedule schedule = new Schedule(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java | schedule.setId(1);
schedule.setProcessDefinitionId(1);
schedule.setReleaseState(ReleaseState.OFFLINE);
List<Server> masterServers = new ArrayList<>();
masterServers.add(new Server());
Mockito.when(scheduleMapper.selectById(1)).thenReturn(schedule);
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project);
Mockito.when(processService.findProcessDefineById(1)).thenReturn(processDefinition);
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.ONLINE);
Mockito.when(projectService.hasProjectAndPerm(loginUser, project, result)).thenReturn(true);
result = schedulerService.setScheduleState(loginUser, projectName, 2, ReleaseState.ONLINE);
Assert.assertEquals(Status.SCHEDULE_CRON_NOT_EXISTS, result.get(Constants.STATUS));
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.OFFLINE);
Assert.assertEquals(Status.SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE, result.get(Constants.STATUS));
schedule.setProcessDefinitionId(2);
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.ONLINE);
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, result.get(Constants.STATUS));
schedule.setProcessDefinitionId(1);
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.ONLINE);
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_RELEASE, result.get(Constants.STATUS));
processDefinition.setReleaseState(ReleaseState.ONLINE);
Mockito.when(processService.findProcessDefineById(1)).thenReturn(processDefinition);
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.ONLINE);
Assert.assertEquals(Status.MASTER_NOT_EXISTS, result.get(Constants.STATUS)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,763 | [Feature][JsonSplit-api]schedule online/offline interface | from #5498
Change the request parameter projectName to projectCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5763 | https://github.com/apache/dolphinscheduler/pull/5764 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | e4f427a8d8bf99754698e054845291a5223c2ea6 | "2021-07-07T11:37:00Z" | java | "2021-07-08T05:59:40Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java | Mockito.when(monitorService.getServerListFromRegistry(true)).thenReturn(masterServers);
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.ONLINE);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
Mockito.when(quartzExecutors.deleteJob(null, null)).thenReturn(true);
result = schedulerService.setScheduleState(loginUser, projectName, 1, ReleaseState.OFFLINE);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testDeleteSchedule() {
Mockito.when(quartzExecutors.deleteJob("1", "1")).thenReturn(true);
Mockito.when(quartzExecutors.buildJobGroupName(1)).thenReturn("1");
Mockito.when(quartzExecutors.buildJobName(1)).thenReturn("1");
boolean flag = true;
try {
schedulerService.deleteSchedule(1, 1);
} catch (Exception e) {
flag = false;
}
Assert.assertTrue(flag);
}
private Project getProject(String name) {
Project project = new Project();
project.setName(name);
project.setUserId(1);
return project;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.server.worker.task;
import static org.apache.dolphinscheduler.common.Constants.EXIT_CODE_FAILURE;
import static org.apache.dolphinscheduler.common.Constants.EXIT_CODE_KILL;
import static org.apache.dolphinscheduler.common.Constants.EXIT_CODE_SUCCESS;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.CommonUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext;
import org.apache.dolphinscheduler.server.utils.ProcessUtils;
import org.apache.dolphinscheduler.server.worker.cache.TaskExecutionContextCacheManager;
import org.apache.dolphinscheduler.server.worker.cache.impl.TaskExecutionContextCacheManagerImpl;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
/**
* abstract command executor
*/
public abstract class AbstractCommandExecutor { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | /**
* rules for extracting application ID
*/
protected static final Pattern APPLICATION_REGEX = Pattern.compile(Constants.APPLICATION_REGEX);
protected StringBuilder varPool = new StringBuilder();
/**
* process
*/
private Process process;
/**
* log handler
*/
protected Consumer<List<String>> logHandler;
/**
* logger
*/
protected Logger logger;
/**
* log list
*/
protected final List<String> logBuffer;
protected boolean logOutputIsScuccess = false;
/**
* taskExecutionContext
*/
protected TaskExecutionContext taskExecutionContext;
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | * taskExecutionContextCacheManager
*/
private TaskExecutionContextCacheManager taskExecutionContextCacheManager;
public AbstractCommandExecutor(Consumer<List<String>> logHandler,
TaskExecutionContext taskExecutionContext,
Logger logger) {
this.logHandler = logHandler;
this.taskExecutionContext = taskExecutionContext;
this.logger = logger;
this.logBuffer = Collections.synchronizedList(new ArrayList<>());
this.taskExecutionContextCacheManager = SpringApplicationContext.getBean(TaskExecutionContextCacheManagerImpl.class);
}
protected AbstractCommandExecutor(List<String> logBuffer) {
this.logBuffer = logBuffer;
}
/**
* build process
*
* @param commandFile command file
* @throws IOException IO Exception
*/
private void buildProcess(String commandFile) throws IOException {
List<String> command = new LinkedList<>();
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.directory(new File(taskExecutionContext.getExecutePath()));
processBuilder.redirectErrorStream(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | if (!OSUtils.isWindows() && CommonUtils.isSudoEnable()) {
command.add("sudo");
command.add("-u");
command.add(taskExecutionContext.getTenantCode());
}
command.add(commandInterpreter());
command.addAll(commandOptions());
command.add(commandFile);
processBuilder.command(command);
process = processBuilder.start();
printCommand(command);
}
/**
* task specific execution logic
*
* @param execCommand execCommand
* @return CommandExecuteResult
* @throws Exception if error throws Exception
*/
public CommandExecuteResult run(String execCommand) throws Exception {
CommandExecuteResult result = new CommandExecuteResult();
int taskInstanceId = taskExecutionContext.getTaskInstanceId();
if (null == taskExecutionContextCacheManager.getByTaskInstanceId(taskInstanceId)) {
result.setExitStatusCode(EXIT_CODE_KILL);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | if (StringUtils.isEmpty(execCommand)) {
taskExecutionContextCacheManager.removeByTaskInstanceId(taskInstanceId);
return result;
}
String commandFilePath = buildCommandFilePath();
createCommandFileIfNotExists(execCommand, commandFilePath);
buildProcess(commandFilePath);
parseProcessOutput(process);
Integer processId = getProcessId(process);
result.setProcessId(processId);
taskExecutionContext.setProcessId(processId);
boolean updateTaskExecutionContextStatus = taskExecutionContextCacheManager.updateTaskExecutionContext(taskExecutionContext);
if (Boolean.FALSE.equals(updateTaskExecutionContextStatus)) {
ProcessUtils.kill(taskExecutionContext);
result.setExitStatusCode(EXIT_CODE_KILL);
return result;
}
logger.info("process start, process id is: {}", processId);
long remainTime = getRemaintime();
boolean status = process.waitFor(remainTime, TimeUnit.SECONDS);
logger.info("process has exited, execute path:{}, processId:{} ,exitStatusCode:{} ,processWaitForStatus:{} ,processExitValue:{}",
taskExecutionContext.getExecutePath(), processId, result.getExitStatusCode(), status, process.exitValue()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | if (status) {
List<String> appIds = getAppIds(taskExecutionContext.getLogPath());
result.setAppIds(String.join(Constants.COMMA, appIds));
result.setExitStatusCode(process.exitValue());
if (process.exitValue() == 0) {
result.setExitStatusCode(isSuccessOfYarnState(appIds) ? EXIT_CODE_SUCCESS : EXIT_CODE_FAILURE);
}
} else {
logger.error("process has failure , exitStatusCode:{}, processExitValue:{}, ready to kill ...",
result.getExitStatusCode(), process.exitValue());
ProcessUtils.kill(taskExecutionContext);
result.setExitStatusCode(EXIT_CODE_FAILURE);
}
return result;
}
public String getVarPool() {
return varPool.toString();
}
/**
* cancel application
*
* @throws Exception exception
*/
public void cancelApplication() throws Exception {
if (process == null) {
return;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | clear();
int processId = getProcessId(process);
logger.info("cancel process: {}", processId);
boolean killed = softKill(processId);
if (!killed) {
hardKill(processId);
process.destroy();
process = null;
}
}
/**
* soft kill
*
* @param processId process id
* @return process is alive
* @throws InterruptedException interrupted exception
*/
private boolean softKill(int processId) {
if (processId != 0 && process.isAlive()) {
try {
String cmd = String.format("kill %d", processId);
cmd = OSUtils.getSudoCmd(taskExecutionContext.getTenantCode(), cmd);
logger.info("soft kill task:{}, process id:{}, cmd:{}", taskExecutionContext.getTaskAppId(), processId, cmd);
Runtime.getRuntime().exec(cmd);
} catch (IOException e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | logger.info("kill attempt failed", e);
}
}
return !process.isAlive();
}
/**
* hard kill
*
* @param processId process id
*/
private void hardKill(int processId) {
if (processId != 0 && process.isAlive()) {
try {
String cmd = String.format("kill -9 %d", processId);
cmd = OSUtils.getSudoCmd(taskExecutionContext.getTenantCode(), cmd);
logger.info("hard kill task:{}, process id:{}, cmd:{}", taskExecutionContext.getTaskAppId(), processId, cmd);
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
logger.error("kill attempt failed ", e);
}
}
}
/**
* print command
*
* @param commands process builder
*/
private void printCommand(List<String> commands) {
String cmdStr;
try { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | cmdStr = ProcessUtils.buildCommandStr(commands);
logger.info("task run command:\n{}", cmdStr);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
/**
* clear
*/
private void clear() {
List<String> markerList = new ArrayList<>();
markerList.add(ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER.toString());
if (!logBuffer.isEmpty()) {
logHandler.accept(logBuffer);
logBuffer.clear();
}
logHandler.accept(markerList);
}
/**
* get the standard output of the process
*
* @param process process
*/
private void parseProcessOutput(Process process) {
String threadLoggerInfoName = String.format(LoggerUtils.TASK_LOGGER_THREAD_NAME + "-%s", taskExecutionContext.getTaskAppId());
ExecutorService getOutputLogService = ThreadUtils.newDaemonSingleThreadExecutor(threadLoggerInfoName + "-" + "getOutputLogService");
getOutputLogService.submit(() -> {
BufferedReader inReader = null;
try { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | inReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
logBuffer.add("welcome to use bigdata scheduling system...");
while ((line = inReader.readLine()) != null) {
if (line.startsWith("${setValue(")) {
varPool.append(line.substring("${setValue(".length(), line.length() - 2));
varPool.append("$VarPool$");
} else {
logBuffer.add(line);
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
logOutputIsScuccess = true;
close(inReader);
}
});
getOutputLogService.shutdown();
ExecutorService parseProcessOutputExecutorService = ThreadUtils.newDaemonSingleThreadExecutor(threadLoggerInfoName);
parseProcessOutputExecutorService.submit(() -> {
try {
long lastFlushTime = System.currentTimeMillis();
while (logBuffer.size() > 0 || !logOutputIsScuccess) {
if (logBuffer.size() > 0) {
lastFlushTime = flush(lastFlushTime);
} else {
Thread.sleep(Constants.DEFAULT_LOG_FLUSH_INTERVAL);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | } catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
clear();
}
});
parseProcessOutputExecutorService.shutdown();
}
/**
* check yarn state
*
* @param appIds application id list
* @return is success of yarn task state
*/
public boolean isSuccessOfYarnState(List<String> appIds) {
boolean result = true;
try {
for (String appId : appIds) {
logger.info("check yarn application status, appId:{}", appId);
while (Stopper.isRunning()) {
ExecutionStatus applicationStatus = HadoopUtils.getInstance().getApplicationStatus(appId);
if (logger.isDebugEnabled()) {
logger.debug("check yarn application status, appId:{}, final state:{}", appId, applicationStatus.name());
}
if (applicationStatus.equals(ExecutionStatus.FAILURE)
|| applicationStatus.equals(ExecutionStatus.KILL)) {
return false;
}
if (applicationStatus.equals(ExecutionStatus.SUCCESS)) {
break; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | }
ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS);
}
}
} catch (Exception e) {
logger.error("yarn applications: {} , query status failed, exception:{}", StringUtils.join(appIds, ","), e);
result = false;
}
return result;
}
public int getProcessId() {
return getProcessId(process);
}
/**
* get app links
*
* @param logPath log path
* @return app id list
*/
private List<String> getAppIds(String logPath) {
List<String> logs = convertFile2List(logPath);
List<String> appIds = new ArrayList<>();
/**
* analysis log?get submited yarn application id
*/
for (String log : logs) {
String appId = findAppId(log);
if (StringUtils.isNotEmpty(appId) && !appIds.contains(appId)) {
logger.info("find app id: {}", appId);
appIds.add(appId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | }
}
return appIds;
}
/**
* convert file to list
*
* @param filename file name
* @return line list
*/
private List<String> convertFile2List(String filename) {
List lineList = new ArrayList<String>(100);
File file = new File(filename);
if (!file.exists()) {
return lineList;
}
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), StandardCharsets.UTF_8));
String line = null;
while ((line = br.readLine()) != null) {
lineList.add(line);
}
} catch (Exception e) {
logger.error(String.format("read file: %s failed : ", filename), e);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | logger.error(e.getMessage(), e);
}
}
}
return lineList;
}
/**
* find app id
*
* @param line line
* @return appid
*/
private String findAppId(String line) {
Matcher matcher = APPLICATION_REGEX.matcher(line);
if (matcher.find()) {
return matcher.group();
}
return null;
}
/**
* get remain time(s)
*
* @return remain time
*/
private long getRemaintime() {
long usedTime = (System.currentTimeMillis() - taskExecutionContext.getStartTime().getTime()) / 1000;
long remainTime = taskExecutionContext.getTaskTimeout() - usedTime;
if (remainTime < 0) {
throw new RuntimeException("task execution time out");
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | return remainTime;
}
/**
* get process id
*
* @param process process
* @return process id
*/
private int getProcessId(Process process) {
int processId = 0;
try {
Field f = process.getClass().getDeclaredField(Constants.PID);
f.setAccessible(true);
processId = f.getInt(process);
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
return processId;
}
/**
* when log buffer siz or flush time reach condition , then flush
*
* @param lastFlushTime last flush time
* @return last flush time
*/
private long flush(long lastFlushTime) {
long now = System.currentTimeMillis();
/**
* when log buffer siz or flush time reach condition , then flush
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,741 | [Improvement][Worker] Improve task process status log | **Describe the question**
In the AbstractCommandExecutor, after the task process executed, it will log the status.
We need to move the log from line 206 to line 227, the `result.getExitStatusCode()` is always 0, because we did not assign value.
https://github.com/apache/dolphinscheduler/blob/2ba569acd028c00c22f4853de7c58251ac72816c/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java#L157-L206
**Which version of DolphinScheduler:**
-[1.3.6]
-[dev]
| https://github.com/apache/dolphinscheduler/issues/5741 | https://github.com/apache/dolphinscheduler/pull/5776 | b114d330ac1fa7de27e09cc73c0804a7536f3b28 | ab527a5e5abd04243305a50f184d8009b9edf21a | "2021-07-03T08:43:03Z" | java | "2021-07-08T16:28:00Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java | if (logBuffer.size() >= Constants.DEFAULT_LOG_ROWS_NUM || now - lastFlushTime > Constants.DEFAULT_LOG_FLUSH_INTERVAL) {
lastFlushTime = now;
/**
logHandler.accept(logBuffer);
logBuffer.clear();
}
return lastFlushTime;
}
/**
* close buffer reader
*
* @param inReader in reader
*/
private void close(BufferedReader inReader) {
if (inReader != null) {
try {
inReader.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
}
protected List<String> commandOptions() {
return Collections.emptyList();
}
protected abstract String buildCommandFilePath();
protected abstract String commandInterpreter();
protected abstract void createCommandFileIfNotExists(String execCommand, String commandFile) throws IOException;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.OFFLINE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.PREVIEW_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.PUBLISH_SCHEDULE_ONLINE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_PAGING_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore;
/**
* scheduler controller
*/
@Api(tags = "SCHEDULER_TAG") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | @RestController
@RequestMapping("/projects/{projectCode}/schedule")
public class SchedulerController extends BaseController {
public static final String DEFAULT_WARNING_TYPE = "NONE";
public static final String DEFAULT_NOTIFY_GROUP_ID = "1";
public static final String DEFAULT_FAILURE_POLICY = "CONTINUE";
public static final String DEFAULT_PROCESS_INSTANCE_PRIORITY = "MEDIUM";
@Autowired
private SchedulerService schedulerService;
/**
* create schedule
*
* @param loginUser login user
* @param projectCode project code
* @param processDefinitionCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group
* @return create result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | */
@ApiOperation(value = "createSchedule", notes = "CREATE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "100"),
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String",
example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','timezoneId':'America/Phoenix','crontab':'0 0 3/6 * * ? *'}"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"),
@ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"),
})
@PostMapping("/create")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result createSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "processDefinitionCode") long processDefinitionCode,
@RequestParam(value = "schedule") String schedule,
@RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false, defaultValue = DEFAULT_NOTIFY_GROUP_ID) int warningGroupId,
@RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectCode, processDefinitionCode, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
return returnDataList(result);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * updateProcessInstance schedule
*
* @param loginUser login user
* @param projectCode project code
* @param id scheduler id
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @return update result code
*/
@ApiOperation(value = "updateSchedule", notes = "UPDATE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"),
@ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"),
})
@PostMapping("/update")
@ApiException(UPDATE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "id") Integer id,
@RequestParam(value = "schedule") String schedule, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false) int warningGroupId,
@RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectCode, id, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
return returnDataList(result);
}
/**
* publish schedule setScheduleState
*
* @param loginUser login user
* @param projectCode project code
* @param id scheduler id
* @return publish result code
*/
@ApiOperation(value = "online", notes = "ONLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@PostMapping("/online")
@ApiException(PUBLISH_SCHEDULE_ONLINE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result online(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam("id") Integer id) {
Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectCode, id, ReleaseState.ONLINE);
return returnDataList(result);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | /**
* offline schedule
*
* @param loginUser login user
* @param projectCode project code
* @param id schedule id
* @return operation result code
*/
@ApiOperation(value = "offline", notes = "OFFLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@PostMapping("/offline")
@ApiException(OFFLINE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result offline(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam("id") Integer id) {
Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectCode, id, ReleaseState.OFFLINE);
return returnDataList(result);
}
/**
* query schedule list paging
*
* @param loginUser login user
* @param projectName project name
* @param processDefinitionId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,510 | [Feature][JsonSplit-api]schedule list-paging interface | from #5498
Change the request parameter processDefinitionId to processDefinitionCode,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5510 | https://github.com/apache/dolphinscheduler/pull/5771 | e4f427a8d8bf99754698e054845291a5223c2ea6 | 72535a47e3dafc68c457996ea6e01b8da17685aa | "2021-05-18T13:57:34Z" | java | "2021-07-09T02:13:00Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * @return schedule list page
*/
@ApiOperation(value = "queryScheduleListPaging", notes = "QUERY_SCHEDULE_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100")
})
@GetMapping("/list-paging")
@ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryScheduleListPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam Integer processDefinitionId,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return returnDataListPaging(result);
}
searchVal = ParameterUtils.handleEscapes(searchVal);
result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize);
return returnDataListPaging(result);
}
/**
* delete schedule by id
*
* @param loginUser login user |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.