org.gridbus.broker.persistence
Class ActiveSet

java.lang.Object
  extended by org.gridbus.broker.persistence.ActiveSet

public class ActiveSet
extends java.lang.Object

The ActiveSet class is used to work with a subset of jobs / servers in the current broker instance. This class retrieves all the info from persistent storage and hence depends on the persistence provider for its functioning. The reader is assumed to return jobs in a sequence order by jobID/serverID. Internally it keeps a pointer (i.e stores the jobID/serverID), of the last retrieved job/server, when retrieving the jobs/servers sequentially (forward-only). Jobs/Servers can be retrieved in a forward-only manner. This pointer is updated whenever a getNextN* method is called. The pointer is *NOT* updated when any other method is called. (such as the getAll* methods).

Author:
krishna

Constructor Summary
ActiveSet(java.lang.Object config)
          The Constructor of the ActiveSet class expects to receive a properly set up writer and reader objects, which are ready to use.
 
Method Summary
 java.util.Collection getAllJobs()
          Returns a collection of all the jobs in the current broker instance.
 java.util.Collection getAllJobs(int jobStatus)
          Returns a collection of all the jobs in the current broker instance.
 long getJobCount(int jobStatus)
          Returns the total number of jobs with the given status
 long getJobCount(int status, java.lang.String serverID)
           
 java.util.Collection getNextNJobs(int N)
          Gets the next "N" jobs available from the persistent store, This method sequentially goes through the jobs in the database, starting from the first.
 java.util.Collection getNextNJobs(int N, int jobStatus)
          Gets the next "N" jobs available from the persistent store, with the given status
 Reader getReader()
           
 long getServerCount(int serverStatus)
          Returns the number of servers with the given status
 java.util.Collection getServers()
          Returns a collection of all the servers in the current broker instance.
 long getTotalJobCount()
          Returns the total number of jobs
 long getTotalServerCount()
          Returns the total number of servers
 Writer getWriter()
           
 void setServers(java.util.Vector servers)
           
 void storeJob(Job j)
           
 void storeJobs(java.util.Vector jobs)
           
 void storeServers(java.util.Vector servers)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActiveSet

public ActiveSet(java.lang.Object config)
The Constructor of the ActiveSet class expects to receive a properly set up writer and reader objects, which are ready to use.

Parameters:
config -
Method Detail

getWriter

public Writer getWriter()
Returns:

getReader

public Reader getReader()
Returns:

getAllJobs

public java.util.Collection getAllJobs()
Returns a collection of all the jobs in the current broker instance. If no jobs are found, an empty collection is returned.

Returns:

getTotalJobCount

public long getTotalJobCount()
Returns the total number of jobs

Returns:

getJobCount

public long getJobCount(int jobStatus)
Returns the total number of jobs with the given status

Parameters:
jobStatus -
Returns:

getAllJobs

public java.util.Collection getAllJobs(int jobStatus)
Returns a collection of all the jobs in the current broker instance. If no jobs are found, an empty collection is returned.

Parameters:
jobStatus -
Returns:

getNextNJobs

public java.util.Collection getNextNJobs(int N)
Gets the next "N" jobs available from the persistent store, This method sequentially goes through the jobs in the database, starting from the first. The job list is sorted by id. It remembers the id of last retrieved job, and each successive call to this method returns a collection which contains the next set of N jobs. If not jobs are available, then the collection is empty.

Parameters:
N -
Returns:

getNextNJobs

public java.util.Collection getNextNJobs(int N,
                                         int jobStatus)
Gets the next "N" jobs available from the persistent store, with the given status

Parameters:
N -
jobStatus -
Returns:

getServers

public java.util.Collection getServers()
Returns a collection of all the servers in the current broker instance.

Returns:

getTotalServerCount

public long getTotalServerCount()
Returns the total number of servers

Returns:

getServerCount

public long getServerCount(int serverStatus)
Returns the number of servers with the given status

Parameters:
serverStatus -
Returns:

setServers

public void setServers(java.util.Vector servers)
Parameters:
servers -

storeServers

public void storeServers(java.util.Vector servers)
Parameters:
servers -

storeJobs

public void storeJobs(java.util.Vector jobs)
Parameters:
jobs -

storeJob

public void storeJob(Job j)
Parameters:
j -

getJobCount

public long getJobCount(int status,
                        java.lang.String serverID)
Parameters:
status -
serverID -
Returns: