[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework Main.java, 1.14, 1.15
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-05 21:49:44
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5287 Modified Files: Main.java Log Message: no message Index: Main.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/Main.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Main.java 29 Aug 2006 02:01:33 -0000 1.14 --- Main.java 5 Sep 2006 21:49:42 -0000 1.15 *************** *** 4,8 **** import java.util.Map; import org.apache.log4j.Logger; - import org.jmonks.batchserver.framework.ErrorCode; import org.jmonks.batchserver.framework.util.FrameworkUtil; import org.jmonks.batchserver.framework.config.ConfigurationException; --- 4,7 ---- *************** *** 34,37 **** --- 33,41 ---- { private static Logger logger=Logger.getLogger(Main.class); + + /** + * Key name have the value of the job name in configuration map. + */ + public static final String JOB_NAME_KEY_NAME = "job-name"; /** *************** *** 67,91 **** * * @return Returns zero for success and non-zero for failure. */ public static ErrorCode process(Map configMap) { ! logger.error("Entering process = " + configMap); ErrorCode returnCode=ErrorCode.JOB_COMPLETED_SUCCESSFULLY; - String jobName=null; JobManagementAgent jobManagementAgent=null; try { ! jobName=(String)configMap.get("job-name"); logger.debug("Job to be invoked = " + jobName); if(jobName!=null && !"".equals(jobName.trim())) { /** - * Get the framework configuration and initialize the framework logging. - */ - logger.debug("Retrieving the framework configuration"); - FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); - logger.debug("Initializing the framework logging"); - LoggingManager.initializeFrameworkLogging(frameworkConfig.getFrameworkLoggingConfig()); - /** * Get the job configuration from the configuration factory. */ --- 71,103 ---- * * @return Returns zero for success and non-zero for failure. + * + * @throws IllegalArgumentException If input configMap is null. */ public static ErrorCode process(Map configMap) { ! if(configMap==null) ! throw new IllegalArgumentException("Argument configMap cannot be null."); ! ErrorCode returnCode=ErrorCode.JOB_COMPLETED_SUCCESSFULLY; JobManagementAgent jobManagementAgent=null; + String jobName=null; try { ! /** ! * Get the framework configuration and initialize the framework logging. ! */ ! logger.debug("Retrieving the framework configuration"); ! FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); ! logger.debug("Initializing the framework logging"); ! LoggingManager.initializeFrameworkLogging(frameworkConfig.getFrameworkLoggingConfig()); ! /** ! * Get the job name from given configMap and start execution. ! */ ! logger.error("Received configuration map = " + configMap); ! jobName=(String)configMap.get(Main.JOB_NAME_KEY_NAME); logger.debug("Job to be invoked = " + jobName); if(jobName!=null && !"".equals(jobName.trim())) { /** * Get the job configuration from the configuration factory. */ *************** *** 94,117 **** logger.debug("Retrieving the job configuration"); JobConfig jobConfig=jobConfigFactory.getJobConfig(jobName); ! /** ! * Initialize the job logging and kick off the controller after ! * registering it to the management agent. ! */ ! logger.debug("Initializing the job logging"); ! LoggingManager.initializeJobLogging(jobName,frameworkConfig.getFrameworkLoggingConfig(), jobConfig.getJobLoggingConfig()); ! logger.debug("Creating the job controller"); ! JobController jobController=JobController.getJobController(jobName, jobConfig.getJobControllerConfig()); ! logger.debug("Retrieving the management agent"); ! jobManagementAgent=JobManagementAgent.getJobManagementAgent(); ! logger.debug("Registering the controller with the management agent"); ! jobManagementAgent.start(jobName, jobController); ! logger.error("Kicking off the controller"); ! returnCode=jobController.process(); ! /** ! * Save the statistics into repository ! */ ! JobStatistics jobStatistics=jobController.getJobStatistics(); ! logger.info(jobStatistics); ! Repository.getRepository().logStatistics(jobStatistics); } else --- 106,138 ---- logger.debug("Retrieving the job configuration"); JobConfig jobConfig=jobConfigFactory.getJobConfig(jobName); ! if(jobConfig!=null) ! { ! /** ! * Initialize the job logging and kick off the controller after ! * registering it to the management agent. ! */ ! logger.debug("Initializing the job logging"); ! LoggingManager.initializeJobLogging(jobName,frameworkConfig.getFrameworkLoggingConfig(), jobConfig.getJobLoggingConfig()); ! logger.debug("Creating the job controller"); ! JobController jobController=JobController.getJobController(jobName, jobConfig.getJobControllerConfig()); ! logger.debug("Retrieving the management agent"); ! jobManagementAgent=JobManagementAgent.getJobManagementAgent(); ! logger.debug("Registering the controller with the management agent"); ! jobManagementAgent.start(jobName, jobController); ! logger.error("Kicking off the controller"); ! returnCode=jobController.process(); ! /** ! * Save the statistics into repository ! */ ! JobStatistics jobStatistics=jobController.getJobStatistics(); ! logger.info(jobStatistics); ! Repository.getRepository().logStatistics(jobStatistics); ! } ! else ! { ! logger.fatal("Unable to find the job configuration for the given job = " + jobName ! + " in the configured job configuration factory = " + jobConfigFactory.toString()); ! returnCode=ErrorCode.JOB_IS_NOT_CONFIGURED; ! } } else *************** *** 131,135 **** { exception.printStackTrace(); ! logger.fatal("Exception while processing the job = " + exception.getMessage(),exception); returnCode=ErrorCode.JOB_COMPLETED_WITH_ERRORS.appendMessage(exception.getMessage()); } --- 152,156 ---- { exception.printStackTrace(); ! logger.fatal("Exception while processing the job = " + jobName + " Message = "+ exception.getMessage(),exception); returnCode=ErrorCode.JOB_COMPLETED_WITH_ERRORS.appendMessage(exception.getMessage()); } *************** *** 183,191 **** { exception.printStackTrace(); ! logger.fatal("Exception while parsing the command line parameters = " + exception.getMessage(),exception); System.exit(ErrorCode.JOB_INVOKATION_CONFIGURAION_ERROR.getCode()); } ErrorCode errorCode=Main.process(configMap); ! logger.info("Job finished = " + errorCode.toString()); System.exit(errorCode.getCode()); } --- 204,213 ---- { exception.printStackTrace(); ! logger.fatal("Exception while parsing the command line parameters = " + args ! + " Message = " + exception.getMessage(),exception); System.exit(ErrorCode.JOB_INVOKATION_CONFIGURAION_ERROR.getCode()); } ErrorCode errorCode=Main.process(configMap); ! logger.error("Job finished = " + errorCode.toString()); System.exit(errorCode.getCode()); } |