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

java.lang.Object
  extended byorg.jmonks.batch.framework.JobController
      extended byorg.jmonks.batch.framework.controller.pool.PoolJobController
All Implemented Interfaces:
JobManagerMBean, JobMonitorMBean

public class PoolJobController
extends JobController

PoolJobController provides the job architecture based on the pool concept, where a loader is load all the information to be processed into the pool and processors(>=1) retrieves the information from pool and process them. It provides the abstract loader and processor classes to be overriden by job implementation and comes with different implementation of pools.

To write any job using this controller, developer needs to write a loader class extends AbstractPoolJobLoader, which loads the data needs to be processed into the pool and write a processor class extending the AbstractPoolJobProcessor, which process the data from the pool. Once implementation is done, this job should be configured either using the XML configuration or DB configuration.

XML Configuration is as follows

    <job-config job-name="process_file_abc">
        <job-controller controller-class-name="org.jmonks.batch.framework.controller.pool.PoolJobController">
            <pool-job-loader pool-job-loader-class-name="com.mycompany.batch.processfileabc.AbcJobLoader">
                <property key="pool-job-loader-config1">pool-job-loader-value1</property>
            </pool-job-loader>
            <pool-job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobProcessor" thread-count="5">
                <property key="pool-job-processor-config1">pool-job-processor-value1</property>
            </pool-job-processor>
            <job-pool job-pool-class-name="org.jmonks.batch.framework.controller.pool.CollectionJobPool">
                <property key="pool-size">50000</property>
            </job-pool>
            <property key="pool-controller-config1">pool-controller-value1</property>
        </job-controller>
        <job-logging-config>
            <logging-property-file>com.mycompany.batch.processfileabc.Logging</logging-property-file>
        </job-logging-config>
    </job-config>
 


DB Configuration is as follows
TableName.ColumnNameValue
job_config.job_nameprocess_file_abc
job_config.job_status1
job_config.job_controller_class_nameorg.jmonks.batch.framework.controller.pool.PoolJobController
job_config.job_controller_propspool-controller-config1=pool-controller-value1:pool-controller-config1=poo2-controller-value2
pool_job_controller_config.job_nameprocess_file_abc
pool_job_controller_config.pool_job_loader_class_namecom.mycompany.batch.processfileabc.AbcJobLoader
pool_job_controller_config.pool_job_loader_propspool-job-loader-key1=loader-value1
pool_job_controller_config.pool_job_processor_class_namecom.mycompany.batch.processfileabc.AbcJobProcessor
pool_job_controller_config.pool_job_processor_propspool-job-processor-key1=processor-value1
pool_job_controller_config.pool_job_processor_thread_cnt5
pool_job_controller_config.job_pool_class_nameorg.jmonks.batch.framework.controller.pool.CollectionJobPool
pool_job_controller_config.job_pool_propsjob-pool-size=5000

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
 
Fields inherited from class org.jmonks.batch.framework.JobController
jobContext
 
Constructor Summary
PoolJobController()
          Constructor enables the instantiation of the pool job controller instance.
 
Method Summary
 long getExpectedRecordsCount()
          Returns the total number of records this job going to process.
 JobStatistics getJobStatistics()
          Returns the statistics of this job.
 long getProcessedRecordsCount()
          Number of records got processed so far.
 java.lang.String[] getProcessorIDList()
          Returns the IDs assigned to all the processors, loader as a string array.
 ProcessorState getProcessorState(java.lang.String processorID)
          Returns the current state of the processor identified by the given processor ID as the ProcessorState object.
 ProcessorStatus getProcessorStatus(java.lang.String processorID)
          Returns the status of the processor identified by the given processor ID.
 ErrorCode process()
           Executes the job by creating the pool, loader and processor(s) based on the configuration and have them work accordingly to process the job.
 boolean resume(java.lang.String processorID)
          Resumes the processor identified by given processor ID.
 boolean stop(java.lang.String processorID)
          Stops the processor identified by the given processor ID.
 boolean suspend(java.lang.String processorID)
          Suspends the processor identified by the given processor ID.
 
Methods inherited from class org.jmonks.batch.framework.JobController
changeLogLevel, createJobController, getLogLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PoolJobController

public PoolJobController()
Constructor enables the instantiation of the pool job controller instance.

Method Detail

process

public ErrorCode process()

Executes the job by creating the pool, loader and processor(s) based on the configuration and have them work accordingly to process the job.

Specified by:
process in class JobController
Returns:
Returns the processing error code for the job.

getExpectedRecordsCount

public long getExpectedRecordsCount()
Returns the total number of records this job going to process. This information will be obtained from the pool loader.

Returns:
Returns the number of records this job goint to process.

getProcessedRecordsCount

public long getProcessedRecordsCount()
Number of records got processed so far. This information will be obtained from the pool.

Returns:
Returns the number of records processed so far.

getProcessorIDList

public java.lang.String[] getProcessorIDList()
Returns the IDs assigned to all the processors, loader as a string array.

Returns:
Returns the string array consist of all the processor(s) and loader IDs.

getProcessorState

public ProcessorState getProcessorState(java.lang.String processorID)
Returns the current state of the processor identified by the given processor ID as the ProcessorState object.

Parameters:
processorID - processor ID identifies the processor or loader.
Returns:
Retuns the current state of the required processor.

getProcessorStatus

public ProcessorStatus getProcessorStatus(java.lang.String processorID)
Returns the status of the processor identified by the given processor ID.

Parameters:
processorID - ID assigned to each processor.
Returns:
Returns the status of the required processor.

stop

public boolean stop(java.lang.String processorID)
Stops the processor identified by the given processor ID.

Parameters:
processorID - ID assigned to each processor.
Returns:
Returns true, if processor could be stopped, false otherwise.

suspend

public boolean suspend(java.lang.String processorID)
Suspends the processor identified by the given processor ID.

Parameters:
processorID - ID assigned to each processor.
Returns:
Returns true if it could suspend the processor, false otherwise.

resume

public boolean resume(java.lang.String processorID)
Resumes the processor identified by given processor ID.

Parameters:
processorID - ID assigned to each processor.
Returns:
Returns true if processor is resumed, false otherwise.

getJobStatistics

public JobStatistics getJobStatistics()
Description copied from class: JobController
Returns the statistics of this job. Statistics will be queried only after the completion of controller processing. Querying before the completion of processing always returns null.

Specified by:
getJobStatistics in class JobController
Returns:
Returns the statistics of this job.
See Also:
org.jmonks.batch.framework.controller.JobController#getJobStatistics()