org.jmonks.batch.framework.controller.basic
Class BasicJobController

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

public class BasicJobController
extends JobController

BasicJobController creates and executes the Basic Job Processor class defined in job configuration. It creates the configured number of instances and have each instance run in a seperate thread. Once all the processors have finished their processing, returns the appropriate return code.

This controller is useful to write and execute a simple business logic stands on its own. Allows the flexibility to run that code in a number of instances. Following is an example configuration to configure the batch job written based on BasicJobController.

XML Configuration is as follows

    <job-config job-name="process_file_abc">
        <job-controller controller-class-name="org.jmonks.batch.framework.controller.basic.BasicJobController">
            <basic-job-processor basic-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobProcessor" thread-count="5">
                <property key="basic-job-processor-config1">basic-job-processor-value1</property>
            </basic-job-processor>
            <property key="basic-controller-config1">basic-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.basic.BasicJobController
job_config.job_controller_propsbasic-controller-config1=basic-controller-value1:basic-controller-config1=basic-controller-value2
basic_job_controller_config.job_nameprocess_file_abc
basic_job_controller_config.basic_job_processor_class_namecom.mycompany.batch.processfileabc.AbcJobProcessor
basic_job_controller_config.basic_job_processor_propsbasic-job-processor-config1=basic-job-processor-value1
basic_job_controller_config.basic_job_processor_thread_cnt1

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
 
Fields inherited from class org.jmonks.batch.framework.JobController
jobContext
 
Constructor Summary
BasicJobController()
          Constructor enables the instantiation of the basic 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()
          Returns the number of records processed so far.
 java.lang.String[] getProcessorIDList()
          Returns the IDs of all the processors as string array.
 ProcessorState getProcessorState(java.lang.String processorID)
          Returns the state of the requested processor as a 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 running the configured number of basic job processors and returns the appropriate errorcode.
 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

BasicJobController

public BasicJobController()
Constructor enables the instantiation of the basic job controller instance.

Method Detail

process

public ErrorCode process()

Executes the job by running the configured number of basic job processors and returns the appropriate errorcode. It collects all the return codes returned by job processors and return the first non successful return code it found in the list. If it doesnt find any non successful return code, it will return successful error code.

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 will be the sum of the expected count from all the job processors.

Returns:
Returns the total number of records the job going to process.

getProcessedRecordsCount

public long getProcessedRecordsCount()
Returns the number of records processed so far. This will be the sum of the processed count from all the job processors.

Returns:
Returns the count of processed records.

getProcessorIDList

public java.lang.String[] getProcessorIDList()
Returns the IDs of all the processors as string array.

Returns:
Returns the string array consist of all the processor IDs.

getProcessorState

public ProcessorState getProcessorState(java.lang.String processorID)
Returns the state of the requested processor as a ProcessorState object.

Returns:
Returns the processor state.

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 ProcessorStatus object represents the status.

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()