Unverified Commit a221ec0a authored by lgcareer's avatar lgcareer Committed by GitHub
Browse files

Merge pull request #322 from lgcareer/branch-1.0.2

 add checkExists in deleteJob
parents e171234f 12d36760
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import org.quartz.impl.matchers.GroupMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Calendar;
import java.util.*;
import java.util.Calendar;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

@@ -226,8 +226,12 @@ public class QuartzExecutors {
  public boolean deleteJob(String jobName, String jobGroupName) {
    lock.writeLock().lock();
    try {
      JobKey jobKey = new JobKey(jobName,jobGroupName);
      if(scheduler.checkExists(jobKey)){
        logger.info("try to delete job, job name: {}, job group name: {},", jobName, jobGroupName);
      return scheduler.deleteJob(new JobKey(jobName, jobGroupName));
        return scheduler.deleteJob(jobKey);
      }

    } catch (SchedulerException e) {
      logger.error(String.format("delete job : %s failed",jobName), e);
    } finally {
+7 −0
Original line number Diff line number Diff line
@@ -514,6 +514,13 @@ public class SchedulerService extends BaseService {
            putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, scheduleId);
            return result;
        }

        // Determine if the login user is the owner of the schedule
        if (loginUser.getId() != schedule.getUserId()) {
            putMsg(result, Status.USER_NO_OPERATION_PERM);
            return result;
        }

        // check schedule is already online
        if(schedule.getReleaseState() == ReleaseState.ONLINE){
            putMsg(result, Status.SCHEDULE_CRON_STATE_ONLINE,schedule.getId());