示例#1
0
  public JobInfo(Job job, Boolean hasAccess) {
    this.id = MRApps.toString(job.getID());
    JobReport report = job.getReport();
    this.startTime = report.getStartTime();
    this.finishTime = report.getFinishTime();
    this.elapsedTime = Times.elapsed(this.startTime, this.finishTime);
    if (this.elapsedTime == -1) {
      this.elapsedTime = 0;
    }
    this.name = job.getName().toString();
    this.user = job.getUserName();
    this.queue = job.getQueueName();
    this.state = job.getState();
    this.mapsTotal = job.getTotalMaps();
    this.mapsCompleted = job.getCompletedMaps();
    this.mapProgress = report.getMapProgress() * 100;
    this.mapProgressPercent = StringUtils.formatPercent(report.getMapProgress(), 2);
    this.reducesTotal = job.getTotalReduces();
    this.reducesCompleted = job.getCompletedReduces();
    this.reduceProgress = report.getReduceProgress() * 100;
    this.reduceProgressPercent = StringUtils.formatPercent(report.getReduceProgress(), 2);

    this.acls = new ArrayList<ConfEntryInfo>();
    if (hasAccess) {
      this.diagnostics = "";
      countTasksAndAttempts(job);

      this.uberized = job.isUber();

      List<String> diagnostics = job.getDiagnostics();
      if (diagnostics != null && !diagnostics.isEmpty()) {
        StringBuffer b = new StringBuffer();
        for (String diag : diagnostics) {
          b.append(diag);
        }
        this.diagnostics = b.toString();
      }

      Map<JobACL, AccessControlList> allacls = job.getJobACLs();
      if (allacls != null) {
        for (Map.Entry<JobACL, AccessControlList> entry : allacls.entrySet()) {
          this.acls.add(
              new ConfEntryInfo(entry.getKey().getAclName(), entry.getValue().getAclString()));
        }
      }
    }
  }
 /** @param context */
 public AppInfo(StramAppContext context) {
   this.appId = context.getApplicationID().toString();
   this.name = context.getApplicationName();
   this.docLink = context.getApplicationDocLink();
   this.user = context.getUser().toString();
   this.startTime = context.getStartTime();
   this.elapsedTime = Times.elapsed(this.startTime, 0);
   this.appPath = context.getApplicationPath();
   this.appMasterTrackingUrl = context.getAppMasterTrackingUrl();
   this.stats = context.getStats();
   this.gatewayAddress = context.getGatewayAddress();
   this.version = VersionInfo.getBuildVersion();
   this.attributes = new TreeMap<String, Object>();
   for (Map.Entry<Attribute<Object>, Object> entry :
       AttributeMap.AttributeInitializer.getAllAttributes(context, DAGContext.class).entrySet()) {
     this.attributes.put(entry.getKey().getSimpleName(), entry.getValue());
   }
   this.gatewayConnected = context.isGatewayConnected();
   this.appDataSources = context.getAppDataSources();
   this.metrics = context.getMetrics();
 }