[Batchserver-cvs] DefaultRepository.java,NONE,1.1 JobContext.java,NONE,1.1 JobStatistics.java,NONE,1
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-03 04:20:03
|
Update of /cvsroot/batchserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30411 Added Files: DefaultRepository.java JobContext.java JobStatistics.java LoggingManager.java Main.java Repository.java Log Message: Submitting the class skeltons --- NEW FILE: JobContext.java --- package org.jmonks.batchserver.framework; import org.jmonks.batchserver.framework.config.*; /** * <p> * This class provides the interface to access various resources outside the framework. * This allows to access the framework configuration and get the reference * to repsoitory. * </p> * @author : Suresh Pragada * @version 1.0 */ public class JobContext { private static JobContext context = new JobContext(); private Repository mRepository; private JobContext() { } public static org.jmonks.batchserver.framework.JobContext getInstance() { return null; } /** * Gets the repository configured for this framework. It it cannot locate * the repository or cannot access the repository, it returns null. * * @return Returns the repository configured for this framework, null, if * it cannot access the repository. */ public org.jmonks.batchserver.framework.Repository getReposiotry() { return null; } /** * Gets the framework configuration. * * @return Gets the framework configuration, null, if it cannot locate * the framework-config.xml file. */ public FrameworkConfig getFrameworkConfig() { return null; } } --- NEW FILE: JobStatistics.java --- package org.jmonks.batchserver.framework; /** * This represents all the statistics related to the job. * * @author : Suresh Pragada * @version 1.0 */ public class JobStatistics { private Date startTime; private Date endTime; private int recordsProcessed; private int maxMemoryUsage; private String jobName; public JobStatistics() { } /** * Sets the startime of the job. * * @param startTime Starting time of the job. */ public void setStartTime(Date startTime) { } /** * Sets the endtime of the job. * * @param endTime Ending time of the job. */ public void setEndTime(Date endTime) { this.endTime = endTime; } /** * Sets the number of the records processed in this job. * * @param recordCount Sets the number of records got processed. */ public void setRecordsProcessed(int recordCount) { this.recordsProcessed = recordCount; } /** * Sets the maximum memory used for the job. * * @param memoryUsaeg Sets the memory usage by the job. */ public void setMaxMemeoryUsage(int memoryUsage) { } /** * Gets the start time of this job. * * @return Returns the starting time of this job. */ public Date getStartTime() { return startTime; } /** * Gets the ending time of this job. * * @return Gets the end time of this job. */ public Date getEndTime() { return endTime; } /** * Gets the number of records processed. * * @return Returns the number of records got processed. */ public int getRecordsProcessed() { return recordsProcessed; } /** * Gets the maximum memory used by this job. * * @return Returns the max memory used by this job. */ public int getMaxMemoryUsage() { return maxMemoryUsage; } /** * Gets the job name * * @return Returns the name of this job. */ public String getJobname() { return null; } /** * Sets the name of the job. * * @param jobName Name of the job. */ public void setJobname(String jobName) { } } --- NEW FILE: LoggingManager.java --- package org.jmonks.batchserver.framework; import org.jmonks.batchserver.framework.config.*; /** * <p> * This class provides the logging services to the framework. * It defines the default logging mechanism at the framework level * which works for all the jobs and provide the facility to * use their own logging mechanism. * * The default logging mechanism defined at the framework will * work like this. It reads the directory to create the log files from * the framework logging configuration <logging-directory> and creates a directory * with the "job-name" and create the log files for each run. So, the format * will be * <br><br> * <directory-defined-in-config>/job-name/jobname_with_timestamp.log * <br><br> * * If job developer would like to override this logging mechanism, they can * define their logging configuration in the element <job-config> in batch * configuration file. * </p> * @author : Suresh Pragada * @version 1.0 */ public class LoggingManager { private static LoggingManager loggingManager = new LoggingManager(); private LoggingManager() { } public static LoggingManager getInstance() { return null; } /** * <p> * This method accepts all the information available from framwork configuration * and job configuration and loads the required loggers appropriately. If jobLoggingConfig * is null, it uses frameworkLoggingConfig to initialize the logging. * * @param jobName Name of the job. * @param frameworkLoggingConfig Logging configuration defined at the framework. * @param jobLogginConfig Logging configuration defined at the job. * </p> */ public void loadLogging(String jobName, org.jmonks.batchserver.framework.config.FrameworkLoggingConfig frameworkLoggingConfig, org.jmonks.batchserver.framework.config.JobLoggingConfig jobLoggingConfig) { } } --- NEW FILE: Repository.java --- package org.jmonks.batchserver.framework; import org.jmonks.batchserver.framework.config.*; import org.jmonks.batchserver.framework.controller.*; /** * <p> * This interface provides utility methods to access and use the repository. * There could be differnt implementations of the repository. Framework * configuration defines which implementation should be used for this framework. * This povides utility methods to logs the job statistics and persist any objects, * transfer some information between the jobs and transfer some management and monitor * information between framework and server. * </p> * @author : Suresh Pragada * @version 1.0 */ public abstract class Repository { private Repository() { } public static void getRepository(org.jmonks.batchserver.framework.config.RepositoryConfig config) { } /** * This method logs the job statistics given in the form JobStatistics object * in the repository for further use. * * @param statistics Job Statistics object which holds all the statistics related to that job. * * @return Returns true if statistics can be logged, false, otherwise. */ public abstract boolean logStatistics(org.jmonks.batchserver.framework.JobStatistics statistics); /** * Given data will be sent to the specified job behalf of this job. * * @param srcJN Name of the source job. * @param srcCmp Name of the source componenet. * @param tgtJN Name of the target job. * @param tgtCmp Name of the target component. * @param data data that needs to be sent as the object. * * @return Returns true, if it could save the data to be sent to the next job. */ public abstract boolean sendDatatoNextJob(String srcJN, String srcCmp, String tgtJN, String tgtCmp, Object data); /** * Gets the data that has been sent to this job. * * @param srcJN Name of the source job. * @param srcCmp Name of the source componenet. * @param tgtJN Name of the target job. * @param tgtCmp Name of the target component. * * @return Returns the data, null, it it couldnt find any data. */ public abstract Object getDataFromPreviousJob(String srcJN, String srcCmp, String tgtJN, String tgtCmp); /** * Registers the job management and monitoring info with the given job name. * * @param jobName Name of the job. * @param registrationInfo Information to be associated with this job name. * * @return Return true, if it could assosciate this information, false, otherwise. */ public abstract boolean registerJobMgmtMntrInfo(String jobName, Object registrationInfo); /** * Retrieves the management and monitoring information assosciated with this job. * * @param jobName Name of the job. * * @return Returns the registered information, null, if it doesnt find any information. */ public abstract Object lookupJobMgmtMntrInfo(String jobName); /** * Unregisters the job management and monitoring info assosciated with the given job name. * * @param jobName Name of the job. * * @return Return true, it it could unregister the information, false, otherwise. */ public abstract boolean unregisterJobMgmtMntrInfo(String jobName); /** * Gets the statistics related to that given job as a JobStatistics object array. * * @param jobName Name of the job for which statistics are required. * @return Returns the array of JobStatistics object, null, if it couldnt find any job with that name. */ public abstract org.jmonks.batchserver.framework.JobStatistics[] getStatistics(String jobName); /** * Persist the controller in repository. This will be useful, when job wants to be restarted. * When controller receives stop signal from servier with restart flag, it persist itself into * the repository. * * @param jobName Name of the job * @param controller Controller object to be persisted. * * @return Returns true, if it could persist the controller, false, otherwise. */ public abstract boolean saveController(org.jmonks.batchserver.framework.controller.JobController controller, String jobName); /** * Loads the controller assosicated with this job name in the repsoitory. When controller starts * execution, always, it looks into the reposiotry for restart. This can be overriden by passing addition * configuration property. * * @param jobName Name of the job. * @return Returns the controller object, null, if it couldnt find any. */ public abstract org.jmonks.batchserver.framework.controller.JobController loadController(String jobName); /** * Releases the persistedcontroller object from repository. * * @param jobName Name of the job. * @return Returns true, if it could release the controller from repository, null, otherwise. */ public abstract boolean releaseController(String jobName); } --- NEW FILE: Main.java --- package org.jmonks.batchserver.framework; import java.util.HashMap; import java.util.Map; import org.jmonks.batchserver.framework.config.*; import org.jmonks.batchserver.framework.mgmtmntr.*; import org.jmonks.batchserver.framework.controller.*; import org.jmonks.batchserver.framework.common.*; /** * <p> * This class is the interface to the batch framework. * This provides the methods accept the information to identify the job and kick off. * 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. * <br><br> * </p> * * @author : Suresh Pragada * @version 1.0 */ public class Main { private MgmtMntrManager mMgmtMntrManager; 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> * import org.jmonks.batchserver.framework.Main; * import java.util.Map; * import java.util.HashMap(); * * Map configMap=new HashMap(); * configMap.put("job-name","process_file_abc"); * configMap.put("config-name1","config-value1"); * configMap.put("config-name2","config-value2"); * Main main=new Main(); * int errorCode=main.process(configMap); * System.out.println("Job exited with return code : " + errorCode); * </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 org.jmonks.batchserver.framework.common.StatusCode process(Map configMap) { return null; } /** * <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> * The format to invoke the job using this interface is as follows. <br> * 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 * */ public static void main(String args[]) { Map configMap=new HashMap(); /** * parse command line parameters and populate the map. **/ Main main=new Main(); int errorCode=main.process(configMap); System.exit(errorCode); } } --- NEW FILE: DefaultRepository.java --- package org.jmonks.batchserver.framework; /** * <p> * This implementation of repository uses the DB4O database as the repository. It expects the following two properties present in the repository configuration in framework-cofig.xml file. * <br><br> * <pre> * <repository-config repository-class-name="org.jmonks.batchserver.framework.DefaultRepository"> * <property key="repository-location">/batchserver/repository</property> * <property key="repository-filename">batchserver_repository.db</property> * </repository-config> * </pre> * <br><br> * Here repository-location defines where the DB4O database needs to be created and repository-filename defines the name of the file to be used as the repository. * * </p> * @author : Suresh Pragada * @version 1.0 */ public abstract class DefaultRepository extends Repository { DefaultRepository(java.util.Map configProps) { } /** * @see org.jmonks.batchserver.framework.Repository#logStatistics(org.jmonks.batchserver.framework.JobStatistics) */ public boolean logStatistics(org.jmonks.batchserver.framework.JobStatistics statistics) { return true; } /** * @see org.jmonks.batchserver.framework.Repository#sendDataToNextJob(String,String,String,String,Object) */ public boolean sendDatatoNextJob(String srcJN, String srcCmp, String tgtJN, String tgtCmp, Object data) { return true; } /** * @see org.jmonks.batchserver.framework.Repository#getDataFromPreviousJob(String,String,String,String) */ public Object getDataFromPreviousJob(String srcJN, String srcCmp, String tgtJN, String tgtCmp) { return null; } /** * @see org.jmonks.batchserver.framework.Repository#registerJobMgmtMntrInfo(String,Object) */ public boolean registerJobMgmtMntrInfo(String jobName, Object registrationInfo) { return true; } /** * @see org.jmonks.batchserver.framework.Repository#lookupJobMgmtMntrInfo(String) */ public Object lookupJobMgmtMntrInfo(String jobName) { return null; } /** * @see org.jmonks.batchserver.framework.Repository#unregisterJobMgmtMntrInfo(String) */ public boolean unregisterJobMgmtMntrInfo(String jobName) { return true; } /** * @see org.jmonks.batchserver.framework.Repository#getStatistics(String) */ public org.jmonks.batchserver.framework.JobStatistics[] getStatistics(String jobName) { return null; } /** * @see org.jmonks.batchserver.framework.Repository#saveController(org.jmonks.batchserver.framework.controller.JobController,String) */ public boolean saveController(org.jmonks.batchserver.framework.controller.JobController controller, String jobName) { return true; } /** * @see org.jmonks.batchserver.framework.Repository#loadController(String) */ public org.jmonks.batchserver.framework.controller.JobController loadController(String jobName) { return null; } /** * @see org.jmonks.batchserver.framework.Repository#releaseController(String) */ public boolean releaseController(String jobName) { return true; } /** * <p> * This is the inner class in the DefaultRepository class to hold the data being transferred between the jobs. This will not have any functionality except holding the data. * </p> * @author : Suresh Pragada * @version 1.0 */ public class JobDataTransfer { private String sourceJobName; private String sourceComponentName; private Object data; private int targetJobName; private int targetComponentName; public JobDataTransfer() { } } } |