Rules, Rules, Rules: Proactively Automate Management of the Service Infrastru...
JMX Tutorial
1. JMX Tutorial
Christophe Ebro
JMX Specification Lead
Sun Microsystems, Inc.
christophe.ebro@sun.co
1 2
Objectives Contents
Understand the JMX Specification • Introduction
• 3 level architecture
• Architecture
• Instrumentation via MBeans
• Instrumentation Specification
• Different kinds of MBeans
• Server Specification
• Client Server architecture
• Client Server services
3 4
What is the JMX? Benefits
• Enables Java applications to be managed
Java Management Extension
without heavy investment
It consists of – Little impact on Java application design
• An architecture • Provides scaleable management
• Design patterns architecture
• Java APIs – Component architecture, pick and choose
components
• Services for application and network
• Integrates existing management solutions
management
– Can be managed via multiple protocols, e.g.
SNMP, WBEM, HTTP
– Information model independent
5 6
• Leverages existing standard Java
1
2. JMX: 3 Level Architecture JMX Architecture
Instrumentation Server Distributed Services
Level Level Level
The JMX architecture defines three levels:
Object 1 JMX-compliant
(MBean) Management
• Instrumentation Level Connector
C
Application
– How to instrument managed resources Object 2
(MBean) Server Services
(as MBeans)
• Server Level Protocol
Adaptor
Web Browser
SNMP/CMIP Client
– How managed resources are managed via the Server Services
Proprietary
(as MBeans)
management server Management
Connector Application
• Distributed Services Level MBean server
Server Java Virtual Machine
– How distributed clients and management C
JMX Client
applications access and interact with servers and
C
the managed resources in the servers
7 8
Contents Basic Goal
• Introduction In a running Java application, we would
like to be able to:
• Architecture • Manage existing Java
objects:
• Instrumentation Specification – get an attribute value
• Server Specification Object 1 – change an attribute value
Object 2
– invoke an operation
• Add new Java objects:
Object 3 – using existing Java
classes
– using new classes from
an arbitrary location
Object 4 • And do all this from a
9 10 remote location
Definitions Contents
• Client: Application controlling servers by
• Introduction
submitting requests, activating new • Architecture
services, etc ...
– Instrumentation Level
• Server: Application making local resources
– Server Level
available remotely and providing one or
more services – Distributed Services Level
• MBean server: Registry for MBeans in the • Instrumentation Specification
server • Server Specification
• MBean: Managed bean. Java class
implementing a management interface and
representing a resource to be managed or
11 monitored 12
2
3. Instrumentation Level Instrumentation Level
Instrumentation Server Distributed Services
Level Level Level
Object 1 JMX-compliant
(MBean)
Connector
C Management
Application
• Provides management agent independence
Object 2 • Specification for implementing JMX
(MBean) Server Services
(as MBeans) Protocol Web Browser manageable resources
Adaptor SNMP/CMIP Client
Server Services • Resource can be a service, device, user, ...
(as MBeans) Proprietary
Management etc.
Connector Application
MBean server
Server Java Virtual Machine
• Resource developed in Java or have Java
C
wrapper
JMX Client
C
13 14
Components of the MBean (1)
Instrumentation Level Object 1
(MBean) Connector
• MBeans Object 2
Server Services
(MBean)
(as MBeans) Protocol
– Defines how resources are instrumented using Adaptor
MBeans Server Services
(as MBeans) Connector
– MBean instrumentation allows the resource to be Mbean server
Server Java Virtual Machine
manageable through JMX-compliant agents
• Notification Model • An MBean exposes the management
– MBeans and other JMX components may emit interface of the managed resource/object
notifications
• The management interface is the set of
• MBean Metadata Classes information and controls that a
15 – Describes the MBean's management interface for 16 management application uses to operate on
management agents and management the resource
MBean (2) Four Types of MBeans
• Standard MBeans
• An MBean exposes the management interface – Simplest to design and implement
as: – Management interface described by method names, like
getState, setState, reset
– Attributes which may be accessed
• Dynamic MBeans
– Operations which may be invoked
– Must implement DynamicMBean interface
– Notifications which may be emitted (optional) – Expose management interface at runtime for greater
– Constructors for the MBean's Java class flexibility via generic methods, like getAttribute,
setAttribute, invoke
• An MBean follows design patterns
• Model MBeans are dynamic MBeans
– The way an attribute or operation to be exposed – Self contained, self described, configurable at runtime
has to be declared
– Generic MBean class for dynamic instrumentation of
resources
• An MBean must be registered in the MBean server
to be visible remotely • Open MBeans are dynamic MBeans
17 18
• An MBean does not know about its MBean – Basic data types only for universal manageability
3
4. Notification Model MBean Metadata Classes
• JMX defines a generic notification model • MBean server (server level) has to provide
– Based on Java event model MBean metadata
• Notification can be emitted by: • Classes that describe the management
– MBean instances interface of an MBean
– MBean server • There are metadata classes for attributes,
• JMX defines operations, notifications, and constructors
– Notification objects • Metadata include name, description,
– Broadcaster interface for notification senders attribute type, operation parameter types, ...
– Listener interface for notification listeners etc.
• Distribution of notification for remote • Different types of MBeans extend metadata
management applications not in JMX 1.0 classes to provide additional information
19 20
May be provided by JMX implementations
Contents Server Level
Instrumentation Server Distributed Services
• Introduction Level Level Level
• Architecture Object 1 JMX-compliant
(MBean) C Management
Connector
– Instrumentation Level Application
Object 2
– Server Level (MBean) Server Services
(as MBeans) Protocol Web Browser
– Distributed Services Level Adaptor SNMP/CMIP Client
Server Services
• Instrumentation Specification (as MBeans) Proprietary
Management
Application
• Server Specification MBean server
Connector
Server Java Virtual Machine
C
JMX Client
C
21 22
Server Level MBean Server (1)
• Specification for implementing servers Object 1
(MBean) Connector
• Servers directly control resources and make Object 2
Server Services
them available to remote management (MBean)
(as MBeans) Protocol
Adaptor
applications
Server Services
(as MBeans) Connector
• JMX server consists of: MBean server
Server Java Virtual Machine
– MBean server
– Server services • The MBean server is a registry of objects which
are exposed to management operations in a server
• Implemented by developers of management – Only registered MBeans can be managed from
systems outside the server's JVM
– Independent of semantics of JMX manageable • The MBean server only exposes an MBean's
resources or management application management interface (not the MBean's direct
23 24 reference)
4
5. MBean Server (2) Server Services
• Also provides standardized interface for accessing
MBeans within the same JVM Object 1
(MBean) Connector
• MBeans can be instantiated and registered by: Object 2
(MBean) Server Services
(as MBeans) Protocol
– Another MBean Adaptor
– The management server itself Server Services
(as MBeans) Connector
MBean server
– A remote management application (through Server Java Virtual Machine
distributed services)
• Each registered MBean is assigned a unique name, • Objects that perform management operations on the
usually user-defined MBeans registered in the MBean server
• Only these names are used by server/client – Provides management intelligence inside the
applications to identify the MBeans server
• Relies on protocol adaptors and connectors to make – Server services are also MBeans
25 26
server accessible from outside server's JVM
JMX 1.0 Server Services Contents
• M-Let dynamic class loading service • Introduction
retrieves and instantiates new classes from
• Architecture
arbitrary network locations
– Instrumentation Level
• Monitors observe MBean attribute value and
– Server Level
emit notifications for several types of
changes in the target – Distributed Services Level
• Timers provide scheduling based on a one- • Instrumentation Specification
time alarm clock or repeated, periodic • Server Specification
notification
• Relation service defines associations
between MBeans and enforces the
27 cardinality of the relation based on 28
Distributed Services Level Distributed Services Level
Instrumentation Agent Distributed Services
Level Level Level • Outside scope of JMX 1.0
Object 1 JMX-compliant • Defines distribution mechanism
(MBean) C Management
Connector Application – Connectors
Object 2
(MBean) Server Services
– Protocol Adaptors
(as MBeans) Protocol Web Browser
Adaptor SNMP/CMIP Client – Proxies
Server Services
(as MBeans) Proprietary
• Specifies interfaces for JMX clients
Management
MBean server
Connector Application • Defines management interfaces and
Server Java Virtual Machine components that operate on servers or
C hierarchies of servers
JMX Client
C
29 30
5
6. Connector (1) Connector (2)
JMX-Compliant
Management • Provides remote access to MBean
Application
Object 1 attributes and operations
(MBean) Connector Connector
Object 2 Client Virtual Machine
(MBean) • Provides remote instantiation,
MBean Server registration and de-registration of
Server Java Virtual Machine
MBeans
• Composed of a client part and a server • Propagates MBean and MBean server
part, the connector connects a JMX client notifications to the client application
application with an MBean server
• Client part provides a protocol-independent
API to access the remote MBean server
31
• Tunnels management operations over a 32
specific protocol (RMI HTTP )
Protocol Adaptor Connectors and Protocol
Not Shown
Object 1 HTML Browser,
Adaptors HTTPS
IIOP (JMX IIOP JSR) Client API
(MBean) Protocol SNMP Client,
Object 2 Adaptor etc... Java
(MBean) Application
RMI
MBean Server
Server Java Virtual Machine RMI
Java
Application
HTTP HTTP
Object 1
• Only has a server part, on the server (MBean)
Object 2 HTML Browser:
• Creates a view of the MBeans through a (MBean) HTML HotJava,
Netscape, ...
given protocol and information model
SNMP SNMP Client:
SNM, SEM,
MBean Server
JDMK, ...
Server Java Virtual Machine
33 34
Proxy MBean Development Process
• The proxy MBean provides an image of an MBean
as a stub object on the client side
Main Steps
• Operations performed on the proxy MBean are
• Instrument managed resources
propagated to the MBean
• Notifications emitted by the MBean are propagated • Instantiate MBeans in a JMX server
to the proxy MBean • Test MBeans
• The proxy is generated from an MBean
MBeans
Proxy MBeans
• Develop the client application (optional)
Object 1
Object 1
Connector
Object 2 Object 2
Client Java Virtual Machine
MBean Server
35 Server Java Virtual Machine 36
6
7. Problems solved by JMX (1) Problems solved by JMX (2)
Open the design of new Java applications
Make an existing Java application manageable
• Design the new application such that it
• The existing application can be modified so includes an MBean server
that – Remote access for management operations is
– It creates an MBean server and a connector or a free
protocol adaptor
– The application will be extensible dynamically
– It registers the objects that need to be managed
• Develop servers for a variety of purposes
• Requirement: registered objects must be
– System Management/Monitoring
instrumented as MBeans
– Network Management/Monitoring
– This requirement is light
37 38 – Application Management/Monitoring
– It does not break existing design or force the
Advantages of this Solution Contents
• Protocol independent • Introduction
• Information model independent
• Architecture
• Light requirements on software design:
– An MBean only needs to implement a • Instrumentation
management interface
– An MBean does not need to be aware of JMX
Specification
servers and agents – Standard MBean
– An MBean does not need to know anything about
– Dynamic MBean
communication with the outside world
– MBean Metadata
• Scalability and flexibility
– Notification Model
– By registering and unregistering MBeans the Java
application can include only what it needs at the – Model MBean
time it needs it • Server Specification
39 40
– New protocol adaptors (with new protocols) can
Instrumentation MBean Requirements
• Defined by the JMX Instrumentation Spec • MBean must be a public concrete Java class
• Must follow specified • Must implement one of two types of MBean
interfaces
– Design patterns
– Standard MBean interface
– Implement MBean interfaces
– Management interface is static, i.e. determined from
• MBean enable management by any JMX methods defined in the MBean's interface
servers – Depends on design patterns and introspection
– DynamicMBean interface
• An MBean can be created from an already – Management interface is generic and determined
existing Java object or from scratch indirectly through method calls
– Generic get, set, and invoke methods
• Developers decide
• Optional NotificationBroadcaster interface
– Granularity of MBeans
41 42
How to wrap legacy code
7
8. Terminology Choice of MBean Interfaces
• An attribute is a field or property of a JMX
manageable resource exposed via an • Choice of standard MBean or dynamic
MBean's management interface MBean interface determines how MBean will
be developed, not how it will be managed
• An operation is an action that a JMX
manageable resource makes available to • JMX server provides abstraction to manage
management applications exposed via an both types of instrumentation transparently
MBean's management interface • Management applications handle them in a
• A method refers to a Java method or similar manner
function
43 44
Contents Standard MBeans
• Introduction • Implement Java interface named after the
class
• Architecture
– Name of MBean interface is formed by
• Instrumentation Specification adding MBean suffix to class name
– Standard MBean • Standard MBean interface lists the attributes
– Dynamic MBean and operations exposed to management
MyClassMBea
– MBean Metadata n
• Impose very little constraint on the MBean
– Notification Model class design Implements getFoo()
– Model MBean
MyClass
• Server Specification
getFoo()
setFoo()
45 46
Lexical design patterns for Lexical Design Patterns: Example
public interface SimpleStandardMBean {
methods public String getState() ;
• An attribute is deduced from the public void setState(String s) ;
public Integer getNbChanges() ;
existence of a get and/or set method: }
public void reset() ;
public class SimpleStandard implements SimpleStandardMBean {
public String getState() { Attribute State
public MyType getMyAttribute(); return state;
}
Type String
public void setState(String s) { Access read-write
public void setMyAttribute(MyType value);
state = s;
nbChanges++;
Attribute
}
NbChanges
public Integer getNbChanges() {
Type Integer
• Any other method is considered to be }
return new Integer(nbChanges);
Access read-only
an operation: public void reset() {
state = "initial state";
reset is an
manageable
nbChanges = 0;
operation
nbResets++;
}
public void reset(); public Integer getNbResets() { NbResets is not a
return new Integer(nbResets); manageable
public MyResult myOperation(MyType arg); } attribute
private String state = "initial state";
47 48 private int nbChanges = 0;
private int nbResets = 0;
8
9. Contents Which MBean
• Introduction Standard MBean
• Suitable when structure of management data is
• Architecture
well-defined in advance
• Instrumentation Specification • Determine structure at compile time
– Standard MBean • Provide quick and easy way to instrument
– Dynamic MBean manageable resources
– MBean Metadata Dynamic MBean
– Notification Model • Suitable when structure of management data is
– Model MBean likely to evolve often over time
• Server Specification • Can determine structure dynamically at run-time
• Provide adaptability and more elaborate
49 50 management capabilities
Dynamic MBeans DynamicMBean Interface
Management Interface
• Implement DynamicMBean interface «Interface»
DynamicMBean
• Provide generic get, set, invoke
methods getMBeanInfo(): M BeanInfo
getAttribute( attribute:String:)Object
• Describe their management interface at getAttributes( attributes:String[]:)AttributeList
runtime (by means of MBeanInfo)
DynamicMBea setAttribute( attribute:Attribute )void
:
n setAttributes( attributes:AttributeList: ) ttributeList
A
getAttribute() invoke( actionName:String,
Implements
setAttribute() params:Object[],
invoke() ...
signature:String[] ): Object
MyClass
51 52
Dynamic MBean: Example (1) Dynamic MBean: Example (2)
Definition of a dynamic MBean with:
• one read-write attribute State
• one read-only attribute NbChanges
• one reset operation public AttributeList getAttributes(String[] attributes) {
// Checks if "State" and/or "NbChanges" is in the list.
public class SimpleDynamic implements DynamicMBean { // Calls getAttribute.
public SimpleDynamic() { }
// Creates MBeanAttributeInfo for "State" and "NbChanges" public void setAttributes(AttributeList attribute) {
// Creates MBeanOperationInfo for "reset" // Checks if "State" is in the list.
} // Calls setAttribute.
public MBeanInfo getMBeanInfo() { }
// Creates a MBeanInfo with the name "SimpleDynamic" and the public Object invoke(String opName, Object[] args,
// MBeanAttributeInfo and MBeanOperationInfo String[] signature) {
} // Checks the operation is "reset",
public Object getAttribute(String attribute) { // with the correct signature (no args).
// Checks if the requested attribute is "State" or "NbChanges" // Perform reset
// Returns the attribute value. }
} ...
public void setAttribute(Attribute attribute) { }
// Checks if attribute is "State" and if argument
// is a String. Sets the value of the attribute.
53 } 54
9
10. getAttribute method invoke method
public Object getAttribute(String attributeName) public Object invoke(String operationName,
throws AttributeNotFoundException, Object params[],
MBeanException, String signature[])
ReflectionException { throws MBeanException,
// Check attributeName is not null to avoid ReflectionException {
// NullPointerException later on // Check operationName is not null to avoid
if (attributeName == null) { // NullPointerException later on
throw new RuntimeOperationsException( if (operationName == null) {
new IllegalArgumentException(...), ...); throw new RuntimeOperationsException(
} new IllegalArgumentException(...), ...);
// Check for a recognized attribute_name and }
// call the corresponding getter // Check for a recognized operation name and call the
if (attributeName.equals("State")) { // corresponding operation
return getState(); if (operationName.equals("reset")){
} reset();
if (attributeName.equals("NbChanges")) { return null;
return getNbChanges(); } else {
} // unrecognized operation name:
// If attributeName has not been recognized throw throw new ReflectionException(
// an AttributeNotFoundException new NoSuchMethodException(operationName), ...);
throw(new AttributeNotFoundException(...)); }
} }
55 56
Contents MBean Metadata Classes
MBeanInfo
• Introduction getClassName(): String
getNotifications() MBeanNotificationInfo[]
:
getAttributes() MBeanAttributeInfo[]
:
• Architecture getConstructors(): MBeanConstructorInfo[]
MBeanFeatureInfo
getOperations(): MBeanOperationInfo[] getName(): String
getDescription(): String getDescription() String
:
• Instrumentation Specification
0..* 0..*
MBeanOperationInfo MBeanNotificationInfo
– Standard MBean UNKNOWN:int {frozen} getNotifT ypes() String[]
:
ACTION: int {frozen}
– Dynamic MBean INFO: int {frozen} 0..*
ACTION_INFO: int {frozen} MBeanAttributeInfo
– MBean Metadata getReturnType(): String
getSignature(): MBeanParameterInfo[]
getImpact(): int
getT ype(): String
isReadable(): boolean
isWritable(): boolean
– Inheritance Pattern 0..*
isIs(): boolean
MBeanConstructorInfo
– Notification Model getSignature(): MBeanParameterInfo[]
0..* 0..*
– Model MBean MBeanParameterInfo
getT ype(): String
• Server Specification
57 58
Behavior of Dynamic MBeans Contents
• Coherence • Introduction
– Developer must ensure that advertised • Architecture
management interface (via getMBeanInfo) is
accurately mapped to internal implementation • Instrumentation Specification
– MBean server does not test or validate the self- – Standard MBean
description of a dynamic MBean – Dynamic MBean
• Dynamics – MBean Metadata
– The management interface of an MBean should – Inheritance Pattern
be applicable throughout the lifetime of the
MBean
– Notification Model
– Model MBean
– getMBeanInfo should return the same
MBeanInfo during the lifetime of the dynamic • Server Specification
59 MBean 60
10
11. Notification Model Notification Class
• Notifications are instances of Notification
– Can be used directly or may be subclassed
• A Notification object contains the following
Notification Source
fields:
implements – An event source references the notification source
NotificationBroadcaster (from java.util.EventObject superclass)
Notification – A notification type is a string used to characterize a
Object generic notification object
Notification Consumer is an instance of – A sequence number is a serial number identifying an
implements Notification
NotificationListener class
notification instance within the context of a notification
broadcaster
– A time stamp indicates when the notification was
generated
– A message containing a string which could be an
61 62 explanation of the notification for display to the user
U d t i df th d t th tifi ti
NotificationListener Interface NotificationFilter Interface
• Must be implemented by all MBeans expecting to receive
notifications
void handleNotification(
• A notification filter object is provided by the listener
Notification notification, when the listener registers for notifications with the
Object handback) broadcaster
• Invoked by notification broadcaster MBean when it emits a • boolean isNotificationEnabled(Notification n)
notification Invoked by notification broadcaster before it emits a
notification
• A single notification handler receives all notifications from all
potential broadcasters • Listeners rely on a filter to screen notifications
– All notifications are characterized by notification type string
• An object can be both a
• Handback object
NotificationListener and
– The object that the listener provides when the listener registers for
notifications with the notification broadcaster
NotificationFilter
– Stored by notification broadcaster and returned unchanged with
63 each notification 64
NotificationBroadcaster Send Notification Semantics
Interface
• MBeanNotificationInfo[] getNotificationInfo()
Provides the description of all notifications this broadcaster emits For each notification
• void addNotificationListener( For each (listener, filter, handback)
NotificationListener listener, If filter.isNotificationEnabled(notification)then
NotificationFilter filter, listener.handleNotification(notification,handback)
Object handback) EndIf
EndFor
Used by listener to register for notifications
EndFor
(listener, filter, handback) tuple stored
Key is (listener, handback)
• void removeNotificationListener(
NotificationListener listener,
Object handback)
Remove (listener, filter, handback) tuple
65 66
11
12. Contents Model MBean (1)
• Introduction
Target Resource
Java Object
• Architecture Model MBean
behavior driven by
• Instrumentation Specification Target Resource descriptors
Java Object
– Standard MBean Model MBean
behavior driven by
– Dynamic MBean descriptors
– MBean Metadata
– Inheritance Pattern
Target Resource
– Notification Model RMI/CORBA/EJB
Object
– Model MBean
• Server Specification
67 68
Model MBean (2) Interaction with Managed Resources
A model MBean is a generic, configurable • Resource obtains access to MBean server
dynamic MBean • Resource invokes MBean server to create new or
•Concrete model MBean classes provided in find existing model MBeans
conjunction with the JMX server • Resource configures model MBeans by
– JMX server must provide RequiredModelMBean manipulating the model MBean descriptors
•Configured via descriptors • Get attribute invoked on a model MBean
•Descriptors contains dynamic, extensible, and – Model MBean has caching mechanism for attributes
configuration behavior information which includes: – Return cached values or delegate invocation to resource
object
– Persistence policies, value caching policies, logging policies
– Mapping from MBean attributes and operations to methods
• Operation invoked on a model MBean
on underlaying Java object(s) – delegate to managed resource object
getAttribute("myApplStatus") • Managed resource sends notifications by invoking
69 ==> myAppl.statusChecker() 70
sendNotifi ation method of model MBean
Contents Server Specification
• Introduction
Object 1
• Architecture (MBean) Connector
Object 2
Server Services
• Instrumentation Specification (MBean)
(as MBeans) Protocol
Adaptor
• Server Specification Server Services
(as MBeans) Connector
MBean server
– MBean Server Server Java Virtual Machine
– M-Let Service
– Monitor Service MBean server Server services
– Timer Service • MBean registry • Dynamic class loading
• All management • Monitoring
– Relation Service operations go through • Timer
MBean server • Relation
71 72
12
13. ObjectName Class Object Name Pattern Matching
• Consists of two parts • Used in queries to identify target objects to
Domain name limit scope of query
– Provides for name spaces within a JMX server • Domain name
or for a more global management solution * matches any character sequence, including
empty
– MBean server can provide default domain
? matches any one single character
Key Property List
• Key property list
– Unordered list of property-value pairs * wildcard for key properties,
– Used to assign unique names within a domain replaces any number of key properties
– Must contain at least one key property • Examples
• String representation MyDomain:description=printer,type=ink
*:* all objects in MBean server
[domainName]:property=value[,property=value]* :* all objects of the default domain
73 74 ??Domain:* all objects in MyDomain
Canonical name: key properties sorted in lexical *Domain:* all objects in domain ending with Domain
Foundation Classes Contents
• ObjectInstance class • Introduction
– Contains • Architecture
– Class name • Instrumentation Specification
– ObjectName
– Equality test with another ObjectInstance
• Server Specification
– Returned when an MBean is created and is used – MBean Server
subsequently for querying – M-Let Service
• Attribute class – Monitor Service
– represents single attribute-value pair – Timer Service
• AttributeList class – Relation Service
75 – represents a list of attribute-value pair 76
MBeanServerFactory MBeanServer Interface (1)
Class
• Object creation methods:
createMBean
instantiates and registers an MBean
• Only has static methods to
instantiate
– Create new MBean server instances instantiates an MBean but does not register MBean
• MBean server referenced by domain name deserialize
– Find MBean server instances byte array in context of MBean class loader
– Release MBean server reference
• MBean registration methods:
registerMBean
unregisterMBean
isRegistered
77 78
13
14. MBeanServer Interface (2) Query Methods
• MBean proxy methods: Takes two arguments: ObjectName and QueryExp
getMBeanInfo
• Object name provides scope of query
getAttribute getAttributes
setAttribute setAttributes – Object name pattern matching selects MBeans on
invoke which query expression will be applied
addNotificationListener • Query expression operates on MBean attributes
removeNotificationListener – Applies to a single MBean
• Query method: – Use Query class to build QueryExp
queryMBeans(ObjectName n,QueryExp q)
QueryExp exp =
returns Set of ObjectInstance's Query.and(
Query.between(Query.attr("age"),
queryNames(ObjectName n,Query q) Query.value(20),
return Set of ObjectName's Query.value(30)),
Query.match(Query.attr("name"),
79 • Read-only attributes: 80 Query.value("G*ling"))
)
Contents Server Service MBeans
• Introduction
My MBeans
• Architecture
• Instrumentation Specification
JMX
• Agent Specification M-Let
Service MBeans
– MBean Server
Monitor
– M-Let Service
Timer
– Monitor Service
– Timer Service Relation
– Relation Service
• Conclusion
81 82
M-Let Service Contents
• Introduction
• MBeans can be
Object obtained from a • Architecture
1
Object 2 remote JAR file • Instrumentation Specification
Object 3
Object 4
• Server Specification
http://soft.eng/mybean.html – MBean Server
<MLET – M-Let Service
CODE=object4.class
ARCHIVE=mybean.jar
M-Let NAME="test:name=object4">
</MLET>
– Monitor Service
CLASSPATH – Timer Service
http://soft.eng/mybean.jar – Relation Service
classes/object1.cl
ass object3.class
classes/object2.cl object4.class
83 ass 84
14
15. Monitor Service Counter Monitor Illustration
• A monitor MBean observes an attribute of another
MBean at regular interval specified by the
granularity period Threshold Threshold Threshold Threshold
Notif Notif Notif Notif
• The derived gauge is either
granularity period modulus
– the exact value, or
threshold
– the difference between two consecutive values
threshold
• A MonitorNotification is sent when the offset
attribute value crosses a level or threshold, threshold
or string value changes
threshold threshold
• There are several types of monitors:
– Counter Monitor
85 – Gauge Monitor 86
String Monitor
Gauge Monitor Illustration String Monitor Illustration
High Low High
Match Differ Match
Notif Notif Notif Notif
Notif Notif
granularity period granularity period
HighThreshold
LowThreshold
"XYZ" "YYY" "XXXX" "XYZ" "XYZ"
87 88
Contents Timer Service
• Introduction " Enables notifications to be sent to all
• Architecture registered listeners
– At a specified date
• Instrumentation Specification
– Starting at a specified date and repeating
• Server Specification several times, at regular time intervals
– MBean Server " addNotification
– M-Let Service " removeNotification
– Monitor Service " SendPastNotification attribute
– Timer Service – If true, send past notifications when timer re-
started and update to the next notification date
– Relation Service
– if false, update past notification dates to next
89 90 notification date but don't send past
notifications
15
16. Contents Relation Service
• Introduction • Used to define logical relations between
MBeans
• Architecture
• Act as a repository for relation types and
• Instrumentation Specification
relations
• Server Specification
• To create relation between MBeans:
– MBean Server
– Create a new relation type, or use existing one
– M-Let Service
– Create a relation from this relation Type
– Monitor Service
– ---> will associate MBeans to this relation
– Timer Service
• Provides a set of operations to get
– Relation Service information about relations and related
91 92 MBeans
Relation Service Example Maintaining Consistency (1)
• Only registered MBeans can participate in relations
– Relation service operates only on object names
• Create relations between the Owner and its – Provides object names in response to queries
Books in a Personal Library • Consistency checks when
– Relation type is created
e.g. role information inconsistent
Relation Type
– Relation is created
Personal Library e.g. does not confirm to relation type or object name does not exist
– Role values (MBeans in role) are updated
• Removal semantics
1..1 0..* – Remove relation type removes all relation of relation type
Role 1 Role 2
– Remove relation does not de-register MBeans
Owner Book
– De-register an MBean removes the MBean from all role
values
93 94 – PurgeFlag attribute and purgeRelations method
Maintaining Consistency (2) Useful Links
• Common use is to maintain consistency when an JMX
MBean is de-registered • Home page (Specification, RI, and related JSR's)
– Trigger code execution when a relation has been updated or http://java.sun.com/products/JavaManagement
deleted due to an MBean de-registration • Email archives
– For example, to trigger code execution when resources are http://archives.java.sun.com/jmx-forum.html
unplugged or removed
Sun JDMK
• Only guarantees that an MBean satisfies its role • Home page
– Cannot define how many relations an MBean may appear in http://www.sun.com/software/java-dynamic
• Email archives
http://archives.java.sun.com/jdmk-forum.html
IBM Tivoli JMX
• http://www.alphaworks.ibm.com/tech/TMX4J
AdventNet Agent Toolkit
• http://www.adventnet.com/products/agenttoolkit
95 96
16