51
© Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

© Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

Embed Size (px)

Citation preview

Page 1: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

© Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008

How To Build Large Scale Enterprise Applications Using OSGi

Page 2: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Who Am I?

• 10 Years as a developer and architect• Mainly startups in telecoms and finance• Whole range of software lifecycle, design, dev, support

and admin

Page 3: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

3

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

• Provisioning• Installation• Remote Classloading in OSGi• Eclipse Plugin

3

What Have I Been Working On?

Page 4: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

4

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Who Are Paremus?

• UK based software company• Started as a consultancy in 1999• Formed by senior architects and decision makers• Switched to software company in 2004• Not Grid, Not N Tier, Fabric

4

Page 5: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

5

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Large Scale Enterprise Infrastructure

• 100+ Core’s• Multiple Applications• Multiple Requirements• Multiple Users

5

Page 6: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

6

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Types Of Industry

• Biotech• Engineering• Finance• Games • Military• Web 2.0/3.0?

6

Page 7: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

7

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

• Open Source Framework/Commercial Application• Version 1.2 GA: March 2008• Based on OSGi• Deploy/Manage OSGi applications life-cycle on remote

nodes

7

Page 8: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

8

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Newton @ Citigroup

• London Development Center• 800 Cores (8 CPU Boxes 16 GB each)• 100 Newton Instances• 800 User Components

8

Page 9: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

9

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Focus Of Talk

• Discussion vs Lecture• Not trying to sell you:

Any particular remote protocol Any particular programming model Any particular software ;)

• How do we build large scale apps - architecture, sys admin, etc.

9

Page 10: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

10

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

What’s The Problem?

10

Page 11: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

11

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Why Do We Scale?

11

• Increased Power• Increased Throughput• Reduced Latency• Increased Resilience

Page 12: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

12

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Problems Of Scale

• Complexity• Reliability• Inflexibility

12

Page 13: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

13

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

An Ideal Enterprise Architecture

13

Page 14: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

14

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Simplicity

14

• Make everything as simple as possible, but no simpler (Quote:Einstein)

• POJOs no dependencies, just business logic make developers lives easier - what about the rest of the

enterprise?

• Scale free patterns: Discovery vs static config Characteristics vs Lists

Page 15: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

15

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Simplicity

• Enterprise complexity shouldn’t get in the way of: the developer, or the architect, or the system administrator

• Make Tasks As Simple As Possible For The Individual

15

Page 16: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

16

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Model Driven

• Need to define the boundary conditions POJOs - need to add meta data somewhere Scale Free: where, when, how to scale Allows you to specify the service level dependencies

• Various DSL’s to describe models• Test deployment scenarios before you commit your

infrastructure• Allows An Enterprise To Quickly Introspect And

Change Their Infrastructure Based On Business Requirements

16

Page 17: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

17

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Why Take OSGi Into The Enterprise?

• Imports/Exports• Simple• Dynamic• Security• Mature• OSGi is an integral part of a Model Driven Architecture

17

Page 18: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

18

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Building Blocks

18

Page 19: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

19

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Newton Architecture

19

• Components• Bundles• Repository• System Manager• Provisioner• Container• Discovery• Bindings• Management

Page 20: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

20

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

View From 100,000 ft.

20

Page 21: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

21

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

View From 10,000 ft. (Functional Perspective)

21

Page 22: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

22

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

View From 10,000 ft. (User Perspective)

22

Page 23: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

23

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Details, details...

23

Page 24: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

24

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Components

24

• Supported models SCA Spring OSGi Switzerland of component deployment technologies

Page 25: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

25

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Repository

• Resilient/Highly available• Query Interface (LDAP)• Content sensitive

25

Page 26: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

26

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Systems

• Structured group of components• Defines:

which components scaling behaviour configuration

26

Page 27: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

27

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Systems

27

Job Queue

Workers

Dave

Page 28: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

28

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Systems<?xml version="1.0" encoding="iso-8859-1"?>

<system name="fractal-workers" boundary="fabric">

<description>An environment that sets up one worker for every container in the fabric</description>

<system.composite name="worker"

bundle="org.cauldron.newton.fractal.engine"

template="fractal-worker-template"

version="1.0.0">

<replication.handler name="scale" type="org.cauldron.newton.system.replication.ScalableReplicationHandler">

<property name="scaleFactor" value="1" type="float" />

<property name="fixedDelta" value="-1" type="integer" />

<property name="minimum" value="1" type="integer" />

</replication.handler>

</system.composite>

<system.composite name="space"

bundle="org.dancres.blitz"

template="blitzTemplate"

version="1.2">

</system.composite>

</system>

28

Page 29: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

29

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

ReplicationHandlerpublic interface ReplicationHandler {

void initialise(SystemContext ctx) throws SystemConfigurationException;

SystemContext getSystemContext() throws SystemConfigurationException;

Collection<CompositeInstance> replicate(

SystemCompositeDescriptor template,

SystemStateModel model)

throws SystemConfigurationException;

void destroy(SystemContext ctx);

}

32

Page 30: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

30

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Presence

• Lightweight pattern for announcing location of components

• Pluggable architecture for defining which components are “activated”

