org.jmonks.batch.framework.controller.pool
Class CollectionJobPool

java.lang.Object
  extended byorg.jmonks.batch.framework.controller.pool.CollectionJobPool
All Implemented Interfaces:
JobPool

public class CollectionJobPool
extends java.lang.Object
implements JobPool

Provides the implementation of job pool using java utility collections. This job pool implementation can be configured for any given job using the following configuration in job configuration.

       <job-pool job-pool-class-name="org.jmonks.batch.framework.controller.pool.CollectionJobPool">
           <property key="job-pool-size">50000</property>
       </job-pool>
  

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
protected  java.util.Map configProps
          Map holds the configuration defined for the job pool.
static int DEFAULT_COLLECTION_POOL_SIZE
          Default collection pool size.
protected  long loadedJobsCount
          Holds the number of job data objects have been loaded by job loader.
protected  EDU.oswego.cs.dl.util.concurrent.BoundedBuffer pool
          Java utility collection holds the job data objects.
protected static java.lang.String POOL_SIZE_PROPERTY_NAME
          Property name by which pool size will be associated with.
 
Constructor Summary
CollectionJobPool()
          Default constructor for the instantiation purposes.
 
Method Summary
 void cleanup()
          Removes all the entries from collection.
 long getLoadedJobDataCount()
          Returns the number of job data objects being loaded into the pool.
 java.lang.Object getNextJobData()
          Gets the next available job data(piece of information) to be processed.
 void initialize(JobContext jobContext)
          Initializes the collection job pool using the configuration defined in the job configuration.
 boolean loadJobData(java.lang.Object jobData)
          Job Loader will use this API to load the job data into the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLLECTION_POOL_SIZE

public static final int DEFAULT_COLLECTION_POOL_SIZE
Default collection pool size. This will be used when pool size is not configured or problem in obtaining the pool size.

See Also:
Constant Field Values

POOL_SIZE_PROPERTY_NAME

protected static final java.lang.String POOL_SIZE_PROPERTY_NAME
Property name by which pool size will be associated with.

See Also:
Constant Field Values

configProps

protected java.util.Map configProps
Map holds the configuration defined for the job pool. There might be properies needed other than initialization.


pool

protected EDU.oswego.cs.dl.util.concurrent.BoundedBuffer pool
Java utility collection holds the job data objects.


loadedJobsCount

protected long loadedJobsCount
Holds the number of job data objects have been loaded by job loader.

Constructor Detail

CollectionJobPool

public CollectionJobPool()
Default constructor for the instantiation purposes.

Method Detail

loadJobData

public boolean loadJobData(java.lang.Object jobData)
Description copied from interface: JobPool
Job Loader will use this API to load the job data into the pool. If job loader is done with the loading all the data to be processed, it should load null indicating that loading of all the job data has been done.

Specified by:
loadJobData in interface JobPool
Parameters:
jobData - Job data needs to be processed.
See Also:
JobPool.loadJobData(Object)

getNextJobData

public java.lang.Object getNextJobData()
Description copied from interface: JobPool
Gets the next available job data(piece of information) to be processed. If it is not available, it will be waited until it gets the next job data. If loader is done with loading the jobs, it returns null. At this time, processor should quit its processing.

Specified by:
getNextJobData in interface JobPool
Returns:
Returns the next available job data to be process, null if no job data is available.
See Also:
JobPool.getNextJobData()

initialize

public void initialize(JobContext jobContext)
Initializes the collection job pool using the configuration defined in the job configuration. It gets the pool size from the defined configuration, by looking for the property "job-pool-size", if it couldnt find it uses the default pool size "1000" and initializes the collection to be used as the pool.

Specified by:
initialize in interface JobPool
Parameters:
jobContext - Context of the job being run.

cleanup

public void cleanup()
Removes all the entries from collection.

Specified by:
cleanup in interface JobPool

getLoadedJobDataCount

public long getLoadedJobDataCount()
Description copied from interface: JobPool
Returns the number of job data objects being loaded into the pool.

Specified by:
getLoadedJobDataCount in interface JobPool
Returns:
Returns the number of job data objects being loaded into the pool.
See Also:
JobPool.getLoadedJobDataCount()