Changeset 4070


Ignore:
Timestamp:
Dec 18, 2007, 11:31:01 AM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #790: Job slot status information on job agent view

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/Agent.java

    r4026 r4070  
    5050import net.sf.basedb.util.Values;
    5151import net.sf.basedb.util.jobagent.JobAgentServerConnection;
     52import net.sf.basedb.util.jobagent.JobInfo;
    5253import net.sf.basedb.util.jobagent.RequestHandler;
    5354import net.sf.basedb.util.timer.Scheduler;
     
    273274  private final Map<Job.ExecutionTime, Integer> priorities;
    274275 
    275   private final Set<Integer> activeJobs;
     276  private final Set<JobInfo> activeJobs;
    276277 
    277278  /**
     
    344345    runnersGroup.setDaemon(false);
    345346
    346     this.activeJobs = new HashSet<Integer>();
     347    this.activeJobs = new HashSet<JobInfo>();
    347348    isRunning = false;
    348349  }
     
    634635    Get a set containing the ID:s of the jobs that are currently
    635636    beeing executed by this job agent.
    636     @return A set of integers
    637   */
    638   public Set<Integer> getRunningJobs()
     637    @return A set of JobInfo objects
     638    @since 2.6
     639  */
     640  public Set<JobInfo> getRunningJobs()
    639641  {
    640642    if (log.isDebugEnabled()) log.debug("Active jobs: " + activeJobs);
     
    793795        slotToUse = slots[i];
    794796        usedSlots.put(slotToUse, usedSlots.get(slotToUse) + 1);
    795         activeJobs.add(job.getId());
     797        activeJobs.add(new JobInfo(job, slotToUse));
    796798        log.debug("Slot: " + slotToUse + "; used: " + usedSlots.get(slotToUse) + "; max: " + maxSlots.get(slotToUse));
    797799        break;
     
    830832  {
    831833    usedSlots.put(usedSlot, usedSlots.get(usedSlot) - 1);
    832     activeJobs.remove(job.getId());
     834    activeJobs.remove(new JobInfo(job, usedSlot));
    833835  }
    834836 
  • trunk/src/core/net/sf/basedb/util/jobagent/JobAgentInfo.java

    r3675 r4070  
    5353  private final Long usedMemory;
    5454  private final Long totalMemory;
    55   private final Set<Integer> jobs;
     55  private final Set<JobInfo> jobs;
    5656 
    5757  /**
     
    7474    @param usedMemory The used memory in bytes, or null if not known
    7575    @param totalMemory The total memory in bytes, or null if not known
    76     @param jobs The ID:is of the jobs that are currently executing, or null if not known
     76    @param jobs Information about jobs that are currently executing or null if not known
    7777   */
    78   public JobAgentInfo(Boolean paused, Integer cpuUsage, Long usedMemory, Long totalMemory, Set<Integer> jobs)
     78  public JobAgentInfo(Boolean paused, Integer cpuUsage, Long usedMemory, Long totalMemory, Set<JobInfo> jobs)
    7979  {
    8080    this.created = System.currentTimeMillis();
     
    100100    this.totalMemory = Values.getLong(getValue(headers, "Total memory"), null);
    101101    this.usedMemory = Values.getLong(getValue(headers, "Used memory"), null);
    102     this.jobs = new HashSet<Integer>();
     102    this.jobs = new HashSet<JobInfo>();
    103103    List<String> jj = getValues(headers, "Job");
    104104    if (jj != null)
     
    107107      {
    108108        Integer jobId = Values.getInteger(id, null);
    109         if (jobId != null) jobs.add(jobId);
     109        jobs.add(new JobInfo(jobId, headers));
    110110      }
    111111    }
     
    161161 
    162162  /**
    163     Get the ID:s of the jobs that are curently executing
     163    Get the ID:s of the jobs that are curently executing. NOTE!
     164    Since 2.6 this method always returns null.
    164165    @return A set with the ID:s or null if not known
     166    @deprecated Use {@link #getJobInfo()} instead
    165167  */
    166168  public Set<Integer> getJobs()
     169  {
     170    return null;
     171  }
     172 
     173  /**
     174    Get detailed information about the running jobs.
     175    @return A set with job information or null if not known
     176    @since 2.6
     177  */
     178  public Set<JobInfo> getJobInfo()
    167179  {
    168180    return jobs;
     
    184196    if (jobs != null)
    185197    {
    186       for (Integer jobId : jobs)
     198      for (JobInfo job : jobs)
    187199      {
    188         sb.append("Job:").append(jobId).append("\n");
     200        sb.append(job.toString());
    189201      }
    190202    }
  • trunk/www/admin/jobagents/view_agent.jsp

    r4003 r4070  
    3838  import="net.sf.basedb.core.JobAgentSettings"
    3939  import="net.sf.basedb.util.jobagent.JobAgentInfo"
     40  import="net.sf.basedb.util.jobagent.JobInfo"
    4041  import="net.sf.basedb.core.User"
    4142  import="net.sf.basedb.core.PermissionDeniedException"
     
    413414
    414415      <%
    415       Set<Integer> jobs = agent.getInfo().getJobs();
     416      Set<JobInfo> jobs = agent.getInfo().getJobInfo();
    416417      if (jobs == null || jobs.size() == 0)
    417418      {
     
    450451          />
    451452          <tbl:columndef
     453            id="slot"
     454            title="Used slot"
     455          />
     456          <tbl:columndef
    452457            id="started"
    453458            title="Started"
     
    466471            <tbl:rows>
    467472            <%
    468             for (int jobId : jobs)
     473            for (JobInfo jobInfo : jobs)
    469474            {
    470475              Job job = null;
     
    472477              try
    473478              {
    474                 job = Job.getById(dc, jobId);
     479                job = Job.getById(dc, jobInfo.getJobId());
    475480              }
    476481              catch (Throwable t)
     
    483488                <tbl:cell column="plugin"><base:propertyvalue item="<%=job%>" property="pluginDefinition"/></tbl:cell>
    484489                <tbl:cell column="started"><%=job == null ? "" : dateFormatter.format(job.getStarted())%></tbl:cell>
     490                <tbl:cell column="slot"><%=jobInfo.getSlot() == null ? "" : jobInfo.getSlot().toString()%></tbl:cell>
    485491                <tbl:cell column="percentComplete">
    486492                  <%
Note: See TracChangeset for help on using the changeset viewer.