Package com.taobao.zeus.web.platform.client.module.jobmanager

Examples of com.taobao.zeus.web.platform.client.module.jobmanager.JobModel


    }
  }
  @Override
  public JobModel getUpstreamJob(String jobId) throws GwtException {
    JobBean jobBean=permissionGroupManager.getUpstreamJobBean(jobId);
    JobModel jobModel=new JobModel();
   
    jobModel.setCronExpression(jobBean.getJobDescriptor().getCronExpression());
    jobModel.setDependencies(jobBean.getJobDescriptor().getDependencies());
    jobModel.setDesc(jobBean.getJobDescriptor().getDesc());
    jobModel.setGroupId(jobBean.getJobDescriptor().getGroupId());
    jobModel.setId(jobBean.getJobDescriptor().getId());
    String jobRunType=null;
    if(jobBean.getJobDescriptor().getJobType()==JobRunType.MapReduce){
      jobRunType=JobModel.MapReduce;
    }else if(jobBean.getJobDescriptor().getJobType()==JobRunType.Shell){
      jobRunType=JobModel.SHELL;
    }else if(jobBean.getJobDescriptor().getJobType()==JobRunType.Hive){
      jobRunType=JobModel.HIVE;
    }
    jobModel.setJobRunType(jobRunType);
    String jobScheduleType=null;
    if(jobBean.getJobDescriptor().getScheduleType()==JobScheduleType.Dependent){
      jobScheduleType=JobModel.DEPEND_JOB;
    }else if(jobBean.getJobDescriptor().getScheduleType()==JobScheduleType.Independent){
      jobScheduleType=JobModel.INDEPEN_JOB;
    }
    jobModel.setJobScheduleType(jobScheduleType);
    jobModel.setLocalProperties(jobBean.getJobDescriptor().getProperties());
    jobModel.setName(jobBean.getJobDescriptor().getName());
    jobModel.setOwner(jobBean.getJobDescriptor().getOwner());
    String ownerName=userManager.findByUid(jobModel.getOwner()).getName();
    if(ownerName==null || "".equals(ownerName.trim()) || "null".equals(ownerName)){
      ownerName=jobModel.getOwner();
    }
    jobModel.setOwnerName(ownerName);
    jobModel.setLocalResources(jobBean.getJobDescriptor().getResources());
    jobModel.setAllProperties(jobBean.getHierarchyProperties().getAllProperties());
    jobModel.setAllResources(jobBean.getHierarchyResources());
    
    jobModel.setAuto(jobBean.getJobDescriptor().getAuto());
    jobModel.setScript(jobBean.getJobDescriptor().getScript());
   
    List<String> preList=new ArrayList<String>();
    if(!jobBean.getJobDescriptor().getPreProcessers().isEmpty()){
      for(Processer p:jobBean.getJobDescriptor().getPreProcessers()){
        JSONObject o=new JSONObject();
        o.put("id", p.getId());
        o.put("config", p.getConfig());
        preList.add(o.toString());
      }
    }
    jobModel.setPreProcessers(preList);
   
    List<String> postList=new ArrayList<String>();
    if(!jobBean.getJobDescriptor().getPostProcessers().isEmpty()){
      for(Processer p:jobBean.getJobDescriptor().getPostProcessers()){
        JSONObject o=new JSONObject();
        o.put("id", p.getId());
        o.put("config", p.getConfig());
        postList.add(o.toString());
      }
    }
    jobModel.setPostProcessers(postList);
   
    jobModel.setAdmin(permissionGroupManager.hasJobPermission(LoginUser.getUser().getUid(), jobId));
   
    List<ZeusFollow> follows=followManager.findJobFollowers(jobId);
    if(follows!=null){
      List<String> followNames=new ArrayList<String>();
      for(ZeusFollow zf:follows){
        String name=userManager.findByUid(zf.getUid()).getName();
        if(name==null || "".equals(name.trim())){
          name=zf.getUid();
        }
        followNames.add(name);
      }
      jobModel.setFollows(followNames);
    }
    List<String> ladmins=permissionManager.getJobAdmins(jobId);
    List<String> admins=new ArrayList<String>();
    for(String s:ladmins){
      String name=userManager.findByUid(s).getName();
      if(name==null || "".equals(name.trim()) || "null".equals(name)){
        name=s;
      }
      admins.add(name);
    }
    jobModel.setAdmins(admins);
   
    List<String> owners=new ArrayList<String>();
    owners.add(jobBean.getJobDescriptor().getOwner());
    GroupBean parent=jobBean.getGroupBean();
    while(parent!=null){
      if(!owners.contains(parent.getGroupDescriptor().getOwner())){
        owners.add(parent.getGroupDescriptor().getOwner());
      }
      parent=parent.getParentGroupBean();
    }
    jobModel.setOwners(owners);
   
   
    //所有secret. 开头的配置项都进行权限控制
    for(String key:jobModel.getAllProperties().keySet()){
      boolean isLocal=jobModel.getLocalProperties().get(key)==null?false:true;
      if(key.startsWith("secret.")){
        if(!isLocal){
          jobModel.getAllProperties().put(key, "*");
        }else{
          if(!jobModel.getAdmin() && !jobModel.getOwner().equals(LoginUser.getUser().getUid())){
            jobModel.getLocalProperties().put(key, "*");
          }
        }
      }
    }
    //本地配置项中的hadoop.hadoop.job.ugi 只有管理员和owner才能查看,继承配置项不能查看
    String SecretKey="core-site.hadoop.job.ugi";
    if(jobModel.getLocalProperties().containsKey(SecretKey)){
      String value=jobModel.getLocalProperties().get(SecretKey);
      if(value.lastIndexOf("#")==-1){
        value="*";
      }else{
        value=value.substring(0, value.lastIndexOf("#"));
        value+="#*";
      }
      if(!jobModel.getAdmin() && !jobModel.getOwner().equals(LoginUser.getUser().getUid())){
        jobModel.getLocalProperties().put(SecretKey, value);
      }
      jobModel.getAllProperties().put(SecretKey, value);
    }else if(jobModel.getAllProperties().containsKey(SecretKey)){
      String value=jobModel.getAllProperties().get(SecretKey);
      if(value.lastIndexOf("#")==-1){
        value="*";
      }else{
        value=value.substring(0, value.lastIndexOf("#"));
        value+="#*";
      }
      jobModel.getAllProperties().put(SecretKey, value);
    }
    //如果zeus.secret.script=true 并且没有权限,对script进行加密处理
    if("true".equalsIgnoreCase(jobModel.getAllProperties().get("zeus.secret.script"))){
      if(!jobModel.getAdmin() && !jobModel.getOwner().equals(LoginUser.getUser().getUid())){
        jobModel.setScript("脚本已加密,如需查看请联系相关负责人分配权限");
      }
    }
   
    return jobModel;
  }
