You are on page 1of 46

Java

TN
Nanagement
Extensions (JNX
TN
)
Adam Quan
2
Agenda
JNX Technology Updates
JNX Architecture (JSR 3)
NBeans
NBean server
JNX security
JNX Remoting (JSR 160)
JNX and J2SE (JSR 77)
JNX and J2EE (JSR 17+)
Real-World JNX Applications
A Simple Demo
3
Why Nanagement 8
Nonitoring?
!nfrastructure Software is Getting Nore
Complicated
Administration
Configuration
Nonitoring
Enterprise Business Application Characteristics:
Distributed
Complex
Nission Critical
High-volume
Dynamic
+
An Analogy First
5
What is JNX?
Defines the Architecture, Design Patterns,
APIs and the Services for exposing and
managing applications and network devices.
Provides a means to:
!nstrument Java code.
!mplement distributed management middleware and
managers.
Smoothly integrate these solutions into existing
management systems.
From Opaque Applications to Transparent
Processes
6
JNX Benefits
Low Cost
Scalable Nanagement Architecture -
Nodularization of agent services
Easy !ntegration - JNX smart agents
manageable through various protocols
Dynamic Nanagement
!ntegrates Existing Nanagement Solutions
Leverages Existing Standard Java Technologies
Applicable to a Wide Range of Applications
Possible Automatic !nstrumentation
7
Typical JNX Usage
Reading and Changing Application Configurations
!nfrastructure and Business Level Operational
Statistics
Availability
Early Detection of Capacity Problems
Application Performance, Business Process Productivity
Resources usage
Problems
Signaling events
Faults
State changes
!mproving Services via Proactive Alerting
8
Nanagement Before JNX
Firewall
Failover
Hardware
Web Server
Application
Server
Database
Primary Servers
Web Server
Application
Server
Database
Secondary Servers
Web Server
Nanagement
Console
App Server
Nanagement
Console
Web Server
Nanagement
Console
App Server
Nanagement
Console
Database
Nanagement
Console
Failover
Nanagement
Console
Database
Nanagement
Console
Firewall
Nanagement
Console
9
Nanagement With JNX
Firewall
Failover
Hardware
Web Server
Application
Server
Database
Primary Servers
Web Server
Application
Server
Database
Secondary Servers
NBean Server
!nstrumentation Layer
Nanagement
Application
Console
Connectorf
Adaptor
10
JNX Architecture
Management
Applications
Managed
Resources
Instrumentation
MBeans
JMX
Instrumentation
JMX Distributed
Services
JMX Agent
Services
Protocol and InfoModel independent
Source: JavaSoft
11
What !s an NBean?
A Java object that implements a specific
interface and conforms to certain design
patterns.
The management interface specifies:
Attributes (fields) which may be accessed
Operations (methods) which may be invoked
Notifications (events) which may be emitted
Constructors of the NBean`s Java class
12
NBean Types
Four Types of NBeans:
Standard NBean - Simple, Static
Dynamic NBean - Flexible, Dynamic
Open NBean - Basic Data Types Only
Nodel NBean - Run Time Support
Differ in !mplementations, Not the Way
They Are Nanaged
13
Standard NBean
For static management information.
Follows naming conventions.
The NBean server constructs the MBeanInfo
for standard NBeans via reflection.
Constructors - Any public constructors
Attributes - gettersfsetters
Operations - Any remaining public methods
Notification
1+
Standard NBean Example -
The Nanagement !nterface
public interface PrinterMBean {
public int getPrintJobCount();
public String getPrinterName();
public int getPrintQuality();
public void setPrintQuality(int q);
public void cancelPrintJobs();
public void performSelfCheck();
}
15
Standard NBean Example -
The NBean !mplementation
public class Printer extends
NotificationBroadcasterSupport
implements PrinterMBean {
private int printJobCount;
private String printerName;
private int printQuality;

public void performSelfCheck(){

if ( error ) {
sendNotification(notification);
}
}
16
Dynamic NBean
Supports management information that is
known only at runtime
!mplements DynamicMBean interface
Responsible for building its own MBeanInfo
structure
Generic methods expose:
Attributes
Operations
For changing resources
17
Dynamic NBean:
Generic Nethod Access
Dynamic
NBean
Protocol
Adaptor
!nstrumentation Layer
Agent Layer Distribution
Layer
Nanagement
Application
getAttribute
setAttribute
getAttributes
setAttributes
invoke()
Nanaged
Resource
version 1
Nanaged
Resource
version 2
getMBeanInfo()
18
Open NBean
Why are Open NBeans Open"?
Dynamic NBeans that use a subset of universal Java
types
Descriptively rich metadata
Open" to widest range of management applications
Does Not Require Serialization - supports
management applications not written in Java
No Custom Classloading
Required in 1.2
19
Nodel NBean
Generic, Configurable Dynamic NBean
Common Template for Different NBeans
Configured at Runtime: Descriptors
Default !mplementation - RequiredNodelNBean
Rapid !nstrumentation - No need to write an
NBean
Nodel NBean Features
Persistence - survive JNX agent crash
Notification Logging
Attribute value Caching - better performance
Operation Delegation - multiple manageable resources
20
Nodel NBean Example
ObjectName oName = new ObjectName();
createMBean(javax.management.modelmbe
an.RequiredModelMBean, oName );
Object managedResource = ;
setManagedResource();
ModelMBeanInfo info =
buildModelMBeanInfo( mbeanDesc );
setModelMBeanInfo();
1
2
3
21
JNX Notification
Notification - Java objects emitted by NBeans and
the NBean server to encapsulate events, alerts, or
general information.
Based on the Java event model
Specifies notification objects, the broadcaster,
the listener and filter interfaces that
notification senders and receivers must
implement.
Nanagement applications listen to the NBean
and NBean server notifications remotely.
22
Object Name
Uniquely identifies NBean
Two parts
domain name
keyfvalue property list (unordered)
[domainName]:name=value[,name=value]*
ObjectName class
23
JNX Agent Layer
JNX Agent - A Java process that provides a
set of services for managing a set of NBeans.
The container for an NBean server.
JNX Agent Level
NBean Server(s)
Agent Services
Four Nandatory Standard Services (NBeans)
N-Let Service
Timer Service
Nonitoring Service
Relation Service
2+
NBean Server
A registry for NBeans - NBeans have to be registered.
Exposes management interfaces:
Creates NBeans
Registers NBean
Handles notifications - addfremove listeners.
Handles access to NBeans - getfset attributes,
invoke operations.
Handles NBean queries - based on object names and
attributes.
NBeanServer mbeanServer =
NBeanServerFactory.createNBeanServer(HelloAgent);
25
Standard Agent Services:
N-Let Service
Expand JNX agent CODEBASE.
Dynamically load new components to the NBean server.
Allows network-enabled application to load its NBean
components from remote hosts.
Enables hot deployment.
<MLET
CODE = com.foo.HelloWorld
ARCHIVE = helloWorld.jar"
CODEBASE = http://www.foo.com/jars
NAME = helloWorld:name=hello,url=www.foo.com>
</MLET>
26
Standard Agent Services:
Timer Service
Schedule notifications for tasks that
need to be run once or at regular
intervals.
Specific Times
!ntervals
Nore elegant solution than background
threads in a J2EE environment.
27
Standard Agent Services:
Nonitoring Service
Common Nonitor Nanagement !nterface
Attributes
ObservedObject
ObservedAttribute
GranularityPeriod
Active
MonitorNotification
Three monitor implementations
Counter monitor: threshold
Gauge monitor: highflow threshold
String monitor: matches fdiffers
28
Standard Agent Services:
Relation Service
Define relations between NBean components
and react to changes in case of NBean
dependencies.
Consistency
Cardinality
Conceptually relate NBeans
Allows to manage NBeans as related groups
Typically grouped based on managed
resources or workflows they participate in.
29
Distributed Services Level
Connectors
Contains connector client and connector server
Hide the actual protocol being used to contact the agent.
Can use any convenient transport - RN!, RN!f!!OP,
HTTP, SOAP, JNS, J!N!, Raw" TCPfUDP, .
Protocol Adaptors
Listen for incoming messages that are constructed in a
particular protocol like HTTP, SNNP
JNX Remoting AP! (JSR-160) - The Standardization
30
JNX Remote AP! (JSR 160)
Allows Any Java Client To:
Discover JNX Connectors
Connect to Any Running JNX Server
Access to a Running JNX Server via a Protocol-
!ndependent Client AP!
JNX Remoting AP! Goals
!nteroperable - Completely defines standard protocols
Transparent - Remote access like local
Secure - Built on JSSE, JAAS, SASL
Flexible - New transport protocols can be added easily
31
JNX Remoting Connectors
RN! Connector - Required
JNXNP Connector - Based on Java
serialization over TCP
Generic Connector - Configurable by plugging
in modules to define Transport Protocol and
Object Wrapping
Connector Server Address
service:jmx:rmi:ffhostf.
service:jmx:jmxmp:ffhost:port
32
JNX Remoting Example:
Remote Access Like Local
Local Access:
NBeanServer mbs = NBeanServerFactory.createNBeanServer();
mbs.createNBean( className, obName );
Object a = mbs.getAttribute( obName, attr" );
Set names = mbs.queryNames(.);
Remote Access:
JNXConnector c = JNCConnectorFactory.connect(url);
NBeanServerConnection mbs = c.getNBeanServerConnection();
mbs.createNBean( className, obName );
Object a = mbs.getAttribute( obName, attr" );
Set names = mbs.queryNames(.);
c.close();
33
JNX Security
JNX Security Risks:
NBeanServer AP! Access
NBean AP! Access
Trusted NBean Sources
JNX Security introduced in JNX 1.2
Based on Standard Java Security Nodel by defining
Permissions (javax.security.Permission)
MBeanServerPermission
MBeanPermission
MBeanTrustPermission
Why not J2EE Role-base Security Nodel?
3+
NBean Permission Example
grant applone.jar { permission
javax.management.NBeanServerPermission
createNBeanServer, releaseNBeanServer"; );
grant applone.jar {
permission javax.management.NBeanPermission
com.Foo#do!t[d1|", invoke"; );
grant signedBy NyOrg" { permission
javax.management.NBeanTrustPermission register";);
35
JNX and J2SE
JNX is going into J2SE 1.5
JSR 17+ - Nonitoring and Nanagement
Specification for Java
Health Indicators:
Class loadfunload
Nemory allocation statistics
Garbage collection statistics
Nonitor info 8 statistics
Thread info 8 statistics
Object info
.
Runtime Control:
Heap size
verbose GC on demand
Garbage collection control
Thread creation control
Just-in-time compilation control
.
36
JNX and J2EE:
J2EE Nanagement (JSR 77)
JNX is Going into J2EE 1.+
Further J2EE Standardization: vendor
!ndependent Nanagement of J2EE Servers
Defines a Nodel of J2EE Nanaged Objects
No Java Classes
Nanaged EJB (NEJB)
Nanagement Capability:
Event Handling - statefattribute change,
creationfdestruction
State Nanagement - manage an object's state
Performance Nonitoring - statistics data
37
J2EE Nanaged Objects
38
Nanaged EJB (NEJB)
Context ctx = new !nitialContext();
NanagementHome home =
(NanagementHome)PortableRemoteObject.narrow(
ctx.lookup(ejbfmgmtfNEJB"), NanagementHome.class);
Nanagement mejb = home.create();
String domain = mejb.getDefaultDomain();
Set names = mejb.queryNames(
new ObjectName(domain+":j2eeType=EJBNodule,*"),null);
!terator itr = names.iterator();
while( itr.hasNext() ) {
ObjectName name = (ObjectName)itr.next();
ObjectNames[| ejbs = (ObjectName[|)mejb.getAttribute(name, ejbs");
)
All EJB Nodules
All EJBs in a Nodule
1
2
3
39
JNX !n Use Today
All Najor Application Servers
BEA WebLogic
!BN WebSphere
JBoss
Nanagement Applications
Tivoli Web Component Nanager
AdventNet Niddleware Nanager
Dirig Softare
Performance Nanagement Tools
Existing instrumentation
Custom instrumentation
+0
JNX Use Case: WebLogic
Administration and Configuration NBeans
Runtime NBeans - information about open servlet
sessions, active JDBC connections, JTS transactions,
pooled EJBs, JNS messages
Anything deployed into WebLogic is automatically
manageable
EJBComponentRuntime
EJBHomeRuntime
EJBRuntime
EJBTransactionRuntime
1 . n
1 . n
1 . 1
+1
Real-World JNX Usage
Log+j Runtime Control
JDBC Connection Pool Nanagement
HTTP Session Nanagement
Generic Cache Control
Cache Size
Cache Policy
Cache Hit Rate
Cache Refresh
+2
Real-World JNX Usage (cont.)
Socket Adaptor for !ntegration
Nonitoring Tool to Collect Data
Key Application Transaction Nonitoring
Pluggable Security Providers
Timer
Queue Nanagement
Custom Queue
JNS Queue
.
+3
Summary
JNX technology is a standard, mature and
complete open solution to manage and
monitor both Java applications and
underlying infrastructure.
Developers should have application
management and monitoring in mind during
design phase, not as an after-thought.
Developer's main task will be writing
interfaces and reporting tools that make use
of the instrumentation already provided by
Application Servers.
++
A Simple Demo: Log+j Control
Log+j Logger
LoggerController
NBean
HTTP Adaptor
JRNP Adaptor
NBean
Server
Web
Browser
NC+J
Console
+5
A Simple Demo: Log+j Control
(cont.)
public interface LoggerControllerMBean {
public String getLevel(String loggerName);
public void setLevel(String loggerName,String level);
}
public class LoggerController implements LoggerControllerMBean{
public String getLevel(String loggerName) {
Logger logger = Logger.getLogger(loggerName);
return logger.getLevel().toString();
}
public void setLevel(String loggerName, String level) {
Level level = Level.toLevel(level);
Logger.getLogger(loggerName).setLevel(level);
}
}
+6
References
JMX in Action
Benjamin G. Sullins, Mark Whipple
Publisher: Manning Publications Company
JMX: Managing J2EE with Java Management Extensions
Marc Fleury, Juha Lindfors
Publisher: Sams
Java and JMX: Building Manageable Systems
Heather Kreger, Ward K. Harold, Leigh Williamson, Ward Harold
Publisher: Pearson Education
Sun JMX Page: http://java.sun.com/products/JavaManagement
AdventNet: www.adventnet.com
MC4J: http://mc4j.sourceforge.net
MX4J: http://mx4j.sourceforge.net

You might also like