[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/controller/pool AbstractPoolJob
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-15 06:21:15
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16940/framework/controller/pool Modified Files: AbstractPoolJobLoader.java AbstractPoolJobProcessor.java PoolJobController.java PoolJobLoader.java PoolJobProcessor.java Log Message: no message Index: PoolJobProcessor.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/PoolJobProcessor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PoolJobProcessor.java 14 Sep 2006 23:05:13 -0000 1.9 --- PoolJobProcessor.java 15 Sep 2006 06:21:12 -0000 1.10 *************** *** 7,11 **** * <p> * PoolJobProcessor gets the job data to be processed from the job pool and ! * processes it. Along with the processing methods, it exposes some method used * by management and monitoring clients. * </p> --- 7,11 ---- * <p> * PoolJobProcessor gets the job data to be processed from the job pool and ! * processes it. Along with the processing methods, it exposes some methods used * by management and monitoring clients. * </p> *************** *** 19,24 **** /** * <p> ! * Process the job data getting from the job pool and quits when job pool ! * out of the job data(returns null). * </p> * --- 19,42 ---- /** * <p> ! * Process the job data available in the job pool until the job loader done loading ! * of all the job data. JobContext reference provides the access to ! * many different resources in the framework. Following is an examples shows ! * the sample implementation of processPool method. ! * <br><br> ! * <pre> ! * public class MyPoolJobProcessor implements PoolJobProcessor ! * { ! * public ErrorCode processPool(JobContext jobContext, JobPool pool) ! * { ! * Object jobData=null; ! * while((jobData=pool.getNextJobData())!=null) ! * { ! * // Perform the business logic on jobData ! * } ! * ! * return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; ! * } ! * } ! * </pre> * </p> * Index: AbstractPoolJobLoader.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/AbstractPoolJobLoader.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AbstractPoolJobLoader.java 14 Sep 2006 23:04:59 -0000 1.11 --- AbstractPoolJobLoader.java 15 Sep 2006 06:21:12 -0000 1.12 *************** *** 210,214 **** * <br> * <pre> ! * public class MyLoader extends AbstractPoolJobLoader * { * public ErrorCode loadPool(JobContext jobContext) --- 210,214 ---- * <br> * <pre> ! * public class MyPoolJobLoader extends AbstractPoolJobLoader * { * public ErrorCode loadPool(JobContext jobContext) Index: PoolJobLoader.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/PoolJobLoader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PoolJobLoader.java 14 Sep 2006 23:05:13 -0000 1.10 --- PoolJobLoader.java 15 Sep 2006 06:21:12 -0000 1.11 *************** *** 28,36 **** * Example loading the 100 integer objects into the pool. * <pre> ! * public class MyLoader implements PoolJobLoader * { * public ErrorCode loadPool(JobContext jobContext, JobPool pool) * { ! * for(int i=0;i<100;i++ * pool.loadJobData(new Integer(i)); * pool.loadJobData(null); --- 28,36 ---- * Example loading the 100 integer objects into the pool. * <pre> ! * public class MyPoolJobLoader implements PoolJobLoader * { * public ErrorCode loadPool(JobContext jobContext, JobPool pool) * { ! * for(int i=0;i<100;i++) * pool.loadJobData(new Integer(i)); * pool.loadJobData(null); Index: AbstractPoolJobProcessor.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/AbstractPoolJobProcessor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractPoolJobProcessor.java 14 Sep 2006 23:04:59 -0000 1.8 --- AbstractPoolJobProcessor.java 15 Sep 2006 06:21:12 -0000 1.9 *************** *** 12,16 **** * Abstract pool job processor implements some of the responsiblites defined by the * pool job processor and leaves the application specific functionality implementation ! * to the final processor. * </p> * --- 12,46 ---- * Abstract pool job processor implements some of the responsiblites defined by the * pool job processor and leaves the application specific functionality implementation ! * to the final processor. Following is an example class shows how to make use of the ! * AbstractPoolJobProcessor. ! * <br><br> ! * <pre> ! * public class MyPoolJobProcessor extends AbstractPoolJobProcessor ! * { ! * private Connection connection=null; ! * ! * public void initialize(JobContext jobContext) ! * { ! * // Perform the initialization for this instance of job processor. ! * // Good place to get any references to any resources to be used to ! * // to processing of all the job data. ! * connection=ConnectionManager.getDBConnection(); ! * } ! * ! * public ErrorCode process(Object jobData) ! * { ! * // Perform the business logic on the incoming jobData. ! * connection.performBusinessLogic(jobData); ! * ! * return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; ! * } ! * ! * public void cleanup() ! * { ! * // Do some cleanup after all the jobData has been processed. ! * connection.close(); ! * } ! * } ! * </pre> * </p> * *************** *** 51,58 **** * <p> * Initializes the processor implementation by calling the <i>initialize</i> ! * method by passing map contains the properties defined for the processor in ! * job configuration, gets the job data from the pool and passes that information ! * to the processor implementation for processing and cleansup the processor ! * implementation by calling the <i>cleanup</i>. * </p> * --- 81,88 ---- * <p> * Initializes the processor implementation by calling the <i>initialize</i> ! * method by passing job context reference, gets the job data from the pool ! * and passes that information to the processor implementation for ! * processing and cleans up the processor implementation by calling the <i>cleanup</i> ! * method. * </p> * *************** *** 219,226 **** /** * Execute the business logic on the given jobData and return the ! * appropriate error code. The format and type of jobData is depend ! * on the job loader. * * @param jobData Data to be processed. */ public abstract ErrorCode process(Object jobData); --- 249,260 ---- /** * Execute the business logic on the given jobData and return the ! * appropriate error code. The format and type of jobData is depends ! * on the job loader configured for the same job. Usually, there will be ! * an understanding between the loader and processor on the type of jobData ! * being loaded into the pool. * * @param jobData Data to be processed. + * + * @return Returns the status of the processingn of this jobData. */ public abstract ErrorCode process(Object jobData); Index: PoolJobController.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/PoolJobController.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PoolJobController.java 14 Sep 2006 23:05:12 -0000 1.16 --- PoolJobController.java 15 Sep 2006 06:21:12 -0000 1.17 *************** *** 36,52 **** * <pre> * <job-config job-name="process_file_abc"> ! * <job-controller controller-class-name="org.jmonks.batchserver.framework.controller.pool.PoolJobController" ! * controller-config-class-name="org.jmonks.batchserver.framework.config.PoolControllerConfig"> ! * <job-loader pool-job-loader-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> ! * <property key="loader-info1">loader-value1</property> ! * </job-loader> ! * <job-processor pool-job-processor-class-name="com.mycompany.batch.processfileabc.AbcJobLoader"> ! * <thread-count>1</thread-count> ! * <property key="processor-info1">processor-value1</property> ! * </job-processor> * <job-pool job-pool-class-name="org.jmonks.batchserver.framework.controller.pool.DefaultJobPool"> * <property key="pool-size">50000</property> * </job-pool> ! * <property key="controller-info1">controller-value1</property> * </job-controller> * <job-logging-config> --- 36,50 ---- * <pre> * <job-config job-name="process_file_abc"> ! * <job-controller controller-class-name="org.jmonks.batchserver.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.batchserver.framework.controller.pool.DefaultJobPool"> * <property key="pool-size">50000</property> * </job-pool> ! * <property key="pool-controller-config1">pool-controller-value1</property> * </job-controller> * <job-logging-config> *************** *** 57,61 **** * <br><br> * <i>DB Configuration is as follows</i> ! * <table> * <tr><td><b>TableName.ColumnName</b></td><td><b>Value</b></td></tr> * <tr><td>job_config.job_name</td><td>process_file_abc</td></tr> --- 55,59 ---- * <br><br> * <i>DB Configuration is as follows</i> ! * <table border="1"> * <tr><td><b>TableName.ColumnName</b></td><td><b>Value</b></td></tr> * <tr><td>job_config.job_name</td><td>process_file_abc</td></tr> *************** *** 401,404 **** --- 399,403 ---- this.jobStatistics.setEndTime(Calendar.getInstance().getTime()); + this.jobStatistics.setMaxMemeoryUsage(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()); this.jobStatistics.setRecordsProcessed(this.getProcessedRecordsCount()); |