Self Management Framework in GlassFish
Complex software such as Application Server typically consists of tens of components and hundreds of configurable (tunable) parameters. Tuning those hundreds of parameters, in a clustered environment in varying load conditions is often a difficult task.
Application servers expose wealth of monitoring information. As of now, this information has to be processed by users or other external tools to make some meaningful representation of this collected data. Based on the data, user needs to take an appropriate action. Unfortunately in varying load conditions, by the time data is processed and an action is taken manually by the user, that action may not be ideal at that point of time. Indeed, if we could embed the intelligence to process the monitoring information with in the server and take an appropriate action based on that data with in the appserver will be an ideal thing to do and makes appserver management simpler.
GlassFish has inbuilt framework to incorporate self management intelligence into the appserver. At a high level, I would touch up on the frame work below.
Summary of self management framework support in GlassFish:
> Built on JMX
> Custom or User MBean support
> Based on the concept of management rules
> Each management rule is a combination of an event and an action
> Set of useful events provided by default
> Event dictionary can be extended by the user
> Admin GUI and CLI support to create and manage rules
JMX has become the standard for management and monitoring of application servers. Self Management framework in GlassFish is a JMX standards based frame work to automate the tuning/configuring/healing (Self Management) with in the appserver without user intervention at runtime.
Framework is built around the concept of management rules. An appserver can be self managed or can be extend to be managed with the help of set of management rules. Each management rule has two parts. First part being event and second part being action. Event and Action are loosely coupled and both of them are JMX MBeans. Event part gathers data, process it and generates an event. When an event occurs, action part will be triggered. Framework describes a set of pre defined useful events and also has provision to extend the possible events with in an appserver.
An example of a management rule could be "Memory Management Rule". In the event of low memory in the application server, an action can be taken to clean up internal resources such as stale sessions, cleaning up caches, pools etc. and alerting the administrator. Shalini in her blog "GlassFish : Self Management Rules" neatly describes some example management rules and how to create them using GlassFish.
Custom MBean support:
As of now, Java EE doesn't specify a way to deploy and undeploy user defined MBeans as stand alone components similar to web components. Glassfish has support to deploy, undeploy and manage custom MBeans at run time.
Event source is an MBean which can emit javax.management.Notification. More specifically any MBean which implements javax.management.NotificationEmitter is a candidate for event source.
Out of box glassfish provides some useful events and these can be further extended by writing custom MBeans which can emit notifications. Each event can be further customized by changing its properties.
Log Events: A management rule, which uses log event could be used to send an alert to an administrator, when an EJB container logger logs a SEVERE log entry.
Monitor Events: Monitor events have similar capabilities as javax.management.monitor package capabilities.In addition to monitoring simple attributes (As of J2SE 5 javax.management.monitor only supports monitoring of simple attributes), monitoring of complex attributes is also possible.
Trace Events: Http/IIOP Request Entry and Exit, EJB method Entry and Exit, Web method Entry and Exit trace events are defined in GlassFish. For example, a servlet filter that is used to log interactions with a servlet, can today be designed as a management rule using Web method Entry and Exit events.
Life Cycle Events: Server Startup, Shutdown and termination events are provided.
Timer Events: Similar capabilities as javax.management.timer package.
Generic Notification Events: This can be used write custom events and thus extend the event dictionary. Any MBeans which can emit a notification can be an event.
Action part of the management rule is triggered when an associated event occurs. Action is an MBean which is a notification listener. More specifically, one which implements javax.management.NotificationListener.
Admin GUI and CLI support custom MBean creation, deletion and updation. They also have necessary support for the life cycle of management rules.
Self Management framework used in GlassFish is built using standard JMX technologies. Best part of this framework is it uses much of what JMX offers and builds Quality of Services on top of the standard JMX infrastructure.
1) Shalini's Blog : GlassFish : Self Management Rules