Thread: [Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/controller/pool AbstractPoolJobPr
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-05-16 03:15:32
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26153 Modified Files: AbstractPoolJobProcessor.java CollectionJobPool.java JobPool.java PoolJobLoader.java PoolJobProcessor.java Removed Files: AbstractPoolJobLoader.java Log Message: no message Index: PoolJobLoader.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/PoolJobLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PoolJobLoader.java 14 May 2006 01:31:32 -0000 1.3 --- PoolJobLoader.java 16 May 2006 03:15:28 -0000 1.4 *************** *** 1,4 **** --- 1,5 ---- package org.jmonks.batchserver.framework.controller.pool; import java.util.Map; + import org.jmonks.batchserver.framework.common.ErrorCode; import org.jmonks.batchserver.framework.management.ProcessorStatus; *************** *** 15,33 **** /** * Chance for the loader to initialize itself with the properties defined ! * in the job configuration and gets the reference to the job pool. * * @param configProps Configuration defined for the loader. - * @param pool Job Pool reference. */ ! public void initialize(Map configProps, JobPool pool); /** ! * Chance to do some cleanup before the job being shutdown. */ public void cleanup(); /** ! * Loads the job data to the job pool. When finished loading of all the job ! * data, loads the <i>NULL</i> into the pool. */ ! public void loadJobData(); /** * Suspends the loader. --- 16,51 ---- /** * Chance for the loader to initialize itself with the properties defined ! * in the job configuration. * * @param configProps Configuration defined for the loader. */ ! public void initialize(Map configProps); /** ! * Chance to do some cleanup before the job loader being shutdown. */ public void cleanup(); /** ! * <p> ! * Loads the job data to the given job pool. When finished loading of all the job ! * data, loads the <i>null</i> into the pool to singal the processor(s) that ! * loading of all the jobs have been done. ! * <br> ! * Example loading the 100 integer objects into the pool. ! * <pre> ! * public class MyLoader ! * { ! * public ErrorCode loadPool(JobPool pool) ! * { ! * for(int i=0;i<100;i++ ! * pool.loadJobData(new Integer(i)); ! * pool.loadJobData(null); ! * } ! * } ! * <pre> ! * </p> ! * ! * @param pool Job Pool reference. */ ! public ErrorCode loadPool(JobPool pool); /** * Suspends the loader. *************** *** 53,57 **** * @return Returns the number of records this loader is going to load. */ ! public int getTotalRecords(); /** * Gets the loader state as object which can be understan by the monitoring --- 71,75 ---- * @return Returns the number of records this loader is going to load. */ ! public int getTotalJobDataCount(); /** * Gets the loader state as object which can be understan by the monitoring Index: JobPool.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/JobPool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JobPool.java 15 May 2006 03:29:32 -0000 1.4 --- JobPool.java 16 May 2006 03:15:28 -0000 1.5 *************** *** 50,53 **** * @return Returns the number of job data objects being loaded into the pool. */ ! public int getLoadedCount(); } --- 50,53 ---- * @return Returns the number of job data objects being loaded into the pool. */ ! public int getLoadedJobDataCount(); } Index: PoolJobProcessor.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/PoolJobProcessor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PoolJobProcessor.java 14 May 2006 01:31:32 -0000 1.3 --- PoolJobProcessor.java 16 May 2006 03:15:28 -0000 1.4 *************** *** 2,5 **** --- 2,6 ---- import java.util.Map; + import org.jmonks.batchserver.framework.common.ErrorCode; import org.jmonks.batchserver.framework.management.ProcessorStatus; *************** *** 19,25 **** * * @param configProps Configuration defined for the job processor in job configuration. - * @param pool Reference to Job Pool. */ ! public void initialize(Map configProps, JobPool pool); /** * Suspends the pool job processor. --- 20,25 ---- * * @param configProps Configuration defined for the job processor in job configuration. */ ! public void initialize(Map configProps); /** * Suspends the pool job processor. *************** *** 48,54 **** * out of the job data(returns null). * ! * @return Returns the number of job data instances being procssed. */ ! public int process(); /** * Gets the processor to be displyed or anaylyzed for the monitoring purposes. --- 48,56 ---- * out of the job data(returns null). * ! * @param pool Reference to Job Pool. ! * ! * @return Returns the error code. */ ! public ErrorCode process(JobPool pool); /** * Gets the processor to be displyed or anaylyzed for the monitoring purposes. *************** *** 63,65 **** --- 65,74 ---- */ public ProcessorStatus getProcessorStatus(); + /** + * Returns the number of job data objects this particular job processor + * has finsihed. + * + * @return Returns the number of job data objects processed. + */ + public int getProcessedJobDataCount(); } Index: AbstractPoolJobProcessor.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/AbstractPoolJobProcessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractPoolJobProcessor.java 4 Mar 2006 04:42:01 -0000 1.2 --- AbstractPoolJobProcessor.java 16 May 2006 03:15:28 -0000 1.3 *************** *** 1,54 **** package org.jmonks.batchserver.framework.controller.pool; import java.util.Map; /** ! * <p> ! * Abstract job processor implements some of responsiblites defined by the job processor and leaves the application specific functionality implementation to the final processor. ! * </p> ! * @author : Suresh Pragada ! * @version 1.0 */ public abstract class AbstractPoolJobProcessor implements PoolJobProcessor { ! private JobPool mJobPool; ! public AbstractPoolJobProcessor() ! { ! } ! public abstract void initialize(Map configProps); ! public boolean suspend() { ! return true; } ! public boolean resume() { return true; } ! public boolean stop() { return true; } ! ! ! public abstract void cleanup(); ! ! public int processPool() { ! return 0; } ! public Object getProcessorState() { return null; } ! ! public void initialize(Map configProps, org.jmonks.batchserver.framework.controller.pool.JobPool pool) { } } --- 1,131 ---- package org.jmonks.batchserver.framework.controller.pool; + import EDU.oswego.cs.dl.util.concurrent.Mutex; import java.util.Map; + import org.apache.log4j.Logger; + import org.jmonks.batchserver.framework.common.ErrorCode; + import org.jmonks.batchserver.framework.management.ProcessorStatus; /** ! * <p> ! * 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> ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public abstract class AbstractPoolJobProcessor implements PoolJobProcessor { + /** + * Counts the number of job data objects processed. + */ + private int processedJobDataCount=0; ! private boolean stopSignal=false; ! ! private boolean suspendSignal=false; ! ! private Mutex suspendLock=new Mutex(); ! ! private static Logger logger=Logger.getLogger(AbstractPoolJobProcessor.class); ! ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#initialize(java.util.Map) ! */ public abstract void initialize(Map configProps); ! /** ! * ! */ ! public abstract ErrorCode process(Object jobData); ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#cleanup() ! */ ! public abstract void cleanup(); ! ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#suspend() ! */ public boolean suspend() { ! this.suspendSignal=true; ! return this.suspendSignal; } ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#resume() ! */ public boolean resume() { + this.stopSignal=false; + this.suspendSignal=false; + this.suspendLock.release(); return true; } ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#stop() ! */ public boolean stop() { return true; } ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#suspend() ! */ ! public ErrorCode processPool(JobPool pool) { ! Object jobData=null; ! while((jobData=pool.getNextJobData())!=null) ! { ! try ! { ! this.processedJobDataCount++; ! ErrorCode errorCode=this.process(jobData); ! } ! catch(Throwable exception) ! { ! exception.printStackTrace(); ! } ! if(this.stopSignal) ! { ! logger.info("Received the stop signal.. Preparing to stop"); ! break; ! } ! if(this.suspendSignal) ! { ! try ! { ! this.suspendLock.acquire(); ! } ! catch(InterruptedException exception) ! { ! exception.printStackTrace(); ! logger.error("Got exception while suspending..." + exception.getMessage(), exception); ! } ! } ! } ! return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#getProcessorState() ! */ public Object getProcessorState() { return null; } ! /** ! * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#getProcessorStatus() ! */ ! public ProcessorStatus getProcessorStatus() { + return null; + } + /** + * @see org.jmonks.batchserver.framework.controller.pool.PoolJobProcessor#getProcessedJobDataCount() + */ + public int getProcessedJobDataCount() + { + return processedJobDataCount; } } --- AbstractPoolJobLoader.java DELETED --- Index: CollectionJobPool.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/pool/CollectionJobPool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CollectionJobPool.java 15 May 2006 03:29:32 -0000 1.5 --- CollectionJobPool.java 16 May 2006 03:15:28 -0000 1.6 *************** *** 82,86 **** */ this.pool.put(END_OF_POOL); - System.out.println(Thread.currentThread().getName() + "Pushing end of pool"); } loaded=true; --- 82,85 ---- *************** *** 109,113 **** if(jobData==END_OF_POOL) { - System.out.println(Thread.currentThread().getName() + "Received end of pool"); this.pool.put(END_OF_POOL); jobData=null; --- 108,111 ---- *************** *** 144,149 **** { poolSize=Integer.parseInt(poolSizePropertyValue); ! // if(poolSize<1) ! // poolSize=CollectionJobPool.DEFAULT_COLLECTION_POOL_SIZE; } catch(Exception exception) --- 142,149 ---- { poolSize=Integer.parseInt(poolSizePropertyValue); ! if(poolSize<1) ! { ! poolSize=CollectionJobPool.DEFAULT_COLLECTION_POOL_SIZE; ! } } catch(Exception exception) *************** *** 171,177 **** /** ! * @see org.jmonks.batchserver.framework.controller.pool.JobPool#getLoadedCount */ ! public int getLoadedCount() { return this.loadedJobsCount; --- 171,177 ---- /** ! * @see org.jmonks.batchserver.framework.controller.pool.JobPool#getLoadedJobDataCount */ ! public int getLoadedJobDataCount() { return this.loadedJobsCount; |