private void showJobs(PrintWriter out, boolean advancedView,
      Set<String> userFilterSet, Set<String> poolFilterSet) {
    ResourceReporter reporter = jobTracker.getResourceReporter();
    out.print("<h2>Running Jobs</h2>\n");
    out.print("<b>Filter</b> "
        + "<input type=\"text\" onkeyup=\"filterTables(this.value)\" id=\"RunningJobsTableFilter\">"
        + "<input type=\"checkbox\" id=\"TimeFilterToggle\" "
          + "onChange=\"filterTables(inputRJF.value)\" checked>Time "
        + "<input type=\"checkbox\" id=\"JobIDFilterToggle\" "
          + "onChange=\"filterTables(inputRJF.value)\" checked>JobID "
        + "<input type=\"checkbox\" id=\"UserFilterToggle\" "
          + "onChange=\"filterTables(inputRJF.value)\" checked>User "
        + "<input type=\"checkbox\" id=\"NameFilterToggle\" "
          + "onChange=\"filterTables(inputRJF.value)\" checked>Name "
        + "<input type=\"checkbox\" id=\"PoolFilterToggle\" "
          + "onChange=\"filterTables(inputRJF.value)\" checked>Pool "
        + "<input type=\"checkbox\" id=\"PrioFilterToggle\" "
          + "onChange=\"filterTables(inputRJF.value)\" checked>Priority"
        + "<br><br>\n");
    out.print("<script type=\"text/javascript\">var inputRJF = "
      + "document.getElementById('RunningJobsTableFilter');</script>");
    out.print("<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\" "
        + "id=\"RunningJobsTable\" class=\"tablesorter\">\n");
    int colsPerTaskType = advancedView ? 6 : 3;
    out.printf("<thead><tr><th rowspan=2>Submitted</th>" +
        "<th rowspan=2>JobID</th>" +
        "<th rowspan=2>User</th>" +
        "<th rowspan=2>Name</th>" +
        "<th rowspan=2>Pool</th>" +
        "<th rowspan=2>Priority</th>" +
        "<td colspan=%d>Maps</td>" +
        "<td colspan=%d>Reduces</td>" +
        ( reporter != null ?
        "<td colspan=2>CPU</td>" +
        "<td colspan=3>MEM</td>" : ""),
        colsPerTaskType, colsPerTaskType);
    out.print("</tr><tr>\n");
    out.print("<th>Finished</th><th>Running</th><th>Fair Share</th>" +
        (advancedView ? "<th>Weight</th><th>Deficit</th><th>minMaps</th>" : ""));
    out.print("<th>Finished</th><th>Running</th><th>Fair Share</th>" +
        (advancedView ? "<th>Weight</th><th>Deficit</th><th>minReduces</th>" : ""));
    if (reporter != null) {
      out.print("<th>Now</th><th>Cumulated</th>" +
                "<th>Now</th><th>Cumulated</th><th>Max/Node</th>");
    }
    out.print("</tr></thead><tbody>\n");
    synchronized (jobTracker) {
      Collection<JobInProgress> runningJobs = getInitedJobs();
      synchronized (scheduler) {
        for (JobInProgress job: runningJobs) {
          JobProfile profile = job.getProfile();
          JobInfo info = scheduler.infos.get(job);
          if (info == null) { // Job finished, but let's show 0's for info
            info = new JobInfo(0);
          }

          // Filter for user and pool filters
          String userName = profile.getUser();
          String poolName = scheduler.getPoolManager().getPoolName(job);
          if ((userFilterSet != null) && !userFilterSet.contains(userName)) {
            continue;
          }
          if ((poolFilterSet != null) && !poolFilterSet.contains(poolName)) {
            continue;
          }

          out.printf("<tr id=\"%s\">\n", profile.getJobID());
          out.printf("<td>%s</td>\n", DATE_FORMAT.format(
                       new Date(job.getStartTime())));
          out.printf("<td><a href=\"jobdetails.jsp?jobid=%s\">%s</a></td>",
                     profile.getJobID(), profile.getJobID());
          out.printf("<td>%s</td>\n", userName);
          out.printf("<td>%s</td>\n", profile.getJobName());
          out.printf("<td>%s</td>\n", generateSelectForPool(poolName));
          out.printf("<td>%s</td>\n", generateSelectForPrio(
                       job.getPriority().toString()));
          out.printf("<td>%d / %d</td><td>%d</td><td>%f</td>\n",
                     job.finishedMaps(), job.desiredMaps(), info.runningMaps,
                     info.mapFairShare);
          if (advancedView) {
            out.print("<td>" + info.mapWeight + "</td>\n");
            out.printf("<td>%s</td>\n", info.neededMaps > 0 ?
                       (info.mapDeficit / 1000) + "s" : "--");
            out.printf("<td>%d</td>\n", info.minMaps);
          }
          out.printf("<td>%d / %d</td><td>%d</td><td>%f</td>\n",
                     job.finishedReduces(), job.desiredReduces(), info.runningReduces,
                     info.reduceFairShare);
          if (advancedView) {
            out.print("<td>" + info.reduceWeight + "</td>\n");
            out.printf("<td>%s</td>\n", info.neededReduces > 0 ?
                       (info.reduceDeficit / 1000) + "s" : "--");
            out.printf("<td>%d</td>\n", info.minReduces);
          }
          if (reporter != null) {
            JobID jobId = profile.getJobID();
            double cpu = reporter.getJobCpuPercentageOnCluster(jobId);
            double mem = reporter.getJobMemPercentageOnCluster(jobId);
            double cpuTime = reporter.getJobCpuCumulatedUsageTime(jobId);
            double memTime = reporter.getJobMemCumulatedUsageTime(jobId);
            double memMax = reporter.getJobMemMaxPercentageOnBox(jobId);
            if (cpu == ResourceReporter.UNAVAILABLE ||
                mem == ResourceReporter.UNAVAILABLE ||
                cpuTime == ResourceReporter.UNAVAILABLE ||
                memTime == ResourceReporter.UNAVAILABLE ||
                memMax == ResourceReporter.UNAVAILABLE) {
              out.printf("<td>-</td><td>-</td><td>-</td><td>-</td><td>-</td>");
              continue;
            }
            out.printf("<td>%.1f%%</td>\n", cpu);
            out.printf("<td>%.1f sec</td>\n", cpuTime / 1000D);
            out.printf("<td>%.1f%%</td>\n", mem);
            out.printf("<td>%.1f sec</td>\n", memTime / 1000D);
            if (memMax > 50) {
              out.printf("<td><font color=\"red\">%.1f%%</font></td>\n",
                         memMax);
            } else {
              out.printf("<td>%.1f%%</td>\n", memMax);
            }
          }
          out.print("</tr>\n");
        }
      }
    }
    out.print("</tbody></table>\n");
  }
