Thread: [Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/repository Repository.java, 1.6
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-12 23:23:19
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/repository In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21414 Modified Files: Repository.java Log Message: no message Index: Repository.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/repository/Repository.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Repository.java 12 Sep 2006 04:07:55 -0000 1.6 --- Repository.java 12 Sep 2006 23:23:14 -0000 1.7 *************** *** 16,24 **** * by the framework. 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 job controllers, ! * transfer some information between the jobs and transfer some management and monitor ! * information between framework and server. Repository make sure only one instance ! * of the implementation class will be created (implements the singleton pattern) ! * and will be used through out the system/job. * </p> * <p> --- 16,24 ---- * by the framework. 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 ! * transfer data between the jobs and register management and monitoring ! * information between. Repository make sure only one instance ! * of the implementation class will be created and it will be associated with the ! * job being run and all the opertions performated will be taken that job as a source job. * </p> * <p> *************** *** 29,32 **** --- 29,33 ---- * this implementation from the factory method. * </p> + * * @author Suresh Pragada * @version 1.0 *************** *** 44,47 **** --- 45,58 ---- /** + * Flag tells that repository instance creation has been attempted or not. + */ + private static boolean isCreationAttempted=false; + + /** + * Name of the job associated with the repository. + */ + protected String jobName=null; + + /** * Method to initialize the repository implementation with the properties * defined in the framework configuration. *************** *** 56,79 **** /** ! * Factory method returns the specific implementation of repository based on the ! * repository configuration in framework configuration file. * ! * @throws ConfigurationException If repositoryClassName is missing or invalid ! * or it cannot be instantiated because of the lack of mandatory properties required ! * by the specific repository implementations. */ ! public static synchronized Repository getRepository() { ! logger.trace("Entering getRepository"); ! if(repository==null) { ! FrameworkConfig.RepositoryConfig repositoryConfig=FrameworkConfig.getInstance().getRepositoryConfig(); ! if(repositoryConfig==null) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "repository configuration is not defined in framework configuration"); ! String repositoryClassName=repositoryConfig.getRepositoryClassName(); if(repositoryClassName==null || "".equals(repositoryClassName)) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "repository class name is not defined in repository configuration"); logger.debug("repository class name = " + repositoryClassName); --- 67,100 ---- /** ! * <p> ! * Creates the repository instance based on the given configuration and associate ! * this repository instance with the given job. So all the repository opertions ! * performed from one job will be associated with that job only. This method ! * will be called by framework before kicking off the controller. Do not attempt ! * to call this method to create the repository from the client code. ! * </p> * ! * @throws IllegalStateException If there is an attempt is to create the repository ! * instance more than once. ! * @throws IllegalArgumentException If jobName is null to create the repository instance. ! * @throws ConfigurationException If required configuration properties are missing or the values ! * are invalid. */ ! public static synchronized void createRepository(String jobName, FrameworkConfig.RepositoryConfig repositoryConfig) { ! logger.trace("Entering createRepository"); ! if(isCreationAttempted) ! throw new IllegalStateException("Attempt to create the repsoitory has been done once."); ! else { ! if(jobName==null || "".equals(jobName)) ! throw new IllegalArgumentException("Job Name cannot be null or empty to create repository instance."); ! if(repositoryConfig==null) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "Repository configuration is not defined in framework configuration"); ! String repositoryClassName=repositoryConfig.getRepositoryClassName(); if(repositoryClassName==null || "".equals(repositoryClassName)) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "Repository class name is not defined in repository configuration"); logger.debug("repository class name = " + repositoryClassName); *************** *** 82,85 **** --- 103,107 ---- repository=(Repository)Class.forName(repositoryClassName).newInstance(); repository.init(repositoryConfig.getRepositoryConfigProperties()); + repository.jobName=jobName; logger.debug("created the repository implemenation class"); } *************** *** 102,113 **** throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); } } ! else ! { ! /** ! * Reposiotry instance has been initialized already. ! */ ! } ! logger.trace("Exiting getRepository " + (repository!=null)); return repository; } --- 124,145 ---- throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); } + isCreationAttempted=true; } ! logger.trace("Exiting createRepository " + (repository!=null)); ! } ! ! /** ! * <p> ! * Returns the repository instance. ! * <br><br> ! * If repository is configured for the framework, it will create the ! * instance and associated this with the running job and then kick off the ! * controller. If repository is not configured, it returns null. ! * </p> ! * ! * @return Returns configured repository instance, null if it is not configured. ! */ ! public static Repository getRepository() ! { return repository; } *************** *** 121,127 **** * </p> * ! * @param dataIdentifier Identifier to be used to exchange the data between two jobs.. ! * @param sourceJobName Name of the source job. ! * @param targetJobName Name of the target job. * @param data Data that needs to be sent as the object. * --- 153,158 ---- * </p> * ! * @param dataIdentifier Identifier to be used to exchange the data between two jobs. ! * @param nextJobName Name of the job this data to be send. * @param data Data that needs to be sent as the object. * *************** *** 130,135 **** * @throws IllegalArgumentException If any one of the input values is null. */ ! public abstract boolean sendDataToNextJob(String dataIdentifier, String sourceJobName, ! String targetJobName, final Object data); /** --- 161,166 ---- * @throws IllegalArgumentException If any one of the input values is null. */ ! public abstract boolean sendDataToNextJob(String dataIdentifier, String nextJobName, ! final Object data); /** *************** *** 138,143 **** * * @param dataIdentifier Identifier tied to the data wants to be read. ! * @param sourceJobName Name of the source job. ! * @param sourceComponent Name of the source componenet. * * @return Returns the data, null, if it couldnt find any data. --- 169,173 ---- * * @param dataIdentifier Identifier tied to the data wants to be read. ! * @param previousJobName Name of the job sent the data to this job. * * @return Returns the data, null, if it couldnt find any data. *************** *** 145,150 **** * @throws IllegalArgumentException If any one of the input values is null. */ ! public abstract Object getDataFromPreviousJob(String dataIdentifier, String sourceJobName, ! String targetJobName); /** --- 175,179 ---- * @throws IllegalArgumentException If any one of the input values is null. */ ! public abstract Object getDataFromPreviousJob(String dataIdentifier, String previousJobName); /** *************** *** 152,216 **** * This method will clear all the data that has been put up by * this job. Usually, this will be called by startp of framework, ! * before kickoff the controller. * </p> - * - * @param jobName Name of job that put up the data. - * - * @throws IllegalArgumentException If input job name is null. */ ! public abstract boolean clearDataTransferredFromThisJob(String jobName); /** * <p> ! * Registers the job management and monitoring info with the given job name. ! * If there is an info association with this job name, that information ! * will be overriden. This could happen, if job forgot to unregister the ! * management and monitoring information. * </p> * ! * @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. * ! * @throws IllegalArgumentException If input arguments jobname or registration information ! * values are null. ! */ ! public abstract boolean registerJobMgmtMntrInfo(String jobName, final 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. ! * ! * @throws IllegalArgumentException If input argument job name is null. */ ! 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. - * - * @throws IllegalArgumentException If input argument job name is null. */ ! public abstract boolean unregisterJobMgmtMntrInfo(String jobName); /** - * Gets all the management and monitoring information registered in the repository - * as a map, where jobname represents the key and management and monitoring information as value. - * - * @return Returns the map contains the job names as keys and management and - * monitoring information as values. - */ - public abstract Map getAllRegisteredMgmtMntrInfo(); - - /** * Logs the job statistics given in the form of JobStatistics object ! * in the repository for further use/reference. * * @param statistics Job Statistics object which holds all the statistics related to that job. --- 181,215 ---- * This method will clear all the data that has been put up by * this job. Usually, this will be called by startp of framework, ! * before kicking off the controller. * </p> */ ! public abstract boolean clearDataTransferredFromThisJob(); /** * <p> ! * Registers the given job management and monitoring info with the job. ! * If there is any information already associated with this job, it ! * will be overriden. * </p> * ! * @param registrationInfo Information to be associated with the job. * * @return Return true, if it could assosciate this information, false, otherwise. * ! * @throws IllegalArgumentException If input argument registration information ! * value is null. */ ! public abstract boolean registerJobMgmtMntrInfo(final Object registrationInfo); /** ! * Unregisters the job management and monitoring info assosciated with the job. * * @return Return true, it it could unregister the information, false, otherwise. */ ! public abstract boolean unregisterJobMgmtMntrInfo(); /** * Logs the job statistics given in the form of JobStatistics object ! * in the repository for further use/references. * * @param statistics Job Statistics object which holds all the statistics related to that job. *************** *** 221,279 **** */ public abstract boolean logStatistics(final JobStatistics statistics); - - /** - * 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. zero length statistics array, if it doestnt find any. - * - * @throws IllegalArgumentException If input argument job name is null. - */ - public abstract JobStatistics[] getStatistics(String jobName); - - //////// Following APIs are for future use. - //////// /** - //////// * <p> - //////// * Persist the controller in repository with the given job name. - //////// * If there are any controller entries with this job name, it removes them - //////// * first and then saves this controller. 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. - //////// * </p> - //////// * - //////// * @param jobName Name of the job - //////// * @param controller Controller object to be persisted. - //////// * - //////// * @return Returns true, if it could persist the controller, false, otherwise. - //////// * - //////// * @throws IllegalArgumentException If input arguments job name or controller is null. - //////// */ - //////// public abstract boolean saveController(String jobName, final JobController controller); - //////// - //////// /** - //////// * <p> - //////// * 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. - //////// * </p> - //////// * - //////// * @param jobName Name of the job. - //////// * - //////// * @return Returns the controller object, null, if it couldnt find any. - //////// * - //////// * @throws IllegalArgumentException If input arguments job name is null. - //////// */ - //////// public abstract 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. - //////// * - //////// * @throws IllegalArgumentException If input arguments job name is null. - //////// */ - //////// public abstract boolean releaseController(String jobName); } --- 220,222 ---- |