Package com.taobao.zeus.store

Examples of com.taobao.zeus.store.JobBean


              f.get(2000,TimeUnit.MILLISECONDS);
            }
          }else{
            List<Tuple<JobDescriptor, JobStatus>> jobs=getChildrenJob(parent.getGroupDescriptor().getId());
            for(Tuple<JobDescriptor, JobStatus> tuple:jobs){
              JobBean jobBean=new JobBean(tuple.getX(),tuple.getY());
              jobBean.setGroupBean(parent);
              parent.getJobBeans().put(tuple.getX().getId(), jobBean);
            }
          }
          return parent;
        }
View Full Code Here


  @Qualifier("groupManager")
  private GroupManager groupManager;
  @Override
  public List<String> findActualJobFollowers(String jobId) {
    List<ZeusFollow> jobFollows=findJobFollowers(jobId);
    JobBean jobBean=groupManager.getUpstreamJobBean(jobId);
   
    List<String> groupIds=new ArrayList<String>();
    GroupBean gb=jobBean.getGroupBean();
    while(gb!=null){
      groupIds.add(gb.getGroupDescriptor().getId());
      gb=gb.getParentGroupBean();
    }
    List<ZeusFollow> groupFollows=findGroupFollowers(groupIds);
   
    List<String> follows=new ArrayList<String>();
    //任务创建人自动纳入消息通知人员名单
    follows.add(jobBean.getJobDescriptor().getOwner());
    for(ZeusFollow zf:jobFollows){
      if(!follows.contains(zf.getUid())){
        follows.add(zf.getUid());
      }
    }
View Full Code Here

  }

  @Override
  public void deleteJob(String user, String jobId) throws ZeusException {
    GroupBean root= getGlobeGroupBean();
    JobBean job=root.getAllSubJobBeans().get(jobId);
    if(!job.getDepender().isEmpty()){
      List<String> deps=new ArrayList<String>();
      for(JobBean jb:job.getDepender()){
        deps.add(jb.getJobDescriptor().getId());
      }
      throw new ZeusException("该Job正在被其他Job"+deps.toString()+"依赖,无法删除");
    }
    getHibernateTemplate().delete(getHibernateTemplate().get(JobPersistence.class, Long.valueOf(jobId)));
View Full Code Here

        parent.getChildrenGroupBeans().add(childBean);
      }
    }else{
      List<Tuple<JobDescriptor, JobStatus>> jobs=getChildrenJob(parent.getGroupDescriptor().getId());
      for(Tuple<JobDescriptor, JobStatus> tuple:jobs){
        JobBean jobBean=new JobBean(tuple.getX(),tuple.getY());
        jobBean.setGroupBean(parent);
        parent.getJobBeans().put(tuple.getX().getId(), jobBean);
      }
    }
   
    return parent;
View Full Code Here

        parent.getChildrenGroupBeans().add(childBean);
      }
    }else{
      List<Tuple<JobDescriptor, JobStatus>> jobs=getChildrenJob(parent.getGroupDescriptor().getId());
      for(Tuple<JobDescriptor, JobStatus> tuple:jobs){
        JobBean jobBean=new JobBean(tuple.getX(),tuple.getY());
        jobBean.setGroupBean(parent);
        parent.getJobBeans().put(tuple.getX().getId(), jobBean);
      }
    }
   
    return parent;
View Full Code Here

    if(Super.getSupers().contains(user)){
      //超级管理员
      return true;
    }
    Set<String> groups=new HashSet<String>();
    JobBean jobBean=groupManager.getUpstreamJobBean(jobId);
    if(user.equals(jobBean.getJobDescriptor().getOwner())){
      //任务所有人
      return true;
    }
    GroupBean gb=jobBean.getGroupBean();
    while(gb!=null){
      groups.add(gb.getGroupDescriptor().getId());
      gb=gb.getParentGroupBean();
    }
    Set<String> users=new HashSet<String>();
