com.sun.slamd.server
Class JobCache

java.lang.Object
  extended bycom.sun.slamd.server.JobCache

public class JobCache
extends java.lang.Object

This class implements an in-memory cache that stores job information. It can help decrease the time required to retrieve information about jobs so that they are retrieved from memory rather than the configuration directory.


Constructor Summary
JobCache(ConfigHandler configHandler, int cacheSize)
          Creates a new job cache intended to hold information about the specified number of jobs.
 
Method Summary
 void addJob(Job job)
          Adds the specified information to the job cache.
 void addOptimizingJob(OptimizingJob optimizingJob)
          Adds the specified optimizing job to the cache.
 void deleteJob(java.lang.String jobID)
          Removes the information about the specified job from the job cache.
 void deleteOptimizingJob(java.lang.String optimizingJobID)
          Removes the information about the specified optimizing job from the job cache.
 void flush()
          Removes all information stored in this job cache.
 Job getJob(java.lang.String jobID)
          Retrieves the specified job.
 Job[] getJobs()
          Retrieves the set of jobs that are currently held in the cache, in order of least recently used to most recently used.
 OptimizingJob getOptimizingJob(java.lang.String optimizingJobID)
          Retrieves the specified optimizing job.
 OptimizingJob[] getOptimizingJobs()
          Retrieves the set of optimizing jobs that are currently held in the cache, in order of least recently used to most recently used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobCache

public JobCache(ConfigHandler configHandler,
                int cacheSize)
Creates a new job cache intended to hold information about the specified number of jobs.

Parameters:
configHandler - The reference to the configuration handler to use to retrieve the job data if a requested job is not contained in the cache.
cacheSize - The maximum number of jobs that can be stored in the cache.
Method Detail

getJob

public Job getJob(java.lang.String jobID)
           throws SLAMDServerException
Retrieves the specified job. If the job is in the job cache, then it will be retrieved from the cache. If not, then it will be retrieved from the configuration directory and added to the cache.

Parameters:
jobID - The job ID of the job to retrieve.
Returns:
The requested job, or null if it was not in the job cache or the configuration directory.
Throws:
SLAMDServerException - If it is necessary to retrieve the job information from the configuration directory and a problem occurs while doing so.

getJobs

public Job[] getJobs()
Retrieves the set of jobs that are currently held in the cache, in order of least recently used to most recently used.

Returns:
The set of jobs that are currently held in the cache.

getOptimizingJob

public OptimizingJob getOptimizingJob(java.lang.String optimizingJobID)
                               throws SLAMDServerException
Retrieves the specified optimizing job. If the job is in the job cache, then it will be retrieved from the cache. If not, then it will be retrieved from the configuration directory and added to the cache.

Parameters:
optimizingJobID - The job ID of the optimizing job to retrieve.
Returns:
The requested optimizing job, or null if it was not in the job cache or the configuration directory.
Throws:
SLAMDServerException - If it is necessary to retrieve the job information from the configuration directory and a problem occurs while doing so.

getOptimizingJobs

public OptimizingJob[] getOptimizingJobs()
Retrieves the set of optimizing jobs that are currently held in the cache, in order of least recently used to most recently used.

Returns:
The set of optimizing jobs that are currently held in the cache.

addJob

public void addJob(Job job)
Adds the specified information to the job cache. If the job cache is already full, then the least recently used job will be removed to make room for the job.

Parameters:
job - The job to be added to the cache.

addOptimizingJob

public void addOptimizingJob(OptimizingJob optimizingJob)
Adds the specified optimizing job to the cache. If the job cache is already full, then the least recently used job will be removed to make room for the job.

Parameters:
optimizingJob - The optimizing job to be added to the cache.

deleteJob

public void deleteJob(java.lang.String jobID)
Removes the information about the specified job from the job cache.

Parameters:
jobID - The ID of the job to be removed from the cache.

deleteOptimizingJob

public void deleteOptimizingJob(java.lang.String optimizingJobID)
Removes the information about the specified optimizing job from the job cache.

Parameters:
optimizingJobID - The ID of the optimizing job to be removed from the cache.

flush

public void flush()
Removes all information stored in this job cache.