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

TS-1188

Embed Size (px)

DESCRIPTION

desenvolvimento java

Citation preview

Page 1: TS-1188

12005 JavaOneSM Conference | Session TS-1188

John ArmstrongArchitectural LeadYolus Limitedhttp://www.yolus.comSession TS-1188

Developing a Scalable Distributed Server with JMX™

Page 2: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 2

Learn how Java™ ManagementExtensions “JMX™” were used as the cornerstone of a scalable and manageable banking system distributed across several servers

Configuring and managing a Distributed ApplicationAchieving Scalability With JMX

Page 3: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 3

Agenda

Outline of the problemWriting self describing servicesManaging complexityReducing the develop/deploy/test cycleImplementation difficulties

Page 4: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 4

Outline of the problemWriting self describing servicesManaging complexityReducing the develop/deploy/test cycleImplementation difficulties

Agenda

Page 5: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 5

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

Page 6: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 6

Three Tier Architecture

Page 7: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 7

JMX API Based Component Architecture

Page 8: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 8

DEMOConfiguration of a Risk Management Server

Page 9: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 9

Outline of the problemWriting self describing servicesManaging complexityReducing the develop/deploy/test cycleImplementation difficulties

Agenda

Page 10: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 10

The Different Types of MBean

Page 11: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 11

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

Page 12: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 12

Comparing the Types of MBean

ModelOpenDynamicStandard

YesBuilt in features

YesEasy to write tools

YesAuto GUI

OptionalRequiredOptionalDocumented

YesEasy to write

Page 13: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 13

The Hello World Standard MBeanpublic 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 );

}}

Page 14: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 14

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 it’s available even if the class is not

• Use Annotations or XDoclet to add metadata• Automate this with ant

Page 15: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 15

Auto Generated Proxy and MBeanInfo

Page 16: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 16

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;}

...}

Page 17: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 17

Outline of the problemWriting self describing servicesManaging complexityReducing the develop/deploy/test cycleImplementation difficulties

Agenda

Page 18: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 18

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

Page 19: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 19

Finding Other Components

• Synchronous or asynchronous lookup?• Simplicity vs. flexibility and robustness

• Start-up order• Deduce, configure or don’t care?

• Attribute based lookup or naming

Page 20: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 20

Variations

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

Page 21: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 21

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

Page 22: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 22

Outline of the problemWriting self describing servicesManaging complexityReducing the develop/deploy/test cycleImplementation difficulties

Agenda

Page 23: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 23

Testing

• Lightweight JMX technology can be used to deploy components in unit tests

• Configure and manage automated tests• Add self tests to your components

Page 24: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 24

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

Page 25: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 25

Problems With Class Loading

• Conceptually difficult—one classpath causes enough problems!• Use a simple class loader hierarchy• Add classpath entries to your jar files

Page 26: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 26

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

Page 27: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 27

Outline of the problemWriting self describing servicesManaging complexityReducing the develop/deploy/test cycleImplementation difficulties

Agenda

Page 28: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 28

Implementation Difficulties

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

Page 29: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 29

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

Page 30: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 30

Q&A

Page 31: TS-1188

2005 JavaOneSM Conference | Session TS-1188 | 31

Submit Session Evaluations for Prizes!

• 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.

Your opinions are important to Sun

Page 32: TS-1188

322005 JavaOneSM Conference | Session TS-1188

John ArmstrongArchitectural LeadYolus Limitedhttp://www.yolus.comSession TS-1188

Developing a Scalable Distributed Server with JMX