Class JMXClientJob
- All Implemented Interfaces:
Runnable,ArooaContextAware,ArooaSessionAware,BeanDirectoryOwner,PropertyChangeNotifier,Iconic,RemoteDirectoryOwner,ConsoleArchiver,LogArchiver,LogEnabled,Resettable,Stateful,Stoppable,Structural
- Author:
- Rob Gordon
Description
Connect to an OddjobJMXServerJob.
This job allows remote jobs to be monitored and controlled from
a local Oddjob.
This service will run until it is manually stopped or until the connection to the remote server is lost. If this job is stopped it's state will be COMPLETE, if the connection is lost the state state will be EXCEPTION.
To access and control jobs on a server from within a configuration file this
client must have an id. If the client has an id of 'freds-pc'
and the job on the server has an id of 'freds-job'. The job on
the server can be accessed from the client using the expression
${freds-pc/freds-job}.
Example
Connect to a remote server that is using the Platform MBean Server. This example also demonstrates using the value of a remote jobs property.
<oddjob id="this" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx">
<job>
<sequential>
<jobs>
<jmx:client id="remote" connection="${this.args[0]}"/>
<echo>${remote/echo.text}</echo>
<stop job="${remote}"/>
</jobs>
</sequential>
</job>
</oddjob>
Note that the StopJob is required otherwise Oddjob wouldn't exit. An
Alternative to using stop, would be to make the client a child of a
SequentialJob with an
ServiceManagerStateOp operator.
Here's an example of the command used to launch it:
java -jar C:\Users\rob\projects\oddjob\run-oddjob.jar -f C:\Users\rob\projects\oddjob\test\java\org\oddjob\jmx\PlatformMBeanClientExample.xml localhost:13013
This configuration is the client side of the first example in
JMXServerJob.To create a connection to a remote server that is using an RMI registry
using the full form of the JMX URL.
<jmx:client id="freds-pc" name="Connection to Freds PC" url="service:jmx:rmi:///jndi/rmi://${hosts.freds-pc}/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/>
Connect, run a remote job, and disconnect.
<oddjob>
<job>
<sequential>
<jobs>
<jmx:client id="freds-pc" name="Oddjob Client" url="service:jmx:rmi:///jndi/rmi://${hosts.freds-pc}/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/>
<run job="${freds-pc/server-jobs/greeting}" join="true"/>
<stop job="${freds-pc}"/>
</jobs>
</sequential>
</job>
</oddjob>
The run job starts the server job but doesn't wait for it to complete. We would need to add a wait job for that.Connect using a username and password to a secure server.
<jmx:client connection="localhost/my-oddjob" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx">
<environment>
<jmx:client-credentials username="username" password="password"/>
</environment>
</jmx:client>
A local job triggers when a server job runs.
<oddjob>
<job>
<sequential>
<jobs>
<jmx:client id="freds-pc" name="Oddjob Client" url="service:jmx:rmi:///jndi/rmi://${hosts.freds-pc}/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/>
<scheduling:trigger on="${freds-pc/server-jobs/greeting}" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
<job>
<sequential>
<jobs>
<echo id="local-job">Server Job Ran!</echo>
<stop job="${freds-pc}"/>
</jobs>
</sequential>
</job>
</scheduling:trigger>
</jobs>
</sequential>
</job>
</oddjob>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.oddjob.jmx.ClientBase
ClientBase.WhyStop -
Field Summary
FieldsFields inherited from interface org.oddjob.logging.LogArchiver
MAX_HISTORY, NO_LOG_AVAILABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConsoleListener(LogListener l, Object component, long last, int max) Add a listener to the archiver which will receive all missed events.voidaddLogListener(LogListener l, Object component, LogLevel level, long last, int history) Add a listener to the archiver which will receive all missed events.voidaddStructuralListener(StructuralListener listener) Add a listener.consoleIdFor(Object component) Get the console id for a given component.protected voiddoStart(MBeanServerConnection mbsc, ScheduledExecutorService notificationProcessor) Overridden by subclasses to provide a specific startup.longintintvoidSubclasses override this method to perform post creation initialisation.protected voidonStop(ClientBase.WhyStop why) Provide a remote directory.voidremoveConsoleListener(LogListener l, Object component) Remove the LogListener.voidremoveLogListener(LogListener l, Object component) Remove the LogListener.voidremoveStructuralListener(StructuralListener listener) Remove a listener.voidsetHandlerFactories(HandlerFactoryProvider handlerFactories) voidsetLogPollingInterval(long logPollingInterval) voidsetMaxConsoleLines(int maxConsoleLines) voidsetMaxLoggerLines(int maxLoggerLines) voidDeprecated.Methods inherited from class org.oddjob.jmx.ClientBase
doStop, getConnection, getEnvironment, getHeartbeat, onStart, onStop, setConnection, setEnvironment, setHeartbeatMethods inherited from class org.oddjob.framework.extend.SimpleService
fireDestroyedState, getName, getStateChanger, hardReset, iconHelper, logger, loggerName, onDestroy, run, setName, softReset, stateHandler, stop, toStringMethods inherited from class org.oddjob.framework.extend.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, removeIconListener, removePropertyChangeListener, removeStateListener, save, save, setArooaContext, setArooaSessionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
-
Field Details
-
DEFAULT_LOG_POLLING_INTERVAL
public static final long DEFAULT_LOG_POLLING_INTERVAL- See Also:
-
-
Constructor Details
-
JMXClientJob
public JMXClientJob()
-
-
Method Details
-
setUrl
Deprecated.- Reference Property:
- url
- Required:
- No.
Description
This property is now deprecated in favour of connection which reflects that the connection string no longer need only be a full JMX URL. -
addLogListener
Description copied from interface:LogArchiverAdd a listener to the archiver which will receive all missed events. The idea of receiving only missed events is to minimise network traffic when used remotely.Event numbers begin at 0. To receive all events, last must be -1.
- Specified by:
addLogListenerin interfaceLogArchiver- Parameters:
l- The logListener which will receive the events.level- The level of events required.last- The last event number received. The LogArchive will not send messages from before this number.history- The maximum messages to send up to the most recent.
-
removeLogListener
Description copied from interface:LogArchiverRemove the LogListener.- Specified by:
removeLogListenerin interfaceLogArchiver- Parameters:
l- The LogListener.
-
addConsoleListener
Description copied from interface:ConsoleArchiverAdd a listener to the archiver which will receive all missed events. The idea of receiving only missed event is to minimise network traffic when used remotely.- Specified by:
addConsoleListenerin interfaceConsoleArchiver- Parameters:
l- The logListener which will receive the events.component- The component whose console to receive events for.last- The last event number received. The LogArchive will not send messages from before this number.max- The maximum messages to send up to the most recent.
-
removeConsoleListener
Description copied from interface:ConsoleArchiverRemove the LogListener.- Specified by:
removeConsoleListenerin interfaceConsoleArchiver- Parameters:
l- The LogListener.
-
consoleIdFor
Description copied from interface:ConsoleArchiverGet the console id for a given component.- Specified by:
consoleIdForin interfaceConsoleArchiver- Parameters:
component- The component.- Returns:
- The console id.
-
onInitialised
public void onInitialised()Description copied from class:BaseComponentSubclasses override this method to perform post creation initialisation.- Overrides:
onInitialisedin classBaseComponent
-
doStart
Description copied from class:ClientBaseOverridden by subclasses to provide a specific startup.- Specified by:
doStartin classClientBase- Parameters:
mbsc-notificationProcessor-
-
onStop
- Specified by:
onStopin classClientBase
-
provideBeanDirectory
Description copied from interface:RemoteDirectoryOwnerProvide a remote directory.- Specified by:
provideBeanDirectoryin interfaceBeanDirectoryOwner- Specified by:
provideBeanDirectoryin interfaceRemoteDirectoryOwner- Returns:
- The
BeanDirectoryor null.
-
addStructuralListener
Description copied from interface:StructuralAdd a listener. The listener will immediately receive add notifications for all existing children.- Specified by:
addStructuralListenerin interfaceStructural- Parameters:
listener- The listener.
-
removeStructuralListener
Description copied from interface:StructuralRemove a listener.- Specified by:
removeStructuralListenerin interfaceStructural- Parameters:
listener- The listener.
-
getMaxConsoleLines
public int getMaxConsoleLines() -
setMaxConsoleLines
public void setMaxConsoleLines(int maxConsoleLines) -
getMaxLoggerLines
public int getMaxLoggerLines() -
setMaxLoggerLines
public void setMaxLoggerLines(int maxLoggerLines) -
getLogPollingInterval
public long getLogPollingInterval() -
setLogPollingInterval
public void setLogPollingInterval(long logPollingInterval) -
getHandlerFactories
-
setHandlerFactories
-