View Full Code Here

          depth=0;
        }
        if(depth<2){//job 的递归深度控制,防止无限递归
          JobProcesser jobProcesser=(JobProcesser) p;
          GroupManager groupManager=(GroupManager) applicationContext.getBean("groupManager");
          JobBean jb=groupManager.getUpstreamJobBean(jobProcesser.getJobId());
          if(jb!=null){
            for(String key:jobProcesser.getKvConfig().keySet()){
              if(jobProcesser.getKvConfig().get(key)!=null){
                jb.getJobDescriptor().getProperties().put(key, jobProcesser.getKvConfig().get(key));
              }
            }
            File direcotry=new File(workDir+File.separator+"job-processer-"+jobProcesser.getJobId());
            if(!direcotry.exists()){
              direcotry.mkdirs();
View Full Code Here

        if(chainLocal.get()==null || !chainLocal.get().getCauseJobId().equals(causeJobId)){
          GroupBean gb=readOnlyGroupManager.getGlobeGroupBean();
          chainLocal.set(new ChainException(causeJobId, gb));
        }
        final ChainException chain=chainLocal.get();
        final JobBean jobBean=chain.gb.getAllSubJobBeans().get(jobId);
        final ZeusUser owner=userManager.findByUid(jobBean.getJobDescriptor().getOwner());
        //延迟6秒发送邮件,保证日志已经输出到数据库
        new Thread(){
          public void run() {
            try {
              Thread.sleep(6000);
              StringBuffer sb=new StringBuffer();
              sb.append("Job任务(").append(jobId).append(")").append(jobBean.getJobDescriptor().getName()).append("运行失败");
              sb.append("<br/>");
              String type="";
              if(event.getTriggerType()==TriggerType.MANUAL){
                type="手动触发";
              }else if(event.getTriggerType()==TriggerType.MANUAL_RECOVER){
                type="手动恢复";
              }else if(event.getTriggerType()==TriggerType.SCHEDULE){
                type="自动调度";
              }
              sb.append("Job任务的触发类型为:"+type).append("<br/>");
              if(event.getHistory()!=null){
                sb.append("失败原因:"+jobHistoryManager.findJobHistory(event.getHistory().getId()).getLog().getContent().replaceAll("\\n", "<br/>"));
                String msg= "Zeus报警 JobId:"+jobId+" 任务运行失败";
                if(!jobBean.getDepender().isEmpty()){
                  msg+=",影响范围:"+getDependencyJobs(jobBean);
                }
                if(!causeJobId.equalsIgnoreCase(event.getJobId())){
                  msg+="(根本原因:job "+causeJobId+"运行失败)";
                }
                mailAlarm.alarm(event.getHistory().getId(), msg, sb.toString());
              }
            } catch (Exception e) {
              log.error("邮件发送出现异常",e);
            }
          };
        }.start();
       
        String msg="Job任务("+jobId+"-"+owner.getName()+"):"+jobBean.getJobDescriptor().getName()+" 运行失败";
        if(!jobBean.getDepender().isEmpty()){
          msg+=",影响范围:"+getDependencyJobs(jobBean);
        }
        if(!causeJobId.equalsIgnoreCase(event.getJobId())){
          msg+="(根本原因:job "+causeJobId+"运行失败)";
        }
View Full Code Here

      return ;
    }
    JobStatus jobStatus=null;
    synchronized (this) {
      jobStatus=groupManager.getJobStatus(jobId);
      JobBean bean=groupManager.getUpstreamJobBean(jobId);
      String cycle=bean.getHierarchyProperties().getProperty(PropertyKeys.DEPENDENCY_CYCLE);
      if(cycle!=null && !"".equals(cycle)){
        Map<String, String> dep=jobStatus.getReadyDependency();
        if("sameday".equals(cycle)){
          SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
          String now=format.format(new Date());
View Full Code Here

   * @return
   */
  private boolean isAllJobsNotChangeParent(GroupBean gb,List<JobDescriptor> list){
    Map<String, JobBean> allJobs=gb.getAllSubJobBeans();
    for(JobDescriptor jd:list){
      JobBean bean=allJobs.get(jd.getId());
      if(bean==null){
        DebugInfoLog.info("isAllJobsNotChangeParent job id="+ jd.getId()+" has changed");
        return false;
      }
      JobDescriptor old=bean.getJobDescriptor();
      if(!old.getGroupId().equals(jd.getGroupId())){
        DebugInfoLog.info("isAllJobsNotChangeParent job id="+ jd.getId()+" has changed");
        return false;
      }
    }
View Full Code Here

TOP

Related Classes of com.taobao.zeus.store.JobBean

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.