[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/controller/basic BasicJobControll
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-05-19 18:55:22
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/basic In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31715/org/jmonks/batchserver/framework/controller/basic Modified Files: BasicJobController.java BasicJobProcessor.java Log Message: no message Index: BasicJobProcessor.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/basic/BasicJobProcessor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BasicJobProcessor.java 14 May 2006 01:24:18 -0000 1.8 --- BasicJobProcessor.java 19 May 2006 18:55:17 -0000 1.9 *************** *** 126,159 **** /** * <p> ! * This method gets a chance to initialize the job processor. This will be called ! * before the <i>process</i> method being called. Properties configured for ! * job processor in job configuration will be passed as map to this method. ! * If job processor needs any resources, they can initialize them here. If ! * mulitple job processors have been configured, this method will be called ! * for each processor in the order they will be created. ! * </p> ! * ! * @param configProps Properties defined for job processor in the job configuration. ! */ ! public abstract void initialize(Map configProps); ! ! /** ! * <p> ! * This method let developer implement businses logic and return the appropriate ! * error code. * </p> * * @return Returns the appropriate error code needs to be passed to the invocation layer. */ ! public abstract ErrorCode process(); ! ! /** ! * <p> ! * This method gets a chance to do any cleanup if needed, after the ! * <i>process</i> method finished. This will be called irrespective of the ! * return status(even exceptions occured) of the <i>process</i> method. ! * </p> ! */ ! public abstract void cleanup(); /** --- 126,138 ---- /** * <p> ! * Does the processing and return the appropriate error code. Properties ! * configured for this job processor will be passed through the configProps. * </p> * + * @param configProps Properties defined for job processor in the job configuration. + * * @return Returns the appropriate error code needs to be passed to the invocation layer. */ ! public abstract ErrorCode process(Map configProps); /** Index: BasicJobController.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/controller/basic/BasicJobController.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BasicJobController.java 14 May 2006 01:24:18 -0000 1.9 --- BasicJobController.java 19 May 2006 18:55:17 -0000 1.10 *************** *** 75,96 **** String threadID=super.getJobName()+"_"+(i+1); BasicJobProcessor jobProcessor=this.getBasicJobProcessor(basicJobControllerConfig.getBasicJobProcessorClassName()); - /** - * Make seperate copy of property map for each processor and initialize with that map. - */ - Map processorConfigProperties=new HashMap(basicJobControllerConfig.getBasicJobProcessorConfigProperties()); - try - { - logger.debug("Going to initialize the " + threadID + " basic job processor"); - jobProcessor.initialize(processorConfigProperties); - logger.info("Done initializing the " + threadID + " basic job processor"); - } - catch(Throwable exception) - { - exception.printStackTrace(); - logger.error("Exception while initializing the " + threadID + " basic job processor = " + - exception.getMessage(), exception); - } FutureResult result=new FutureResult(); ! Thread processorThread=new Thread(result.setter(this.getCallableProcessor(countDownLock,jobProcessor)), threadID); processorThread.start(); this.jobProcessorsMap.put(threadID,jobProcessor); --- 75,81 ---- String threadID=super.getJobName()+"_"+(i+1); BasicJobProcessor jobProcessor=this.getBasicJobProcessor(basicJobControllerConfig.getBasicJobProcessorClassName()); FutureResult result=new FutureResult(); ! Thread processorThread=new Thread(result.setter(this.getCallableProcessor ! (countDownLock,jobProcessor,basicJobControllerConfig.getBasicJobProcessorConfigProperties())), threadID); processorThread.start(); this.jobProcessorsMap.put(threadID,jobProcessor); *************** *** 303,307 **** * @return Returns the runnable instance. */ ! private Callable getCallableProcessor(final CountDown countDownLock,final BasicJobProcessor jobProcessor) { logger.trace("Entering getCallableProcessor"); --- 288,292 ---- * @return Returns the runnable instance. */ ! private Callable getCallableProcessor(final CountDown countDownLock,final BasicJobProcessor jobProcessor,final Map configProps) { logger.trace("Entering getCallableProcessor"); *************** *** 315,319 **** logger.debug("Status of registering thread with the processor = " + registered); logger.trace("Going to call the process method"); ! returnCode=jobProcessor.process(); logger.debug("Done calling the process method"); } --- 300,304 ---- logger.debug("Status of registering thread with the processor = " + registered); logger.trace("Going to call the process method"); ! returnCode=jobProcessor.process(new HashMap(configProps)); logger.debug("Done calling the process method"); } *************** *** 324,339 **** returnCode=ErrorCode.BASIC_JOB_PROCESSOR_EXCEPTION; } - // Need to call the processor cleanup all the time. - try - { - logger.trace("Going to call cleanup method"); - jobProcessor.cleanup(); - logger.debug("Done calling the cleanup method"); - } - catch(Throwable exception) - { - exception.printStackTrace(); - logger.error("Exception while doing the cleanup = " + exception.getMessage(), exception); - } countDownLock.release(); logger.info(Thread.currentThread().getName() + " is exiting with the error code = " + returnCode); --- 309,312 ---- *************** *** 375,379 **** { ErrorCode threadReturnCode=(ErrorCode)((FutureResult)iterator.next()).peek(); ! if(threadReturnCode!=ErrorCode.JOB_COMPLETED_SUCCESSFULLY) { returnCode=threadReturnCode; --- 348,352 ---- { ErrorCode threadReturnCode=(ErrorCode)((FutureResult)iterator.next()).peek(); ! if(!ErrorCode.JOB_COMPLETED_SUCCESSFULLY.equals(threadReturnCode)) { returnCode=threadReturnCode; |