Sie sind auf Seite 1von 32

Developing a

Scalable Distributed Server


with JMX
John Armstrong
Architectural Lead
Yolus Limited
http://www.yolus.com
Session TS-1188
2005 JavaOneSM Conference | Session TS-1188

Achieving Scalability With JMX

Configuring and managing a Distributed Application

Learn how Java Management


Extensions JMX were used as
the cornerstone of a scalable and
manageable banking system distributed
across several servers

2005 JavaOneSM Conference | Session TS-1188 |

Agenda
Outline of the problem
Writing self describing services
Managing complexity
Reducing the develop/deploy/test cycle
Implementation difficulties

2005 JavaOneSM Conference | Session TS-1188 |

Agenda
Outline of the problem
Writing self describing services
Managing complexity
Reducing the develop/deploy/test cycle
Implementation difficulties

2005 JavaOneSM Conference | Session TS-1188 |

The Problem
It is a given that you must componentize
Scaling to 1000s of interdependent components
is the major challenge
Separation of development and deployment
Reduce the develop/deploy/test cycle
Achieve code reuse in the large

2005 JavaOneSM Conference | Session TS-1188 |

Three Tier Architecture

2005 JavaOneSM Conference | Session TS-1188 |

JMX API Based


Component Architecture

2005 JavaOneSM Conference | Session TS-1188 |

DEMO
Configuration of a Risk Management Server

2005 JavaOneSM Conference | Session TS-1188 |

Agenda
Outline of the problem
Writing self describing services
Managing complexity
Reducing the develop/deploy/test cycle
Implementation difficulties

2005 JavaOneSM Conference | Session TS-1188 |

The Different Types of MBean

2005 JavaOneSM Conference | Session TS-1188 | 10

Choosing the Type of MBean


Writing an MBean should be as easy as possible
All MBeans should have documentation
MBeans should have a reasonable GUI to
configure them
It should be easy to write management tools

2005 JavaOneSM Conference | Session TS-1188 | 11

Comparing the Types of MBean


Standard Dynamic
Easy to write
Documented

Open

Yes
Optional

Required Optional

Auto GUI

Yes

Easy to write tools

Yes

Built in features

Model

Yes

2005 JavaOneSM Conference | Session TS-1188 | 12

The Hello World Standard MBean


public class MyService implements MyServiceMBean {
private String message = "Hello World!";
public String getMessage() {
return message;
}
public void setMessage( String message ) {
this.message = message;
}
public void printMessage() {
System.out.println( message );
}
}

2005 JavaOneSM Conference | Session TS-1188 | 13

Making OpenMBeans Easy


Generate a wrapper (OpenProxy) for your
service that uses restricted parameter types:
Primitives Wrapper classes
JavaBeans Specification CompositeData

Generate MBeanInfo using introspection


and serialize it so its available even if the
class is not
Use Annotations or XDoclet to add metadata
Automate this with ant
2005 JavaOneSM Conference | Session TS-1188 | 14

Auto Generated Proxy and MBeanInfo

2005 JavaOneSM Conference | Session TS-1188 | 15

An MBean With Annotations


@MBean (
description="A service that prints a message"
)
public class MyService {
private String message = "Hello World!";
@MBean (
description="The message to print out"
)
public String getMessage() {
return message;
}
...
}

2005 JavaOneSM Conference | Session TS-1188 | 16

Agenda
Outline of the problem
Writing self describing services
Managing complexity
Reducing the develop/deploy/test cycle
Implementation difficulties

2005 JavaOneSM Conference | Session TS-1188 | 17

Issues Not Addressed by JMX API


A naming convention
Hierarchical path names/Standard keys

A component lifecycle
An mbean deployed method at least

An index of available MBeans


A format must be defined

An error reporting convention


An mbean OK property at least

Starting JVM
Use a JMX API enabled daemon process
2005 JavaOneSM Conference | Session TS-1188 | 18

Finding Other Components


Synchronous or asynchronous lookup?
Simplicity vs. flexibility and robustness

Start-up order
Deduce, configure or dont care?

Attribute based lookup or naming

2005 JavaOneSM Conference | Session TS-1188 | 19

Variations
Maintain consistency between similar but
distinct configurations
Development, UAT and Production
Production and a Failover system
Tokyo Server and New York Server

2005 JavaOneSM Conference | Session TS-1188 | 20

J.F.C/Swing Applications
Build your own J.F.C./Swing clients from
configurable components, for example:
Charting plugin
Menu Manager
Options property sheet

Monitor client components at runtime


Guarantee the same code is used by client
and server

2005 JavaOneSM Conference | Session TS-1188 | 21

Agenda
Outline of the problem
Writing self describing services
Managing complexity
Reducing the develop/deploy/test cycle
Implementation difficulties

2005 JavaOneSM Conference | Session TS-1188 | 22

Testing
Lightweight JMX technology can be used to
deploy components in unit tests
Configure and manage automated tests
Add self tests to your components

2005 JavaOneSM Conference | Session TS-1188 | 23

Class Loading
Hot deploy components
Reduce the develop-deploy-test cycle

Deploy all code to a web server


Consistent code across the network
Simply build code to deploy it

2005 JavaOneSM Conference | Session TS-1188 | 24

Problems With Class Loading


Conceptually difficultone classpath causes
enough problems!
Use a simple class loader hierarchy
Add classpath entries to your jar files

2005 JavaOneSM Conference | Session TS-1188 | 25

Problems With Class Loading


You must use a decent security policy
Use a custom SecurityManager to provide diagnostics
Use https in development

Downloading code is slow


Use a custom jar URL protocol handler

2005 JavaOneSM Conference | Session TS-1188 | 26

Agenda
Outline of the problem
Writing self describing services
Managing complexity
Reducing the develop/deploy/test cycle
Implementation difficulties

2005 JavaOneSM Conference | Session TS-1188 | 27

Implementation Difficulties
Complexity of asynchronous lookup
Security and robustness of lookup service
Lack of tool support for RMI activation

2005 JavaOneSM Conference | Session TS-1188 | 28

Summary
Manageability is the key to building a scalable
distributed server
Self documenting components
Automated lookup
Variations

Manageability speeds development


Visualize the architecture
Easily deploy new code
Automate testing

2005 JavaOneSM Conference | Session TS-1188 | 29

Q&A

2005 JavaOneSM Conference | Session TS-1188 |

30

Submit Session Evaluations


for Prizes!
Your opinions are important to Sun

You can win a $75.00 gift certificate to the on-site


Retail Store by telling Sun what you think!
Turn in completed forms to enter the daily drawing
Each evaluation must be turned in the same day as
the session presentation
Five winners will be chosen each day (Sun will send
the winners e-mail)
Drop-off locations: give to the room monitors or use any
of the three drop-off stations in the North and South Halls
Note: Winners on Thursday, 6/30, will receive and can redeem
certificates via e-mail.
2005 JavaOneSM Conference | Session TS-1188 | 31

Developing a Scalable
Distributed Server with JMX
John Armstrong
Architectural Lead
Yolus Limited
http://www.yolus.com
Session TS-1188
2005 JavaOneSM Conference | Session TS-1188

32

Das könnte Ihnen auch gefallen