[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework Main.java,1.8,1.9
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-05-23 03:16:34
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25263/org/jmonks/batchserver/framework 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.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Main.java 19 May 2006 18:55:17 -0000 1.8 --- Main.java 23 May 2006 03:16:29 -0000 1.9 *************** *** 6,9 **** --- 6,10 ---- import org.jmonks.batchserver.framework.common.ErrorCode; import org.jmonks.batchserver.framework.common.FrameworkUtil; + import org.jmonks.batchserver.framework.config.ConfigurationException; import org.jmonks.batchserver.framework.config.FrameworkConfig; import org.jmonks.batchserver.framework.config.JobConfig; *************** *** 17,24 **** /** * <p> ! * Main class is the interface to the batch framework. ! * This provides the methods to accept the information to identify the job and kick off the jobs. ! * The framework can be executed either through command line as an independent program or from any other java program. ! * The information on how to kickoff using these two methods available in {@link #main(String[])} and {@link #process(Map)} methods of this class. * </p> * --- 18,27 ---- /** * <p> ! * Main class is the entry point to the batch framework. This provides ! * the methods to accept the information to identify the job and kick off the job. ! * The framework can be executed either through command line as an independent ! * program or from any other java program. The information on how to kickoff using ! * these two methods available in {@link #main(String[])} and {@link #process(java.util.Map)} ! * methods of this class. * </p> * *************** *** 30,42 **** { private static Logger logger=Logger.getLogger(Main.class); - - public Main() - { - } - /** * <p> ! * This method provides the interface to execute the job from another java program. This accepts the job-name and additional configuration information relate to this job as a key value pairs in the map. Among the entries in the map, there should be job-name key available. * <br><br> * <pre> --- 33,44 ---- { private static Logger logger=Logger.getLogger(Main.class); /** * <p> ! * This method provides the interface to execute the job from another java ! * program. This accepts the job-name and additional configuration information ! * relate to this job as a key value pairs in the map. Among the entries ! * in the map, there should be <i>job-name</i> key available with the values ! * as a name of the job to be executed. * <br><br> * <pre> *************** *** 47,76 **** * * ErrorCode statusCode=Main.process(configMap); ! * System.out.println("Job exited with return code : " + errorCode.getErrorCode()); * </pre> * <br><br> ! * Whatever the configuration key values passed here will override the values defined in job configuration. * </p> * <br> * @param configMap Map object consist of all the properties needed to kick off this batch job. * @return Returns zero for success and non-zero for failure. */ public static ErrorCode process(Map configMap) { ! logger.trace("Entering process"); ErrorCode returnCode=ErrorCode.JOB_COMPLETED_SUCCESSFULLY; try { ! String jobName=(String)configMap.get("job-name"); ! FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); ! LoggingManager.initializeFrameworkLogging(frameworkConfig.getFrameworkLoggingConfig()); ! JobConfigFactory jobConfigFactory=JobConfigFactory.getJobConfigFactory(frameworkConfig.getJobConfigFactoryConfig()); ! JobConfig jobConfig=jobConfigFactory.getJobConfig(jobName); ! LoggingManager.initializeJobLogging(jobName,frameworkConfig.getFrameworkLoggingConfig(), jobConfig.getJobLoggingConfig()); ! JobController jobController=JobController.getJobController(jobName, jobConfig.getJobControllerConfig()); ! JobManagementAgent jobManagementAgent=JobManagementAgent.getJobManagementAgent(); ! jobManagementAgent.start(jobName, jobController); ! returnCode=jobController.process(); ! jobManagementAgent.stop(returnCode); } catch(Throwable exception) --- 49,110 ---- * * ErrorCode statusCode=Main.process(configMap); ! * System.out.println("Job exited with return code : " + errorCode.toString()); * </pre> * <br><br> ! * Whatever the configuration key values passed here will override the values ! * defined in job configuration. * </p> * <br> + * * @param configMap Map object consist of all the properties needed to kick off this batch job. + * * @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"); ! if(jobName!=null && !"".equals(jobName.trim())) ! { ! logger.debug("Job to be invoked = " + jobName); ! logger.debug("Retrieving the framework configuration"); ! FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); ! logger.debug("Initializing the framework logging"); ! LoggingManager.initializeFrameworkLogging(frameworkConfig.getFrameworkLoggingConfig()); ! logger.debug("Retrieving the job config factory"); ! JobConfigFactory jobConfigFactory=JobConfigFactory.getJobConfigFactory(frameworkConfig.getJobConfigFactoryConfig()); ! logger.debug("Retrieving the job configuration"); ! JobConfig jobConfig=jobConfigFactory.getJobConfig(jobName); ! 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 ! */ ! } ! else ! { ! logger.fatal("job-name parameter cannot be found in the configuration to kick of the job = " + jobName); ! returnCode=ErrorCode.JOB_INVOKATION_CONFIGURAION_ERROR; ! } ! } ! catch(ConfigurationException exception) ! { ! exception.printStackTrace(); ! logger.fatal("Configuration Exception in the component " + exception.getExceptionComponent() + ! " while processing the job = " + jobName + " Message = " + exception.getMessage(),exception); ! returnCode=exception.getErrorCode(); } catch(Throwable exception) *************** *** 80,84 **** returnCode=ErrorCode.JOB_COMPLETED_WITH_ERRORS.appendMessage(exception.getMessage()); } ! logger.trace("Exiting process"); return returnCode; } --- 114,124 ---- returnCode=ErrorCode.JOB_COMPLETED_WITH_ERRORS.appendMessage(exception.getMessage()); } ! finally ! { ! logger.debug("Unregistering the controller with the management agent"); ! if(jobManagementAgent!=null) ! jobManagementAgent.stop(returnCode); ! } ! logger.error("Exiting process = " + returnCode); return returnCode; } *************** *** 87,91 **** /** * <p> ! * This method provides the interface to execute the jobs from command line. This accepts the job name/job config and additional configuration information relate to this job as a command line parameters. Each parameter passed through line should be in the format name=value. Among these, either "jobname=xxxxxx" or "jobconfig=xxxxxxxxx" should exist. If these two passed in the parameters, job will exit with error. If job is invoking in independent mode through this method, the return value will be return as exit code. So, exit should be considered as return value. * </p> * <p> --- 127,136 ---- /** * <p> ! * This method provides the interface to execute the jobs from command line. ! * This accepts the job name and additional configuration information relate ! * to this job as a command line parameters. Each parameter passed through ! * command line should be in the format <i>name=value</i>. Among these, ! * <i>job-name=process_file_abc</i> property should exist. ! * The ErrorCode's code value will be return as exit code. * </p> * <p> *************** *** 93,100 **** * java org.jmonks.batchserver.framework.Main job-name=process_file_abc config-name1=config-value1 config-name2=config-value2 * <br><br> - * java org.jmonks.batchserver.framework.Main job-name=<job-config>...</job-config> config-name1=config-value1 config-name2=config-value2 - * <br><br> * Whatever the configuration paremters passed here will override the values defined in job configuration. * </p> * @param args Configuration details in command line params as name=value format * --- 138,144 ---- * java org.jmonks.batchserver.framework.Main job-name=process_file_abc config-name1=config-value1 config-name2=config-value2 * <br><br> * Whatever the configuration paremters passed here will override the values defined in job configuration. * </p> + * * @param args Configuration details in command line params as name=value format * *************** *** 102,107 **** public static void main(String args[]) { ! logger.info("Job started"); Map configMap=new HashMap(); try { --- 146,154 ---- public static void main(String args[]) { ! logger.info("Job processing has been started"); Map configMap=new HashMap(); + /** + * Translate the command line parameters into the configuration map. + */ try { *************** *** 119,127 **** System.exit(ErrorCode.JOB_INVOKATION_CONFIGURAION_ERROR.getCode()); } ! ! Main main=new Main(); ! ErrorCode errorCode=main.process(configMap); ! logger.info("Job finished = " + errorCode); System.exit(errorCode.getCode()); } } --- 166,177 ---- System.exit(ErrorCode.JOB_INVOKATION_CONFIGURAION_ERROR.getCode()); } ! ErrorCode errorCode=Main.process(configMap); ! logger.info("Job finished = " + errorCode.toString()); System.exit(errorCode.getCode()); } + + private ErrorCode getErrorCode(String componentName) + { + return null; + } } |