View Full Code Here


  public JobModel getJobStatus(String jobId) {
    JobStatus jobStatus=permissionGroupManager.getJobStatus(jobId);
    if(jobStatus==null){
      return null;
    }
    JobModel model=new JobModel();
    model.setId(jobStatus.getJobId());
    model.setReadyDependencies(jobStatus.getReadyDependency());
    model.setStatus(jobStatus.getStatus()==null?"":jobStatus.getStatus().getId());
    return model;
  }
View Full Code Here

    Map<String,JobHistory> jobHisMap=jobHistoryManager.findLastHistoryByList(jobIds);
    List<JobModel> result=new ArrayList<JobModel>();
    for(Tuple<JobDescriptor, JobStatus> job:allJobs){
      JobStatus status=job.getY();
      JobDescriptor jd=job.getX();
      JobModel model=new JobModel();
      model.setId(status.getJobId());
      Map<String, String> dep=new HashMap<String, String>();
      for(String jobId:job.getX().getDependencies()){
        if(jobId!=null && !"".equals(jobId)){
          dep.put(jobId, null);
        }
      }
      dep.putAll(status.getReadyDependency());
      model.setReadyDependencies(dep);
      model.setStatus(status.getStatus()==null?null:status.getStatus().getId());
      model.setName(jd.getName());
      model.setAuto(jd.getAuto());
      JobHistory his=jobHisMap.get(jd.getId());
      if(his!=null && his.getStartTime()!=null){
        SimpleDateFormat format=new SimpleDateFormat("MM-dd HH:mm:ss");
        model.setLastStatus(format.format(his.getStartTime())+" "+(his.getStatus()==null?"":his.getStatus().getId()));
      }
      result.add(model);
    }
   
    return new PagingLoadResultBean<JobModel>(result,total,start);
View Full Code Here

    grid.getView().setForceFit(true);
   
    grid.addCellDoubleClickHandler(new CellDoubleClickHandler() {
      public void onCellClick(CellDoubleClickEvent event) {
        int row=event.getRowIndex();
        JobModel model=grid.getStore().get(row);
        if(model!=null){
          TreeNodeSelectEvent te=new TreeNodeSelectEvent(TreeKeyProviderTool.genJobProviderKey(model.getId()));
          presenter.getPlatformContext().getPlatformBus().fireEvent(te);
        }
      }
    });
    grid.addRefreshHandler(new RefreshHandler() {
View Full Code Here

TOP

Related Classes of com.taobao.zeus.web.platform.client.module.jobmanager.JobModel

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.