Exemple #1
0
 @Override
 public void updateJob(String user, JobDescriptor job) throws ZeusException {
   JobPersistence orgPersist =
       (JobPersistence)
           getHibernateTemplate().get(JobPersistence.class, Long.valueOf(job.getId()));
   updateJob(user, job, orgPersist.getOwner(), orgPersist.getGroupId().toString());
 }
Exemple #2
0
  @Override
  public void updateJobStatus(JobStatus jobStatus) {
    JobPersistence persistence = getJobPersistence(jobStatus.getJobId());
    persistence.setGmtModified(new Date());

    // 只修改状态 和 依赖 2个字段
    JobPersistence temp = PersistenceAndBeanConvert.convert(jobStatus);
    persistence.setStatus(temp.getStatus());
    persistence.setReadyDependency(temp.getReadyDependency());
    persistence.setHistoryId(temp.getHistoryId());

    getHibernateTemplate().update(persistence);
  }
Exemple #3
0
 @Override
 public JobDescriptor createJob(
     String user, String jobName, String parentGroup, JobRunType jobType) throws ZeusException {
   GroupDescriptor parent = getGroupDescriptor(parentGroup);
   if (parent.isDirectory()) {
     throw new ZeusException("目录组下不得创建Job");
   }
   JobDescriptor job = new JobDescriptor();
   job.setOwner(user);
   job.setName(jobName);
   job.setGroupId(parentGroup);
   job.setJobType(jobType);
   job.setPreProcessers(Arrays.asList((Processer) new DownloadProcesser()));
   JobPersistence persist = PersistenceAndBeanConvert.convert(job);
   persist.setGmtCreate(new Date());
   persist.setGmtModified(new Date());
   getHibernateTemplate().save(persist);
   return PersistenceAndBeanConvert.convert(persist).getX();
 }
Exemple #4
0
 @Override
 public Tuple<JobDescriptor, JobStatus> getJobDescriptor(String jobId) {
   JobPersistence persist = getJobPersistence(jobId);
   if (persist == null) {
     return null;
   }
   Tuple<JobDescriptor, JobStatus> t = PersistenceAndBeanConvert.convert(persist);
   JobDescriptor jd = t.getX();
   // 如果是周期任务,并且依赖不为空,则需要封装周期任务的依赖
   if (jd.getScheduleType() == JobScheduleType.CyleJob && jd.getDependencies() != null) {
     JobPersistence jp = null;
     for (String jobID : jd.getDependencies()) {
       if (StringUtils.isNotEmpty(jobID)) {
         jp = getJobPersistence(jobID);
         if (jp != null) {
           jd.getDepdCycleJob().put(jobID, jp.getCycle());
         }
       }
     }
   }
   return t;
 }
Exemple #5
0
  public void updateJob(String user, JobDescriptor job, String owner, String groupId)
      throws ZeusException {
    JobPersistence orgPersist =
        (JobPersistence)
            getHibernateTemplate().get(JobPersistence.class, Long.valueOf(job.getId()));
    if (job.getScheduleType() == JobScheduleType.Independent) {
      job.setDependencies(new ArrayList<String>());
    } else if (job.getScheduleType() == JobScheduleType.Dependent) {
      job.setCronExpression("");
    }
    job.setOwner(owner);
    job.setGroupId(groupId);
    // 以下属性不允许修改,强制采用老的数据
    JobPersistence persist = PersistenceAndBeanConvert.convert(job);
    persist.setGmtCreate(orgPersist.getGmtCreate());
    persist.setGmtModified(new Date());
    persist.setRunType(orgPersist.getRunType());
    persist.setStatus(orgPersist.getStatus());
    persist.setReadyDependency(orgPersist.getReadyDependency());
    persist.setHost(job.getHost());
    // 如果是用户从界面上更新,开始时间、统计周期等均为空,用原来的值
    if (job.getStartTime() == null || "".equals(job.getStartTime())) {
      persist.setStartTime(orgPersist.getStartTime());
    }
    if (job.getStartTimestamp() == 0) {
      persist.setStartTimestamp(orgPersist.getStartTimestamp());
    }
    if (job.getStatisStartTime() == null || "".equals(job.getStatisStartTime())) {
      persist.setStatisStartTime(orgPersist.getStatisStartTime());
    }
    if (job.getStatisEndTime() == null || "".equals(job.getStatisEndTime())) {
      persist.setStatisEndTime(orgPersist.getStatisEndTime());
    }

    // 如果是周期任务,则许检查依赖周期是否正确
    if (job.getScheduleType().equals(JobScheduleType.CyleJob)
        && job.getDependencies() != null
        && job.getDependencies().size() != 0) {
      List<JobDescriptor> list = this.getJobDescriptors(job.getDependencies());
      jobValidate.checkCycleJob(job, list);
    }

    if (jobValidate.valide(job)) {
      getHibernateTemplate().update(persist);
    }
  }
  public void updateJob(String user, JobDescriptor job, String owner, String groupId)
      throws ZeusException {
    JobPersistence orgPersist =
        (JobPersistence)
            getHibernateTemplate().get(JobPersistence.class, Long.valueOf(job.getId()));
    if (job.getScheduleType() == JobScheduleType.Independent) {
      job.setDependencies(new ArrayList<String>());
    } else if (job.getScheduleType() == JobScheduleType.Dependent) {
      job.setCronExpression("");
    }
    job.setOwner(owner);
    job.setGroupId(groupId);
    // 以下属性不允许修改,强制采用老的数据
    JobPersistence persist = PersistenceAndBeanConvert.convert(job);
    persist.setGmtCreate(orgPersist.getGmtCreate());
    persist.setGmtModified(new Date());
    persist.setRunType(orgPersist.getRunType());
    persist.setStatus(orgPersist.getStatus());
    persist.setReadyDependency(orgPersist.getReadyDependency());

    if (jobValidate.valide(job)) {
      getHibernateTemplate().update(persist);
    }
  }