private void showJobs ( PrintWriter out , boolean advancedView , Set < String > userFilterSet , Set < String > poolFilterSet ) { ResourceReporter reporter = jobTracker . getResourceReporter ( ) ; out . print ( "<h2>Running Jobs</h2>\n" ) ; out . print ( "<b>Filter</b> " + "<input type=\"text\" onkeyup=\"filterTables(this.value)\" id=\"RunningJobsTableFilter\">" + "<input type=\"checkbox\" id=\"TimeFilterToggle\" " + "onChange=\"filterTables(inputRJF.value)\" checked>Time " + "<input type=\"checkbox\" id=\"JobIDFilterToggle\" " + "onChange=\"filterTables(inputRJF.value)\" checked>JobID " + "<input type=\"checkbox\" id=\"UserFilterToggle\" " + "onChange=\"filterTables(inputRJF.value)\" checked>User " + "<input type=\"checkbox\" id=\"NameFilterToggle\" " + "onChange=\"filterTables(inputRJF.value)\" checked>Name " + "<input type=\"checkbox\" id=\"PoolFilterToggle\" " + "onChange=\"filterTables(inputRJF.value)\" checked>Pool " + "<input type=\"checkbox\" id=\"PrioFilterToggle\" " + "onChange=\"filterTables(inputRJF.value)\" checked>Priority" + "<br><br>\n" ) ; out . print ( "<script type=\"text/javascript\">var inputRJF = " + "document.getElementById('RunningJobsTableFilter');</script>" ) ; out . print ( "<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\" " + "id=\"RunningJobsTable\" class=\"tablesorter\">\n" ) ; int colsPerTaskType = advancedView ? 6 : 3 ; out . printf ( "<thead><tr><th rowspan=2>Submitted</th>" + "<th rowspan=2>JobID</th>" + "<th rowspan=2>User</th>" + "<th rowspan=2>Name</th>" + "<th rowspan=2>Pool</th>" + "<th rowspan=2>Priority</th>" + "<td colspan=%d>Maps</td>" + "<td colspan=%d>Reduces</td>" + ( reporter != null ? "<td colspan=2>CPU</td>" + "<td colspan=3>MEM</td>" : "" ) , colsPerTaskType , colsPerTaskType ) ; out . print ( "</tr><tr>\n" ) ; out . print ( "<th>Finished</th><th>Running</th><th>Fair Share</th>" + ( advancedView ? "<th>Weight</th><th>Deficit</th><th>minMaps</th>" : "" ) ) ; out . print ( "<th>Finished</th><th>Running</th><th>Fair Share</th>" + ( advancedView ? "<th>Weight</th><th>Deficit</th><th>minReduces</th>" : "" ) ) ; if ( reporter != null ) { out . print ( "<th>Now</th><th>Cumulated</th>" + "<th>Now</th><th>Cumulated</th><th>Max/Node</th>" ) ; } out . print ( "</tr></thead><tbody>\n" ) ; synchronized ( jobTracker ) { Collection < JobInProgress > runningJobs = getInitedJobs ( ) ; synchronized ( scheduler ) { for ( JobInProgress job : runningJobs ) { JobProfile profile = job . getProfile ( ) ; JobInfo info = scheduler . infos . get ( job ) ; if ( info == null ) { info = new JobInfo ( 0 ) ; } String userName = profile . getUser ( ) ; String poolName = scheduler . getPoolManager ( ) . getPoolName ( job ) ; if ( ( userFilterSet != null ) && ! userFilterSet . contains ( userName ) ) { continue ; } if ( ( poolFilterSet != null ) && ! poolFilterSet . contains ( poolName ) ) { continue ; } out . printf ( "<tr id=\"%s\">\n" , profile . getJobID ( ) ) ; out . printf ( "<td>%s</td>\n" , DATE_FORMAT . format ( new Date ( job . getStartTime ( ) ) ) ) ; out . printf ( "<td><a href=\"jobdetails.jsp?jobid=%s\">%s</a></td>" , profile . getJobID ( ) , profile . getJobID ( ) ) ; out . printf ( "<td>%s</td>\n" , userName ) ; out . printf ( "<td>%s</td>\n" , profile . getJobName ( ) ) ; out . printf ( "<td>%s</td>\n" , generateSelectForPool ( poolName ) ) ; out . printf ( "<td>%s</td>\n" , generateSelectForPrio ( job . getPriority ( ) . toString ( ) ) ) ; out . printf ( "<td>%d / %d</td><td>%d</td><td>%f</td>\n" , job . finishedMaps ( ) , job . desiredMaps ( ) , info . runningMaps , info . mapFairShare ) ; if ( advancedView ) { out . print ( "<td>" + info . mapWeight + "</td>\n" ) ; out . printf ( "<td>%s</td>\n" , info . neededMaps > 0 ? ( info . mapDeficit / 1000 ) + "s" : "--" ) ; out . printf ( "<td>%d</td>\n" , info . minMaps ) ; } out . printf ( "<td>%d / %d</td><td>%d</td><td>%f</td>\n" , job . finishedReduces ( ) , job . desiredReduces ( ) , info . runningReduces , info . reduceFairShare ) ; if ( advancedView ) { out . print ( "<td>" + info . reduceWeight + "</td>\n" ) ; out . printf ( "<td>%s</td>\n" , info . neededReduces > 0 ? ( info . reduceDeficit / 1000 ) + "s" : "--" ) ; out . printf ( "<td>%d</td>\n" , info . minReduces ) ; } if ( reporter != null ) { JobID jobId = profile . getJobID ( ) ; double cpu = reporter . getJobCpuPercentageOnCluster ( jobId ) ; double mem = reporter . getJobMemPercentageOnCluster ( jobId ) ; double cpuTime = reporter . getJobCpuCumulatedUsageTime ( jobId ) ; double memTime = reporter . getJobMemCumulatedUsageTime ( jobId ) ; double memMax = reporter . getJobMemMaxPercentageOnBox ( jobId ) ; if ( cpu == ResourceReporter . UNAVAILABLE || mem == ResourceReporter . UNAVAILABLE || cpuTime == ResourceReporter . UNAVAILABLE || memTime == ResourceReporter . UNAVAILABLE || memMax == ResourceReporter . UNAVAILABLE ) { out . printf ( "<td>-</td><td>-</td><td>-</td><td>-</td><td>-</td>" ) ; continue ; } out . printf ( "<td>%.1f%%</td>\n" , cpu ) ; out . printf ( "<td>%.1f sec</td>\n" , cpuTime / 1000D ) ; out . printf ( "<td>%.1f%%</td>\n" , mem ) ; out . printf ( "<td>%.1f sec</td>\n" , memTime / 1000D ) ; if ( memMax > 50 ) { out . printf ( "<td><font color=\"red\">%.1f%%</font></td>\n" , memMax ) ; } else { out . printf ( "<td>%.1f%%</td>\n" , memMax ) ; } } out . print ( "</tr>\n" ) ; } } } out . print ( "</tbody></table>\n" ) ; }
Print a view of running jobs to the given output writer.

@param out All html output goes here.
@param advancedView Show advanced view if true
@param String userFilterSet If not null, only show this set's info
@param String poolFilterSet If not null, only show this set's info