33

Page 31: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

31

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Active Passive Presence Behaviour

34

Time

Page 32: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

32

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

ActivePassive<presence-group labels="mylabel" strategy="org.cauldron.newton.presence.strategy.ActivePassiveStrategy">

<property name="maximumActive" value="1" type="integer" />

</presence-group>

35

Page 33: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

33

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

PresenceStrategy

public interface PresenceStrategy {

void configure(Map<String, Object> config);

long execute(PresenceGroup group);

}

36

Page 34: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

34

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Negotiation

• In An Enterprise Environment Not All Nodes Are Equal Need To Make Best Use Of Resource

• Contracts Requirement Cost/Value Assessment

• Features Extensible

• Life-cycle Lifetime Life-cycle events, initialised, bound, unbound, destroy

37

Page 35: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

35

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Contract<contract features="(&amp;(machine.arch=i386)(machine.availableProcessors>1))"/>

<contract features="(!(container.composite.foo>0))"/>

<contract features="(network.bandwidth.in>1M)"/>

38

Page 36: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

36

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Assessmentpublic interface CompositeAssessor {

public static final int MINIMUM_PRIORITY = 1000;

public static final int MAXIMIM_PRIORITY = 0;

public static final int NORMAL_PRIORITY = 500;

int getPriority();

/**

* Return a positive integer value representing the "cost" to host the given

* instance, or -1 if the instance cannot be installed for any cost

*/

int accept(CompositeInstance instance, Collection<CompositeInstance> current);

}

39

Page 37: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

37

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

FeaturesProviderpublic interface FeaturesProvider {

String getNamespace();

void addFeaturesChangeListener(FeatureChangeListener listener);

void removeFeaturesChangeListener(FeatureChangeListener listener);

Collection<String> getFeatureNames();

<T> ContainerFeature<T> getFeature(String name);

}

40

Page 38: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

38

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Installation And Garbage Collection

• Bundle install - imports/exports/requires/versions• Component install - services/references -

bindings/interfaces• Graph walker• Simplifies Job Of System Administrator When

Deploying Changes To An Application

41

Page 39: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

39

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Discovery

• Registry• Query Interface• Filters and Attributes

42

Page 40: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

40

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Filters and Attributes<reference name="foo">

<interface.java interface="com.example.Foo"/>

<binding.rmi filter="(check=true)">

</reference>

<service name="foo">

<interface.java interface="com.example.Foo"/>

<binding.rmi>

<attribute name="check" value="true" />

</binding.rmi>

</service>

43

Page 41: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

41

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

SCA Bindings

• OSGi (local)• RMI • WS*• JMS• Java Space• ...

44

Page 42: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

42

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Marshalling Java Objects

• Bundle Import/Export not enough• Private classes are serialized• Lifecycle of OSGi bundles when unmarshalled

45

Page 43: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

43

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Management

• JMX• Dynamic• Pluggable• Views/Trackers

46

Page 44: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

44

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Tracking MBeansManagementBeanListener listener = new ManagementBeanListener() {

public void addBean(ObjectName name, MBeanServerConnection sourceConnection) {

log.info("Added " + name);

}

public void changedBean(ObjectName name, MBeanServerConnection sourceConnection) {

log.info("Changed " + name);

}

public void removeBean(ObjectName name, MBeanServerConnection sourceConnection) {

log.info("Removed " + name);

}

}

47

Page 45: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

45

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Tracking MBeans@Reference

private ManagementView view;

...

String CONTAINER = "org.cauldron.newton:Type=ContainerMBean,*";

ObjectName name = new ObjectName( CONTAINER );

ManagementBeanTracker tracker = new ManagementBeanTracker(name, listener, view);

tracker.open();

48

Page 46: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

46

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Recovery

• Shared VM• Java Security gives no protection against Out Of

Memory• CrashOnly

Dave Patterson, CS researcher at Berkely Having Built A Resilient Infrastructure That Can Cope With

Change And Accepts Dynamicity Then We Can Deal Effectively With The Concept Of Failure

49

Page 47: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

47

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Conclusions

• In order to build scalable applications you need to use the right patterns

• Patterns should be simple (i.e. expose relevant problems to relevant people)

• Model Driven Patterns Are Easier To Introspect And Change

50

Page 48: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

48

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Conclusions

• Expect failure at larger scales• Even small problems will be magnified by scale

51

Page 49: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

49

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Conclusions

• Dynamic behaviours can increase resilience• Resilience cannot be achieved via forcing the world to

be the way you want it• King Canute and his enterprise?

52

Page 50: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

50

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Summary

• Large scale enterprise applications can be built using OSGi

• and you can deploy them on Newton and Infiniflow ;)

53

Page 51: © Paremus 2008 by David Savage; made available under the EPL v1.0 | 18/03/2008 How To Build Large Scale Enterprise Applications Using OSGi

51

How To Build Large Scale Enterprise Applications Using OSGi | © Paremus 2008 by David Savage; made available under the EPL v1.0

Questions?

• Contact info: [email protected] http://newton.codecauldron.org http://www.paremus.com Exhibitor Stand 400 (located just by the doorway) Come and see a demo.

54