org.jmonks.batch.framework.management
Class JobManagementAgent

java.lang.Object
  extended byorg.jmonks.batch.framework.management.JobManagementAgent

public class JobManagementAgent
extends java.lang.Object

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.

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
static java.lang.String JOB_MANAGER_MBEAN_NAME
          Name of the bean that manages this job.
static java.lang.String JOB_MONITOR_MBEAN_NAME
          Name of the bean monitors this job.
static java.lang.String MBEAN_SERVER_DOMAIN_NAME
          Mbean Server domain name.
 
Method Summary
static JobManagementAgent createJobManagementAgent(JobContext jobContext, Main agentCreator)
           Creates the agent and initializes with the job context and job connection helper.
 boolean isRunning()
          Tells whether the agent is running or not.
 boolean start(JobController jobController)
           This method start the job management agent with the given controller information.
 boolean stop(ErrorCode exitCode)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MBEAN_SERVER_DOMAIN_NAME

public static final java.lang.String MBEAN_SERVER_DOMAIN_NAME
Mbean Server domain name.

See Also:
Constant Field Values

JOB_MANAGER_MBEAN_NAME

public static final java.lang.String JOB_MANAGER_MBEAN_NAME
Name of the bean that manages this job.

See Also:
Constant Field Values

JOB_MONITOR_MBEAN_NAME

public static final java.lang.String JOB_MONITOR_MBEAN_NAME
Name of the bean monitors this job.

See Also:
Constant Field Values
Method Detail

createJobManagementAgent

public static JobManagementAgent createJobManagementAgent(JobContext jobContext,
                                                          Main agentCreator)

Creates the agent and initializes with the job context and job connection helper. Once it is created, it will be associated with the job in the job context.

Parameters:
jobContext - Context of the job is being run.
agentCreator - Main class instance authroized to create the agent.
Returns:
Returns the JobConnectorHelper implemenation.
Throws:
java.lang.SecurityException - If there is an attempt to create the agent other than Main class(framework).
ConfigurationException - If unable to instantiate the job connection helper.

start

public boolean start(JobController jobController)

This method start the job management agent with the given controller information. Basicially, this does the following activities to start the management agent.


Parameters:
jobController - Controller reference to be passed to the mbeans.
Returns:
Returns true, if manager is started properly, false, otherwise.
Throws:
java.lang.IllegalArgumentException - If input parameters job name or job controller is null.
java.lang.IllegalStateException - If manager is already started.

stop

public boolean stop(ErrorCode exitCode)
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.

Parameters:
exitCode - errorCode returned by controller to the Main class.
Returns:
Returns true, if agent could be stopped properly, false otherwise.
Throws:
java.lang.IllegalArgumentException - If input parameter status code is null.
java.lang.IllegalStateException - If agent is already stopped or it not yet started.

isRunning

public boolean isRunning()
Tells whether the agent is running or not. This state needs to be queried before trying to stop the agent.

Returns:
Returns true if agent is running, false otherwise.