Package com.taobao.zeus.model

Examples of com.taobao.zeus.model.JobHistory


      if(mvce.getAppEvent() instanceof JobSuccessEvent){
        final JobSuccessEvent event=(JobSuccessEvent) mvce.getAppEvent();
        if(event.getTriggerType()==TriggerType.SCHEDULE){
          return;
        }
        JobHistory history=jobHistoryManager.findJobHistory(event.getHistoryId());
        final JobDescriptor jd=groupManager.getJobDescriptor(history.getJobId()).getX();
        if(history.getOperator()!=null){
          //此处可以发送IM消息
        }
      }
    } catch (Exception e) {
      //处理异常,防止后续的依赖任务受此影响,无法正常执行
View Full Code Here


  }
 
  public Future<Response> cancelManual(final WorkerContext context,final Request req,final String historyId){
    // 查找该job是否在运行中,如果不在,响应ERROR
    // 如果在,执行取消操作,等待操作结束后,响应OK
    JobHistory history=context.getJobHistoryManager().findJobHistory(historyId);
    final String jobId=history.getJobId();
    SocketLog.info("receive master cancel request,rid="+req.getRid()+",jobId="+jobId);
    if(!context.getManualRunnings().containsKey(historyId)){
      return context.getThreadPool().submit(new Callable<Response>() {
        public Response call() throws Exception {
          return Response.newBuilder().setRid(req.getRid()).setOperate(Operate.Cancel).setStatus(Status.ERROR)
View Full Code Here

  }
 
  public Future<Response> cancelSchedule(final WorkerContext context,final Request req,final String historyId){
    // 查找该job是否在运行中,如果不在,响应ERROR
    // 如果在,执行取消操作,等待操作结束后,响应OK
    JobHistory history=context.getJobHistoryManager().findJobHistory(historyId);
    final String jobId=history.getJobId();
    SocketLog.info("receive master cancel request,rid="+req.getRid()+",jobId="+jobId);
    if(!context.getRunnings().containsKey(jobId)){
      return context.getThreadPool().submit(new Callable<Response>() {
        public Response call() throws Exception {
          return Response.newBuilder().setRid(req.getRid()).setOperate(Operate.Cancel).setStatus(Status.ERROR)
View Full Code Here

    } catch (InvalidProtocolBufferException e1) {
    }
    SocketLog.info("receive master to worker manual request,rid="
        + req.getRid() + ",historyId=" + mm.getHistoryId());
    final String historyId = mm.getHistoryId();
    final JobHistory history = context.getJobHistoryManager()
        .findJobHistory(historyId);
    Future<Response> f = context.getThreadPool().submit(
        new Callable<Response>() {
          public Response call() throws Exception {
            history.setExecuteHost(WorkerContext.host);
            history.setStartTime(new Date());
            context.getJobHistoryManager()
                .updateJobHistory(history);

            String date = new SimpleDateFormat("yyyy-MM-dd")
                .format(new Date());
            File direcotry = new File(Environment.getDownloadPath()
                + File.separator + date + File.separator
                + "manual-" + history.getId());
            if (!direcotry.exists()) {
              direcotry.mkdirs();
            }
            JobBean jb = context.getGroupManager()
                .getUpstreamJobBean(history.getJobId());

            final Job job = JobUtils.createJob(new JobContext(JobContext.MANUAL_RUN),
                jb, history, direcotry.getAbsolutePath(),
                context.getApplicationContext());
            context.getManualRunnings().put(historyId, job);

            Integer exitCode = -1;
            Exception exception = null;
            try {
              exitCode = job.run();
            } catch (Exception e) {
              exception = e;
              history.getLog().appendZeusException(e);
            } finally {
              JobHistory jobHistory = context
                  .getJobHistoryManager()
                  .findJobHistory(history.getId());
              jobHistory.setEndTime(new Date());
              if (exitCode == 0) {
                jobHistory
                    .setStatus(com.taobao.zeus.model.JobStatus.Status.SUCCESS);
              } else {
                jobHistory
                    .setStatus(com.taobao.zeus.model.JobStatus.Status.FAILED);
              }
              context.getJobHistoryManager().updateJobHistory(
                  jobHistory);
              history.getLog().appendZeus("exitCode=" + exitCode);
View Full Code Here

                  Status.ERROR).build();
        }
      });
    }
    final JobStatus js = context.getGroupManager().getJobStatus(jobId);
    final JobHistory history = context.getJobHistoryManager()
        .findJobHistory(js.getHistoryId());
    Future<Response> f = context.getThreadPool().submit(
        new Callable<Response>() {
          public Response call() throws Exception {
            history.setExecuteHost(WorkerContext.host);
            history.setStartTime(new Date());
            context.getJobHistoryManager()
                .updateJobHistory(history);

            JobBean jb = context.getGroupManager()
                .getUpstreamJobBean(history.getJobId());
            String date = new SimpleDateFormat("yyyy-MM-dd")
                .format(new Date());
            File direcotry = new File(Environment.getDownloadPath()
                + File.separator + date + File.separator
                + history.getId());
            if (!direcotry.exists()) {
              direcotry.mkdirs();
            }

            final Job job = JobUtils.createJob(new JobContext(JobContext.SCHEDULE_RUN),
                jb, history, direcotry.getAbsolutePath(),
                context.getApplicationContext());
            context.getRunnings().put(jobId, job);

            Integer exitCode = -1;
            Exception exception = null;
            try {
              exitCode = job.run();
            } catch (Exception e) {
              exception = e;
              history.getLog().appendZeusException(e);
            } finally {
              JobHistory jobHistory = context
                  .getJobHistoryManager()
                  .findJobHistory(history.getId());
              jobHistory.setEndTime(new Date());
              if (exitCode == 0) {
                jobHistory
                    .setStatus(com.taobao.zeus.model.JobStatus.Status.SUCCESS);
              } else {
                jobHistory
                    .setStatus(com.taobao.zeus.model.JobStatus.Status.FAILED);
              }
              context.getJobHistoryManager().updateJobHistory(
                  jobHistory);
              history.getLog().appendZeus("exitCode=" + exitCode);
View Full Code Here

    JSONObject jsonData = new JSONObject();
    //JSONObject data = new JSONObject();
    jsonData.put("id", result.getId()+"-"+new Random().nextInt(1000));
    jsonData.put("name", result.getName());
    Map<String, JobHistory> map=jobHistoryManager.findLastHistoryByList(Arrays.asList(result.getId()));
    JobHistory his=map.get(result.getId());
    JSONObject data=new JSONObject();
    if(his==null){
      data.put("jobId",result.getId());
      data.put("historyId", "");
      data.put("lastStatus", "");
      data.put("lastRuntime", 0);
    }else{
      data.put("jobId",result.getId());
      data.put("historyId", his.getId());
      data.put("lastStatus", his.getStatus()==null?"":his.getStatus().toString());
      data.put("lastRuntime", his.getStartTime()==null?null:his.getStartTime().getTime());
    }
    jsonData.put("data", data);
    if(result.getChildren().size()>0)
      jsonData.put("children", getChildren(result));
    else
View Full Code Here

    if(!permissionManager.hasJobPermission(LoginUser.getUser().getUid(), jobId)){
      GwtException e=new GwtException("你没有权限执行该操作");
      log.error(e);
      throw e;
    }
    JobHistory history=new JobHistory();
    history.setJobId(jobId);
    history.setTriggerType(triggerType);
    history.setOperator(LoginUser.getUser().getUid());
    history.setIllustrate("触发人:"+LoginUser.getUser().getUid());
    history.setStatus(Status.RUNNING);
    jobHistoryManager.addJobHistory(history);
    ExecuteKind kind=null;
    if(triggerType==TriggerType.MANUAL){
      kind=ExecuteKind.ManualKind;
    }else if(triggerType==TriggerType.MANUAL_RECOVER){
      kind=ExecuteKind.ScheduleKind;
    }
    try {
      worker.executeJobFromWeb(kind, history.getId());
    } catch (Exception e) {
      log.error("error",e);
      throw new GwtException(e.getMessage());
    }
  }
View Full Code Here

      throw new GwtException(e.getMessage());
    }
  }
  @Override
  public void cancel(String historyId) throws GwtException {
    JobHistory history=jobHistoryManager.findJobHistory(historyId);
    if(!permissionManager.hasJobPermission(LoginUser.getUser().getUid(), history.getJobId())){
      throw new GwtException("你没有权限执行该操作");
    }
    ExecuteKind kind=null;
    if(history.getTriggerType()==TriggerType.MANUAL){
      kind=ExecuteKind.ManualKind;
    }else{
      kind=ExecuteKind.ScheduleKind;
    }
    try {
View Full Code Here

      throw new GwtException(e.getMessage());
    }
  }
  @Override
  public JobHistoryModel getJobHistory(String id) {
    JobHistory his=jobHistoryManager.findJobHistory(id);
    JobHistoryModel d=new JobHistoryModel();
    d.setId(his.getId());
    d.setJobId(his.getJobId());
    d.setStartTime(his.getStartTime());
    d.setEndTime(his.getEndTime());
    d.setExecuteHost(his.getExecuteHost());
    d.setStatus(his.getStatus()==null?null:his.getStatus().toString());
    String type="";
    if(his.getTriggerType()!=null){
      if(his.getTriggerType()==TriggerType.MANUAL){
        type="手动调度";
      }else if(his.getTriggerType()==TriggerType.MANUAL_RECOVER){
        type="手动恢复";
      }else if(his.getTriggerType()==TriggerType.SCHEDULE){
        type="自动调度";
      }
    }
    d.setTriggerType(type);
    d.setIllustrate(his.getIllustrate());
    d.setLog(his.getLog().getContent());
    return d;
  }
View Full Code Here

          throw new ZeusException(e);
        } finally{
          IOUtils.closeQuietly(out);
        }
       
        JobHistory history=new JobHistory();
        JobContext jobContext=new JobContext();
        jobContext.setWorkDir(temp.getParent());
        jobContext.setJobHistory(history);
        jobContext.setProperties(new HierarchyProperties(new HashMap<String, String>()));
        UploadHdfsFileJob job=new UploadHdfsFileJob(jobContext, temp.getAbsolutePath(), hdfsLibPath);
        Integer exitCode=job.run();
        if(exitCode!=0){
          log.error(history.getLog().getContent());
          resp.getWriter().write(history.getLog().getContent());
        }else{
          resp.getWriter().write("[[uri=hdfs://"+hdfsLibPath+File.separator+temp.getName()+"]]");
        }
        break;
      }
View Full Code Here

TOP

Related Classes of com.taobao.zeus.model.JobHistory

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.