Package com.taobao.zeus.store.mysql.persistence

Examples of com.taobao.zeus.store.mysql.persistence.JobPersistence


 
  public static JobPersistence convert(Tuple<JobDescriptor, JobStatus> job){
    if(job==null){
      return null;
    }
    JobPersistence persist=convert(job.getX());
    JobPersistence p2=convert(job.getY());
    persist.setReadyDependency(p2.getReadyDependency());
    persist.setStatus(p2.getStatus());
    persist.setHistoryId(p2.getHistoryId());
    return persist;
  }
View Full Code Here


 
  public static JobPersistence convert(JobStatus jobStatus){
    if(jobStatus==null){
      return null;
    }
    JobPersistence persist=new JobPersistence();
    persist.setId(Long.valueOf(jobStatus.getJobId()));
    persist.setStatus(jobStatus.getStatus()==null?null:jobStatus.getStatus().getId());
    JSONObject o=new JSONObject();
    for(String key:jobStatus.getReadyDependency().keySet()){
      o.put(key, jobStatus.getReadyDependency().get(key));
    }
    persist.setReadyDependency(o.toString());
    persist.setHistoryId(jobStatus.getHistoryId()==null?null:Long.valueOf(jobStatus.getHistoryId()));
    return persist;
  }
View Full Code Here

 
  public static JobPersistence convert(JobDescriptor jd){
    if(jd==null){
      return null;
    }
    JobPersistence persist=new JobPersistence();
    JSONArray resArray=new JSONArray();
    for(Map<String, String> map:jd.getResources()){
      JSONObject o=new JSONObject();
      for(String key:map.keySet()){
        o.put(key, map.get(key));
      }
      resArray.add(o);
    }
    persist.setResources(resArray.toString());
    JSONObject object=new JSONObject();
    for(Object key:jd.getProperties().keySet()){
      object.put(key, jd.getProperties().get(key.toString()));
    }
    persist.setAuto(jd.getAuto()?1:0);
    persist.setConfigs(object.toString());
    persist.setCronExpression(jd.getCronExpression());
    persist.setDependencies(StringUtils.join(jd.getDependencies().iterator(), ","));
    persist.setDescr(jd.getDesc());
    persist.setGroupId(jd.getGroupId()==null?null:Integer.valueOf(jd.getGroupId()));
    if(jd.getId()!=null){
      persist.setId(Long.valueOf(jd.getId()));
    }
    persist.setName(jd.getName());
    persist.setOwner(jd.getOwner());
    persist.setRunType(jd.getJobType()==null?null:jd.getJobType().toString());
    persist.setScheduleType(jd.getScheduleType()==null?null:jd.getScheduleType().getType());
   
    persist.setScript(jd.getScript());
   
    JSONArray preArray=new JSONArray();
    for(Processer p:jd.getPreProcessers()){
      JSONObject o=new JSONObject();
      o.put("id", p.getId());
      o.put("config", p.getConfig());
      preArray.add(o);
    }
    persist.setPreProcessers(preArray.toString());
   
    JSONArray postArray=new JSONArray();
    for(Processer p:jd.getPostProcessers()){
      JSONObject o=new JSONObject();
      o.put("id", p.getId());
      o.put("config", p.getConfig());
      postArray.add(o);
    }
    persist.setPostProcessers(postArray.toString());
   
    return persist;
  }
View Full Code Here

    return null;
  }

  @Override
  public Tuple<JobDescriptor,JobStatus> getJobDescriptor(String jobId) {
    JobPersistence persist=getJobPersistence(jobId);
    if(persist==null){
      return null;
    }
    return PersistenceAndBeanConvert.convert(persist);
  }
View Full Code Here

    }
    return PersistenceAndBeanConvert.convert(persist);
  }
 
  private JobPersistence getJobPersistence(String jobId){
    JobPersistence persist=(JobPersistence) getHibernateTemplate().get(JobPersistence.class, Long.valueOf(jobId));
    if(persist==null){
      return null;
    }
    return persist;
  }
View Full Code Here

  }
 

  @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());
  }
View Full Code Here

    JobPersistence orgPersist=(JobPersistence) getHibernateTemplate().get(JobPersistence.class, Long.valueOf(job.getId()));
    updateJob(user, job, orgPersist.getOwner(),orgPersist.getGroupId().toString());
  }
 
  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);
    }
  }
View Full Code Here

    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();
  }
View Full Code Here

    return map;
  }

  @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);
  }
View Full Code Here

TOP

Related Classes of com.taobao.zeus.store.mysql.persistence.JobPersistence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.