[Batchserver-cvs] batchserver/src/org/jmonks/batch/framework/management JobConnectorHelper.java, N
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-15 20:07:04
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batch/framework/management In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19938 Added Files: JobConnectorHelper.java JobManagementAgent.java JobManager.java JobManagerMBean.java JobMonitor.java JobMonitorMBean.java JobNotification.java ProcessorState.java ProcessorStatus.java Log Message: no message --- NEW FILE: JobMonitorMBean.java --- package org.jmonks.batch.framework.management; /** * <p> * JobMonitorMBean interface defines the methods to instrument the job being run * to find out the statistics of the job and to find out all the processor states * running in the controller. This follows the JMX standard MBean paradigm to define * name of the MBean and methods instrument the job. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public interface JobMonitorMBean { /** * Gets the total number of records this job might try to process. * * @return Returns the total number of records this job might try to process. */ public long getExpectedRecordsCount(); /** * Gets the records processed by this job so far. * * @return Returns the number of records processed by this job so far. */ public long getProcessedRecordsCount(); /** * Returns the array of IDs assigned to be processors running under this controller. * * @return Returns the array of IDs being assigned by each processor. */ public String[] getProcessorIDList(); /** * Gets the state of the processor identified by the given processor ID. * This returns the state in a ProcessorState object. * * @return Returns the state of the requested processor. */ public ProcessorState getProcessorState(String processorID); } --- NEW FILE: ProcessorStatus.java --- package org.jmonks.batch.framework.management; /** * <p> * ProcessorStatus defines the statuses that processors can be in the system. * </p> * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class ProcessorStatus { /** * Status indicates that processor is instantiated. */ public static ProcessorStatus INSTANTIATED = new ProcessorStatus("INSTANTIATED"); /** * Status indicates that processor is being initialized. */ public static ProcessorStatus INITIALIZING = new ProcessorStatus("INITIALIZING"); /** * Status indicates that processor is initailized. */ public static ProcessorStatus INITIALIZED = new ProcessorStatus("INITIALIZED"); /** * Status indicates that processor is running. */ public static ProcessorStatus RUNNING = new ProcessorStatus("RUNNING"); /** * Status indictes that processor is suspended. */ public static ProcessorStatus SUSPENDED = new ProcessorStatus("SUSPENDED"); /** * Status indicates the processor is stopped. */ public static ProcessorStatus STOPPED = new ProcessorStatus("STOPPED"); /** * Status indicates the processor is resumed. */ public static ProcessorStatus RESUMED = new ProcessorStatus("RESUMED"); /** * Status indicates the processor is being cleaned up. */ public static ProcessorStatus CLEANUP = new ProcessorStatus("CLEANUP"); /** * Status indicates the processor is finished. */ public static ProcessorStatus FINISHED = new ProcessorStatus("FINISHED"); /** * Varaible holds the status ID. */ private String statusID; /** * Constructor make sure all the constants have been defined inside this * class and takes the status ID. */ private ProcessorStatus(String statusID) { this.statusID=statusID; } /** * Returns the job status in string format. */ public String toString() { return this.statusID; } } --- NEW FILE: JobConnectorHelper.java --- /* * JobConnectorHelper.java * * Created on March 24, 2006, 8:04 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.management; import java.util.Map; import javax.management.remote.JMXConnectorServer; import org.apache.log4j.Logger; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.config.ConfigurationException; import org.jmonks.batch.framework.config.FrameworkConfig; /** * <p> * JobConnectorHelper defines the helper methods will be used in creating the * JMX connector server, registering and unregistering the JMX connector server * in lookup location and querying the registerd jobs in look up location and * creating the JMX connector clients. * Because of many possible implementations available in creating * the JMX connector server and lookup locations, this class defines the methods * to choose their own implementations. Mainly, Agent and client looks for the following * information and activities from the concrete implementations of the connector * helper class. * <br> * <ul> * <li>Create the JMX connector server. * <li>Register the given the JMX connector server in the lookup location with the given jobname. * <li>Unregister the JMX connector server available in lookup location with the given jobname. * <li>Get all the registered jobs in look up location as list. * <li>Get the JMX connector from the look up location for the requested job name. * </ul> * <br> * This class provides the factory method to return the configured JobConnectorHelper * instance by looking at the framework configuration and make sure only one * instance will be created for the job(jvm). * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public abstract class JobConnectorHelper { private static Logger logger=Logger.getLogger(JobConnectorHelper.class); /** * Singleton job connector helper instance. */ private static JobConnectorHelper jobConnectorHelper=null; /** * This factory method creates the correct implementation of JobConnectorHelper * based on the configuration defined in framework-config.xml file. * This looks for the following configuration and uses the class name provided * at the job-connector-helper-class-name attribute to create the helper * instance. * <br> * <pre> * <job-connector-config job-connector-helper-class-name="org.jmonks.batch.framework.management.jmxmp.repository.RepositoryJMXMPConnectorHelper"> * <property key="mgmt-mntr-config-key">mgmt-mntr-config-value</property> * </job-connector-config> * </pre> * * @return Returns the JobConnectorHelper implemenation. * * @throws ConfigurationException If configuration could not be found or * implementation class cannot be accessed or instantiated. */ public static synchronized JobConnectorHelper getJobConnectorHelper() { logger.trace("Entering getJobConnectorHelper"); if(jobConnectorHelper==null) { FrameworkConfig.JobConnectorConfig jobConnectorConfig=FrameworkConfig.getInstance().getJobConnectorConfig(); if(jobConnectorConfig==null) throw new ConfigurationException(ConfigurationException.JOB_CONNECTOR_CONFIG, "job connector configuration is not configured in framework configuration"); String jobConnectorHelperClassName=jobConnectorConfig.getJobConnectorHelperClassName(); logger.trace("Job connector helper class name = " + jobConnectorHelperClassName); try { jobConnectorHelper=(JobConnectorHelper)Class.forName(jobConnectorHelperClassName).newInstance(); jobConnectorHelper.init(jobConnectorConfig.getJobConnectorConfigProperties()); } catch(ClassNotFoundException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); throw new ConfigurationException(ConfigurationException.JOB_CONNECTOR_CONFIG, exception.getMessage()); } catch(InstantiationException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); throw new ConfigurationException(ConfigurationException.JOB_CONNECTOR_CONFIG, exception.getMessage()); } catch(IllegalAccessException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); throw new ConfigurationException(ConfigurationException.JOB_CONNECTOR_CONFIG, exception.getMessage()); } } logger.trace("Exiting getJobConnectorHelper"); return jobConnectorHelper; } /** * This method will be called after instantiating the JobConnectorHelper to * initialize JobConnectorHelper with the properties needed to create JMX connector server * and initialize the lookup location needed to register and unregister the JMX connector servers. * * @param configProps Properties defined for this connector server as a map. * * @throws ConfigurationException If required properties for this connector server are missing. */ protected abstract void init(Map configProps); /** * Creates the JMX connector server based on the desired connector protocol. * * @return Returns the JMX connector server, null, if helper cannot create the connector server. */ public abstract JMXConnectorServer createConnectorServer(); /** * Registers the jmx connector server with the job name taken from job context in the desired lookup location. * * @param jobContext Context of the job is being run. * @param jmxConnectorServer JMX connector server where all the manager and monnitor mbeans are configured. * * @return Returns true, if it successfully registred in lookup location, false, otherwise. * * @throws IllegalArgumentException If job name paramter is null. */ public abstract boolean registerConnectorServer(JobContext jobContext,JMXConnectorServer connectorServer); /** * Unregisters the jmx connector server registered in desired lookup location with the * job name available in job context. * * @param jobContext Context of the job is being run. * * @return Returns true, if it successfully unregistered, false otherwise. * * @throws IllegalArgumentException If job name paramter is null. */ public abstract boolean unregisterConnectorServer(JobContext jobContext); } --- NEW FILE: JobManagerMBean.java --- package org.jmonks.batch.framework.management; import org.apache.log4j.Level; /** * <p> * This standard MBean interface provides the methods to instrument the * job controller and processors running under the job controller. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public interface JobManagerMBean { /** * Returns the status of the processor identified by the given processor ID. * * @param processorID ID assigned to each processor. * * @return Returns the processor status. */ public ProcessorStatus getProcessorStatus(String processorID); /** * Controller should stop processing of the processor identified by the * given processor ID. * * @param processorID ID assigned to each processor. * * @return Returns true, if processor has been stopped, false otherwise. */ public boolean stop(String processorID); /** * Controller should suspend processing of the processor identified by the * give processor ID. * * @param processorID ID assigned to each processor. * * @return Returns true, if processor has been suspended, false otherwise. */ public boolean suspend(String processorID); /** * Controller should resume processing of the processor identified by the * given processor ID. * * @param processorID ID assigned to each processor. * * @return Returns true, if processor can be resumed, false, otherwise. */ public boolean resume(String processorID); /** * Gets the log level of the given logger name. * * @param loggerName Name of the logger wants to find the log level. * * @return Returns the log level, null, if the given logger could not be found. */ public Level getLogLevel(String loggerName); /** * Changes the log level for the requested logger name with the given log level. * * @param loggerName Logger name needs to be modified. * @param newLogLevel new logging level. * * @return Returns true, if log level could be changed, false, otherwise. */ public boolean changeLogLevel(String loggerName,Level newLogLevel); } --- NEW FILE: JobNotification.java --- /* * JobNotification.java * * Created on April 5, 2006, 5:08 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.management; import java.util.Calendar; import javax.management.Notification; /** * Notification to send the specified job information and define the various * notification types. * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class JobNotification extends Notification { /** * Name of the job this notification belongs to. */ private String jobName=null; /** * Used to generate the sequence number. */ private static int sequence=1; /** * Notification type specifies that the job got finished. */ public static final String JOB_FINISHED = "job.status.finished"; /** * Creates a new instance of JobNotification */ public JobNotification(String jobName,String type,Object source,String message) { super(type,source,JobNotification.sequence++,Calendar.getInstance().getTimeInMillis(),message); if(jobName==null) throw new IllegalArgumentException("job name cannot be null to create the job notification."); this.jobName=jobName; } /** * Gets the job name; */ public String getJobName() { return this.jobName; } /** * <p> * Returns the string representation of JobNotification class in the format * <br> {JobNotification [jobName = value] [rest = value] } * </p> * * @return Returns the string representation of JobNotification. */ public String toString() { StringBuffer stringValue=new StringBuffer("{JobNotification "); stringValue.append("[jobName = " + this.jobName + "]"); stringValue.append("[rest = " + super.toString() + "]"); stringValue.append("}"); return stringValue.toString(); } } --- NEW FILE: JobManagementAgent.java --- package org.jmonks.batch.framework.management; import java.io.IOException; import javax.management.InstanceAlreadyExistsException; import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; import javax.management.remote.JMXConnectorServer; import org.apache.log4j.Logger; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.Main; import org.jmonks.batch.framework.config.ConfigurationException; import org.jmonks.batch.framework.controller.JobController; /** * <p> * JobManagementAgent defines the methods to start and stop the JMX Agent for this job. * Only one agent will be created for a job and this can be created only be the framework. * Agent service can be started and stopped only once during the life cycle of the job. This uses * the JobConnectorHelper to take the help in creating different JMX * connector servers and register and unregister jmx connector servers to be looked up * by the JMX connector clients. * </p> * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class JobManagementAgent { /** * Mbean Server domain name. */ public static final String MBEAN_SERVER_DOMAIN_NAME = "EnterpriseBatchServer"; /** * Name of the bean that manages this job. */ public static final String JOB_MANAGER_MBEAN_NAME = "JobManagerMBean"; /** * Name of the bean monitors this job. */ public static final String JOB_MONITOR_MBEAN_NAME = "JobMonitorMBean"; /** * Singleton job management agent instance. */ private static final JobManagementAgent jobManagementAgent=new JobManagementAgent(); /** * JMX Connector server instance created for this agent. */ private JMXConnectorServer jmxConnectorServer=null; /** * Job connector helper instance. This defines the implementation * and lookup location of the JMX connector server. */ private JobConnectorHelper jobConnectorHelper=null; /** * Name of the job this agent configured for. */ private String jobName=null; /** * Tells whether the agent has been started or not. */ private boolean started=false; /** * Tells whether the agent has been stopped or not. */ private boolean stopped=false; private static Logger logger=Logger.getLogger(JobManagementAgent.class); /** * Initializes the job management agent. It make sure it would be able to get * the reference to job connector server helper class. * * @throws ConfigurationException If it couldnt get the job connector server helper class. */ private JobManagementAgent() { this.jobConnectorHelper=JobConnectorHelper.getJobConnectorHelper(); if(jobConnectorHelper==null) throw new ConfigurationException(ConfigurationException.JOB_CONNECTOR_CONFIG, "could not get the reference to job connector helper class."); } /** * Returns the job management agent instance. */ public static JobManagementAgent getJobManagementAgent() { return jobManagementAgent; } /** * <p> * This method start the job management agent with the given controller information. * Basicially, this does the following activities to start the management agent. * <br> * <ul> * <li>Creates the job manager and job monitor mbeans by passing the controller reference. * <li>Creates the MBeanServer and registers these two MBeans. * <li>Create the JMX Connector server based connector helper implementation. * <ii>Registers JMX Connector server in the lookup location defined by connector helper implementation. * <li>Marks the started flag as true to indicate that agent has been started. * </ul> * <br> * Agent can be started only once in the job life cycle. If it receives a request to start * when it is already started, it throws IllegalStateException. * </p> * * @param jobContext Context of the job is being run. * @param jobController Controller reference to be passed to the mbeans. * @param agentManager Main class reference as a agent manager. * * @return Returns true, if manager is started properly, false, otherwise. * * @throws SecurityException if an attempt is maded to start by any one other than Main(framework). * @throws IllegalArgumentException If input parameters job name or job controller is null. * @throws IllegalStateException If manager is already started or already stopped. */ public boolean start(JobContext jobContext, JobController jobController, Main agentManager) { logger.trace("Entering start"); if(!(agentManager instanceof Main)) throw new SecurityException("Not authorized to manage the agent."); if(this.started) throw new IllegalStateException("job management agent has been already started."); if(this.stopped) throw new IllegalStateException("job management agent has been already stopped."); if(jobContext==null) throw new IllegalArgumentException("job context cannot be null to start the job management agent."); if(jobController==null) throw new IllegalArgumentException("controller object cannot be null to start the job management agent."); this.jobName=jobContext.getJobName(); try { MBeanServer mbeanServer=MBeanServerFactory.createMBeanServer(JobManagementAgent.MBEAN_SERVER_DOMAIN_NAME); this.jmxConnectorServer=this.jobConnectorHelper.createConnectorServer(); if(this.jmxConnectorServer==null) { logger.error("Unable to get the jmx connector server from job connector helper implementation."); throw new ConfigurationException(ConfigurationException.JOB_CONNECTOR_CONFIG, "Unable to get the jmx connector server from job connector helper implementation."); } else { logger.debug("Got the jmx connector server from the implementation"); } /** * Create the mbeans and register them with this mbean server. */ JobMonitorMBean monitorBean=new JobMonitor(jobController); JobManagerMBean managerBean=new JobManager(jobController); ObjectName connectorServerObjectName= new ObjectName(JobManagementAgent.MBEAN_SERVER_DOMAIN_NAME+":jobName="+jobName+",objectType=JMXConnectorServer"); ObjectName monitorBeanObjectName= new ObjectName(JobManagementAgent.MBEAN_SERVER_DOMAIN_NAME+":jobName="+jobName+",objectType="+JobManagementAgent.JOB_MONITOR_MBEAN_NAME); ObjectName managerBeanObjectName= new ObjectName(JobManagementAgent.MBEAN_SERVER_DOMAIN_NAME+":jobName="+jobName+",objectType="+JobManagementAgent.JOB_MANAGER_MBEAN_NAME); mbeanServer.registerMBean(this.jmxConnectorServer, connectorServerObjectName); mbeanServer.registerMBean(monitorBean, monitorBeanObjectName); mbeanServer.registerMBean(managerBean, managerBeanObjectName); /** * Start the connector server and register it with the job name. */ this.jmxConnectorServer.start(); boolean registered=this.jobConnectorHelper.registerConnectorServer(jobContext,this.jmxConnectorServer); if(registered) { logger.debug("Successfully registered the connector server with the job name"); this.started=true; } else { logger.error("Unable to register the jmx connector server using job connector helper"); this.started=false; } } catch(MalformedObjectNameException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); } catch(InstanceAlreadyExistsException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); } catch(MBeanRegistrationException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); } catch(NotCompliantMBeanException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); } catch(IOException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); } logger.trace("Exiting start"); return this.started; } /** * Stops the JMX connector server, unregisters the MBeans and MBeanServer and * unregisters the jmx service url information from lookup location and marks * stopped flag as true to indicate that agent has been stopped. Given controller * exit status will be sent to all the JMX remote clients as a notification. * * @param jobContext Context of the job is being run. * @param exitCode errorCode returned by controller to the Main class. * @param agentManager Main class reference as a agent manager. * * @return Returns true, if agent could be stopped properly, false otherwise. * * @throws SecurityException if an attempt is maded to stop by any one other than Main(framework). * @throws IllegalArgumentException If input parameter status code is null. * @throws IllegalStateException If agent is already stopped or it not yet started. */ public boolean stop(JobContext jobContext, ErrorCode exitCode, Main agentManager) { logger.trace("Entering stop"); if(!(agentManager instanceof Main)) throw new SecurityException("Not authorized to manage the agent."); if(!this.started) throw new IllegalStateException("Job management agent has not been started."); if(this.stopped) throw new IllegalStateException("Job management agent has been stopped already."); if(jobContext==null) throw new IllegalArgumentException("Job context cannot be null to stop the server."); if(exitCode==null) throw new IllegalArgumentException("controller exit code cannot be null to stop the server."); try { JobNotification notification=new JobNotification(this.jobName, JobNotification.JOB_FINISHED, this, exitCode.toString()); this.jmxConnectorServer.sendNotification(notification); this.jmxConnectorServer.stop(); this.jobConnectorHelper.unregisterConnectorServer(jobContext); this.stopped=true; logger.debug("unregistered the jmx connector server from lookup location"); } catch(IOException exception) { exception.printStackTrace(); logger.error(exception.getMessage(),exception); this.stopped=false; } logger.trace("Exiting stop"); return this.stopped; } /** * Tells whether the agent is running or not. This state needs to be queried * before trying to stop the agent. * * @return Returns true if agent is running, false otherwise. */ public boolean isRunning() { return this.started; } } --- NEW FILE: JobMonitor.java --- /* * JobMonitor.java * * Created on March 25, 2006, 1:12 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.management; import org.jmonks.batch.framework.controller.JobController; /** * <p> * Implementation of job monitor mbean to instrument the job controller. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class JobMonitor implements JobMonitorMBean { private JobMonitorMBean jobMonitor=null; /** * Creates a new instance of JobMonitorMBean and initializes with job controller. * * @param jobController Job controller implements this interface. * * @throws IllegalArgumentException if input argument job controller is null. */ public JobMonitor(JobController jobController) { if(jobController==null) throw new IllegalArgumentException("job controller cannot be null to create the job monitor mbean."); this.jobMonitor=(JobMonitorMBean)jobController; } /** * @see org.jmonks.batch.framework.management.JobMonitorMBean#getExpectedRecordsCount */ public long getExpectedRecordsCount() { return this.jobMonitor.getExpectedRecordsCount(); } /** * @see org.jmonks.batch.framework.management.JobMonitorMBean#getProcessedRecordsCount */ public long getProcessedRecordsCount() { return this.jobMonitor.getProcessedRecordsCount(); } /** * @see org.jmonks.batch.framework.management.JobMonitorMBean#getProcessorIDList */ public String[] getProcessorIDList() { return this.jobMonitor.getProcessorIDList(); } /** * @see org.jmonks.batch.framework.management.JobMonitorMBean#getProcessorState(java.lang.String) */ public ProcessorState getProcessorState(String processorID) { return this.jobMonitor.getProcessorState(processorID); } } --- NEW FILE: JobManager.java --- /* * JobManager.java * * Created on March 25, 2006, 11:14 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.management; import javax.management.NotificationBroadcasterSupport; import org.apache.log4j.Level; import org.jmonks.batch.framework.controller.JobController; /** * <p> * JobManager instruments the job controller for management purposes. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class JobManager extends NotificationBroadcasterSupport implements JobManagerMBean { private JobManagerMBean jobManager=null; /** * Creates a new instance of JobManagerMBean and initializes with job controller. * * @param jobController Job controller implements this interface. * * @throws IllegalArgumentException if input argument job controller is null. */ public JobManager(JobController jobController) { if(jobController==null) throw new IllegalArgumentException("job controller cannot be null to create the job manager mbean."); this.jobManager=(JobManagerMBean)jobController; } /** * Controller should stop processing of the processor identified by the * given processor ID. * * @param processorID ID assigned to each processor. * * @return Returns true, if processor has been stopped, false otherwise. */ public boolean stop(String processorID) { return this.jobManager.stop(processorID) ; } /** * Controller should suspend processing of the processor identified by the * give processor ID. * * @param processorID ID assigned to each processor. * * @return Returns true, if processor has been suspended, false otherwise. */ public boolean suspend(String processorID) { return this.jobManager.suspend(processorID); } /** * Controller should resume processing of the processor identified by the * given processor ID. * * @param processorID ID assigned to each processor. * * @return Returns true, if processor can be resumed, false, otherwise. */ public boolean resume(String processorID) { return this.jobManager.resume(processorID); } /** * Returns the status of the processor identified by the given processor ID. * * @param processorID ID assigned to each processor. * * @return Returns the processor status. */ public ProcessorStatus getProcessorStatus(String processorID) { return this.jobManager.getProcessorStatus(processorID); } /** * Gets the log level of the given logger name. * * @param loggerName Name of the logger wants to find the log level. * * @return Returns the log level, null, if the given logger could not be found. */ public Level getLogLevel(String loggerName) { return this.jobManager.getLogLevel(loggerName); } /** * Changes the log level for the requested logger name with the given log level. * * @param loggerName Logger name needs to be modified. * @param newLogLevel new logging level. * * @return Returns true, if log level could be changed, false, otherwise. */ public boolean changeLogLevel(String loggerName, Level newLogLevel) { return this.jobManager.changeLogLevel(loggerName, newLogLevel); } } --- NEW FILE: ProcessorState.java --- package org.jmonks.batch.framework.management; /** * <p> * This represents the state of the processor(thread) running under the controller. * This gives the information like processor ID, description and * processing information. * </p> * * @author Suresh pragada * @version 1.0 * @since 1.0 */ public class ProcessorState { /** * Holds the processor ID. */ private String processorID; /** * Holds the processor description. */ private String processorDescription; /** * Holds the processing information. This can be anything that client and server * can understand. */ private Object processingInfo; /** * Constructor initializes the object. */ public ProcessorState(String processorID,String processorDescription,Object processingInfo) { this.processorID=processorID; this.processorDescription=processorDescription; this.processingInfo=processingInfo; } /** * Returns the processor ID. */ public String getProcessorID() { return this.processorID; } /** * Returns the processor description. */ public String getProcessorDescription() { return this.processorDescription; } /** * Returns the processor processing information. */ public Object getProcessingInfo() { return this.processingInfo; } /** * <p> * Returns the string representation of ProcessorState class in the format * <br> {ProcessorState [ID = value] [desc = value] [processingInfo = value]} * </p> * * @return Returns the string representation of ProcessorState. */ public String toString() { StringBuffer stringValue=new StringBuffer("{ProcessorState "); stringValue.append("[ID = " + this.processorID + "]"); stringValue.append("[desc = " + this.processorDescription + "]"); stringValue.append("[processingInfo = " + this.processingInfo + "]"); stringValue.append("}"); return stringValue.toString(); } } |