[Batchserver-cvs] batchserver/src/org/jmonks/batch/framework/controller/basic BasicJobController.j
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-19 00:05:58
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batch/framework/controller/basic In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27472/framework/controller/basic Modified Files: BasicJobController.java Log Message: no message Index: BasicJobController.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batch/framework/controller/basic/BasicJobController.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicJobController.java 15 Sep 2006 20:06:39 -0000 1.1 --- BasicJobController.java 19 Sep 2006 00:05:52 -0000 1.2 *************** *** 3,6 **** --- 3,7 ---- import EDU.oswego.cs.dl.util.concurrent.CountDown; import EDU.oswego.cs.dl.util.concurrent.FutureResult; + import java.lang.reflect.InvocationTargetException; import java.util.Calendar; import java.util.Hashtable; *************** *** 114,117 **** --- 115,119 ---- this.jobStatistics=new JobStatistics(super.jobContext.getJobName()); this.jobStatistics.setStartTime(Calendar.getInstance().getTime()); + this.jobStatistics.setMaxMemeoryUsage(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()); for(int i=0;i<threadCount;i++) { *************** *** 124,128 **** this.jobProcessorsMap.put(threadID,jobProcessor); this.jobProcessorsResultMap.put(threadID, result); ! logger.info(threadID + " basic job processor has been kicked off."); } ErrorCode returnCode=hybernate(countDownLock); --- 126,130 ---- this.jobProcessorsMap.put(threadID,jobProcessor); this.jobProcessorsResultMap.put(threadID, result); ! logger.info(threadID + " basic job processor has been started."); } ErrorCode returnCode=hybernate(countDownLock); *************** *** 344,350 **** boolean registered=jobProcessor.registerThread(); logger.debug("Status of registering thread with the processor = " + registered); - logger.trace("Going to call the process method"); returnCode=jobProcessor.process(jobContext); ! logger.debug("Done calling the process method"); } catch(Throwable exception) --- 346,351 ---- boolean registered=jobProcessor.registerThread(); logger.debug("Status of registering thread with the processor = " + registered); returnCode=jobProcessor.process(jobContext); ! logger.debug("Done calling the process method. Return code = " + returnCode); } catch(Throwable exception) *************** *** 352,359 **** exception.printStackTrace(); logger.error("Exception while processing = " + exception.getMessage(), exception); ! returnCode=ErrorCode.BASIC_JOB_PROCESSOR_EXCEPTION; } countDownLock.release(); ! logger.info(Thread.currentThread().getName() + " is exiting with the error code = " + returnCode); return returnCode; } --- 353,361 ---- exception.printStackTrace(); logger.error("Exception while processing = " + exception.getMessage(), exception); ! returnCode=ErrorCode.BASIC_JOB_PROCESSOR_EXCEPTION.appendMessage(" Message from processor = " + exception.getMessage()); } + logger.trace(Thread.currentThread().getName() + " is going to release the countdown lock."); countDownLock.release(); ! logger.info(Thread.currentThread().getName() + " is exiting with the error code = " + returnCode); return returnCode; } *************** *** 379,385 **** try { ! logger.debug("Going to wait until all the processors is gonna finish."); countDownLock.acquire(); logger.info("All processors have finished their task."); } catch(InterruptedException exception) --- 381,398 ---- try { ! logger.debug("Going to wait until all the processors are going to finish."); countDownLock.acquire(); logger.info("All processors have finished their task."); + + logger.debug("Calculating the final return code from all the processors results."); + for(Iterator iterator=this.jobProcessorsResultMap.values().iterator();iterator.hasNext();) + { + ErrorCode threadReturnCode=(ErrorCode)((FutureResult)iterator.next()).get(); + if(!ErrorCode.JOB_COMPLETED_SUCCESSFULLY.equals(threadReturnCode) && threadReturnCode.getCode()>returnCode.getCode()) + { + returnCode=threadReturnCode; + } + } + logger.debug("Calculated result from all the processeors is " + returnCode); } catch(InterruptedException exception) *************** *** 389,406 **** return ErrorCode.BASIC_JOB_PROCESSOR_EXCEPTION; } ! ! this.jobStatistics.setEndTime(Calendar.getInstance().getTime()); ! this.jobStatistics.setMaxMemeoryUsage(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()); ! this.jobStatistics.setRecordsProcessed(this.getProcessedRecordsCount()); ! ! for(Iterator iterator=this.jobProcessorsResultMap.values().iterator();iterator.hasNext();) { ! ErrorCode threadReturnCode=(ErrorCode)((FutureResult)iterator.next()).peek(); ! if(!ErrorCode.JOB_COMPLETED_SUCCESSFULLY.equals(threadReturnCode)) ! { ! returnCode=threadReturnCode; ! break; ! } } this.jobStatistics.setExitCode(returnCode); logger.trace("Exiting hybernate = " + returnCode); --- 402,417 ---- return ErrorCode.BASIC_JOB_PROCESSOR_EXCEPTION; } ! catch(InvocationTargetException exception) { ! exception.printStackTrace(); ! logger.error("Exception while waiting for all the processors = " + exception.getMessage(), exception); ! return ErrorCode.BASIC_JOB_PROCESSOR_EXCEPTION; } + + this.jobStatistics.setEndTime(Calendar.getInstance().getTime()); + this.jobStatistics.setMaxMemeoryUsage( + (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())-this.jobStatistics.getMaxMemoryUsage() + ); + this.jobStatistics.setRecordsProcessed(this.getProcessedRecordsCount()); this.jobStatistics.setExitCode(returnCode); logger.trace("Exiting hybernate = " + returnCode); |