186
©2014 IBM Corporation Making everything better with OSGi a happy case study in building a really nice runtime Holly Cummins [email protected] @holly_cummins

Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

Embed Size (px)

DESCRIPTION

OSGi Community Event 2014 Abstract: The WebSphere Application Server Liberty Profile makes extensive use of OSGi technologies to achieve a dynamic, compact, flexible and powerful application server. Using a foundation of Equinox, Subsytems, Configuration Admin, Metatype, and Declarative Services, we built a right-sized elastically-capable runtimes which allows users to get going with (almost) zero-setup, (almost) zero-hardware, and (really) zero-migration. This talk will discuss how Liberty uses OSGi, what OSGi gives us, why OSGi services are the best thing since sliced bread, what we've learned, and our development best practices. Speaker Bio: Holly Cummins is a senior software engineer developing enterprise middleware with the IBM WebSphere, and a committer on the Apache Aries project. She is a co-author of Enterprise OSGi in Action and has spoken at Devoxx, JavaZone, The ServerSide Java Symposium, JAX London, GeeCon, and the Great Indian Developer Summit, as well as a number of user groups.

Citation preview

Page 1: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Making everything better with OSGi

a happy case study in building a really nice runtime

Holly Cummins [email protected]

@holly_cummins

Page 2: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Let’s talk about WebSphere.

Page 3: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Let’s talk about WebSphere.

Awesome capabilities…

Page 4: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Let’s talk about WebSphere.

Awesome capabilities…

Page 5: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Let’s talk about WebSphere.

Awesome capabilities…

… for production.

Page 6: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Let’s talk about WebSphere.

Awesome capabilities…

… for production.

For development, historically not so well-suited.

Page 7: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

History

Page 8: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

History

Page 9: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

History

forever

Page 10: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

Big codebase

History

forever

Page 11: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

Big codebase

Big customer base

History

forever

Page 12: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

Big codebase

Big customer base

Big workloads

History

forever

Page 13: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

Big codebase

Big customer base

Big workloads

… Big inhibitors to massive change

History

forever

Page 14: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

Big codebase

Big customer base

Big workloads

… Big inhibitors to massive change

History

This is not a complaint.

This is a problem we arehappy to have.

forever

Page 15: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

WebSphere Application Server (the full profile) has been around since 1998

Big codebase

Big customer base

Big workloads

… Big inhibitors to massive change

History

This is not a complaint.

This is a problem we arehappy to have.

But it is still a problem.

forever

Page 16: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Page 17: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Code that has been around forever…

Page 18: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Code that has been around forever…

No matter how good you are, or how smart you are

Page 19: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Code that has been around forever…

No matter how good you are, or how smart you are

If your code lives long enough, and is used enough, it ends up looking like…

Page 20: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Code that has been around forever…

No matter how good you are, or how smart you are

If your code lives long enough, and is used enough, it ends up looking like…

?!

Page 21: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Code that has been around forever…

No matter how good you are, or how smart you are

If your code lives long enough, and is used enough, it ends up looking like…

dragons

?!

Page 22: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Code that has been around forever…

No matter how good you are, or how smart you are

If your code lives long enough, and is used enough, it ends up looking like…

dragons

?!

Especially code that has roots

going back to late ‘90s…

Page 23: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

By Steve Collis from Melbourne, Australia [CC-BY-2.0 (http://

creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

How do you manage dragons?

Page 24: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

By Steve Collis from Melbourne, Australia [CC-BY-2.0 (http://

creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

Clever WebSphere architects

How do you manage dragons?

Page 25: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

By Steve Collis from Melbourne, Australia [CC-BY-2.0 (http://

creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

Clever WebSphere architects OSGi

How do you manage dragons?

Page 26: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi and WAS: The first pass…

OSGi was included in WAS v6.1, in 2006

Went from lots of arbitrary jars to a few bundles

Achieved some modularity enforced by OSGi

We did not use or expose OSGi services

Compatibility constraints: WAS is the bottom of the stack

Assumptions about resource initialization and availability

Entrenched dependencies between some core elements

Page 27: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Did that fix everything?

Page 28: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Not quite.

Did that fix everything?

By Steve Collis from Melbourne, Australia [CC-

BY-2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

Page 29: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Page 30: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Page 31: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Simple

Page 32: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Simple

Dynamic

Page 33: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Simple

Dynamic

Light-weight

Page 34: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Simple

Dynamic

Light-weight

Composable / Flexible

Page 35: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Simple

Dynamic

Light-weight

Composable / Flexible

Extensible

Page 36: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… If we could start over, what would we want?

Developer-friendly

Simple

Dynamic

Light-weight

Composable / Flexible

Extensible

selectable content

clear API/SPI runtime/app

isolation

human usable configuration

Page 37: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

runtimeonly

some combination oftechnologies

!app-centered

everything

What if…

grokable config

provisioning

Page 38: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if…

grokable config

provisioning

runtimeonly

some combination oftechnologies

!app-centered

everything

How do we do this?

Page 39: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if… runtime

only

some combination oftechnologies

!app-centeredeverything

And yet allow this?

no restarts

Page 40: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if…

And for crying out loud, can we prevent THIS?!

runtime3rd party

bundleB

systembundle

A

Page 41: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if…

And for crying out loud, can we prevent THIS?!

runtime3rd party

bundleB

systembundle

A

Application

Page 42: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if…

And for crying out loud, can we prevent THIS?!

runtime3rd party

bundleB

systembundle

A

Application

Page 43: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What if…

And for crying out loud, can we prevent THIS?!

runtime3rd party

bundleB

systembundle

A

Application

X

Page 44: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

The egg problem

“Create a light-weight profile of WebSphere that starts in under 2 seconds… Don’t break any eggs”

— Ian Robinson (cleverest WebSphere architect)

Page 45: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

The egg problem

“Create a light-weight profile of WebSphere that starts in under 2 seconds… Don’t break any eggs”

— Ian Robinson (cleverest WebSphere architect)

By miya (miya's own file) [CC-BY-3.0 (http://creativecommons.org/licenses/by/3.0)], via Wikimedia Commons

Page 46: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity model

Page 47: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Page 48: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Page 49: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Page 50: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Level 4: Loose coupling

Page 51: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Level 4: Loose coupling

Level 5: Devolution

Page 52: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Level 4: Loose coupling

Level 5: Devolution

Level 6: Dynamism

Page 53: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Level 4: Loose coupling

Level 5: Devolution

Level 6: Dynamism

Level 7: Peter Kriens

Page 54: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Level 4: Loose coupling

Level 5: Devolution

Level 6: Dynamism

Level 7: Peter Kriens

Websphere Full Profile

Page 55: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi maturity modelLevel 1: Ad Hoc

Level 2: Modules

Level 3: Modularity

Level 4: Loose coupling

Level 5: Devolution

Level 6: Dynamism

Level 7: Peter Kriens

Websphere Liberty Profile

Page 56: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Dealing with our legacy

We needed a new kernel

Used the new base to re-group…

Lots of code still common with full profile

Wrap/Shim: New face on old code

Patch: tweak and replace bits where necessary

Page 57: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Building a kernel from scratch

OSGi-based for all the reasons

First-class use of OSGi services

Must react to configuration changes

Runtime composition on-the-fly

Page 58: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Bundle manifests

Page 59: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Bundle manifests? What manifests?We use Eclipse .classpath to

Determine project build order

Generate ant classpath

Bnd takes care of the rest

Declare services using annotations

Bnd makes overrides really easy

Useful when integrating legacy code

Page 60: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Bundle manifests? What manifests?We use Eclipse .classpath to

Determine project build order

Generate ant classpath

Bnd takes care of the rest

Declare services using annotations

Bnd makes overrides really easy

Useful when integrating legacy code

New developers need to have almost no awareness we’re

Page 61: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

ConfigurationSettled on XML for configuration format

Ubiquitous

Expressive

BUT, for simplicity:

single file

usable defaults

<server description=“simple”> <featureManager> <feature>jsp-2.2</feature> </featureManager> ! <httpEndpoint id=“defaultHttpEndpoint” httpPort=“9080” httpsPort=“9443” /> </server>

Page 62: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

ConfigurationComposable system requires composable configuration:

Individual components own their config

No centralized repository

No externally defined global config model

Page 63: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

ConfigurationComposable system requires composable configuration:

Individual components own their config

No centralized repository

No externally defined global config modelConfiguration Admin and Metatype

- job done

Page 64: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

ConfigurationComposable system requires composable configuration:

Individual components own their config

No centralized repository

No externally defined global config modelConfiguration Admin and Metatype

- job mostly done

Page 65: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Metatype Equinox impl + extensions

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

Page 66: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Metatype Equinox impl + extensions

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

human readable: 1h30m converted to unit of

choice

Page 67: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Metatype Equinox impl + extensions

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

human readable: 1h30m converted to unit of

choiceused by developer tools to help prompt for the right kind of

path: file vs. url

Page 68: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Metatype Equinox impl + extensions

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

human readable: 1h30m converted to unit of

choiceused by developer tools to help prompt for the right kind of

path: file vs. url

type=“String” ibm:type=“password”

The value is a “SerializedProtectedString”,

which is not a String.

Page 69: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Using OSGi Services…

?

BlueprintDeclarative Services

yes, there are others. We focused on these two.

Page 70: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Using OSGi Services… Who in their right mind wants to manage OSGi services themselves??

?

BlueprintDeclarative Services

yes, there are others. We focused on these two.

Page 71: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Using OSGi Services… Who in their right mind wants to manage OSGi services themselves??

Exactly. NOBODY.?

BlueprintDeclarative Services

yes, there are others. We focused on these two.

Page 72: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Declarative ServicesWe chose DS for two main reasons:

Timing: Blueprint and Aries were just getting started

Integration with Configuration Admin and Metatype!

Config injected as one unit

activate/modified/updated methods

Service instance creation based on metatype-declared factory pid

DS target filters can be set via configuration

Page 73: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

DS is AWESOME!

DS is a central part of the Liberty runtime

CA + M + DS = “magic”We do insane things with config-derived target filters

Our runtime would not be what it is without DS in the middle of it

Page 74: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

But …

Page 75: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Remember this?We need to prevent

THIS

runtime3rd party

bundleB system

bundleA

Application

X

Page 76: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Package privacy

Page 77: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Package privacy

OSGi lets you keep your internals private.

Page 78: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Package privacy

OSGi lets you keep your internals private.

Your externals are public.

Page 79: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Package privacy

OSGi lets you keep your internals private.

Your externals are public.

PublicPrivate

Page 80: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Package privacy

OSGi lets you keep your internals private.

Your externals are public.

PublicPrivate

Page 81: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularity

bundle C

bundle Abundle B

Page 82: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

Page 83: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

Wait a minute, it wasn’t supposed to be that

public …

Page 84: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

Wait a minute, it wasn’t supposed to be that

public …

Page 85: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

Page 86: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bund

le F

bund

le E

bundle G

bundle M

bund

le N

bund

le I

bundle K

bund

le Jbu

ndle O

bund

le P

bund

le N

bund

le L

bundle M

bund

le Q

bundle C

bund

le A

bund

le B

Page 87: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bund

le F

bund

le E

bundle G

bundle M

bund

le N

bund

le I

bundle K

bund

le Jbu

ndle O

bund

le P

bund

le N

bund

le L

bundle M

bund

le Q

bundle C

bund

le A

bund

le BWhat bundles do I

actually need?

Page 88: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bund

le F

bund

le E

bundle G

bundle M

bund

le N

bund

le I

bundle K

bund

le Jbu

ndle O

bund

le P

bund

le N

bund

le L

bundle M

bund

le Q

bundle C

bund

le A

bund

le BWhat bundles do I

actually need?

Could I just have an archive, please?

Page 89: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Granularitybundle D

bund

le F

bund

le E

bundle G

bundle M

bund

le N

bund

le I

bundle K

bund

le Jbu

ndle O

bund

le P

bund

le N

bund

le L

bundle M

bund

le Q

bundle C

bund

le A

bund

le BWhat bundles do I

actually need?

Could I just have an archive, please?

Page 90: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

This is not a new requirement

Page 91: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

This is not a new requirement

Lots of attempts to solve this problem

Page 92: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

This is not a new requirement

Lots of attempts to solve this problem

Eclipse features

Page 93: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

This is not a new requirement

Lots of attempts to solve this problem

Eclipse features

Equinox composite bundles

Page 94: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

This is not a new requirement

Lots of attempts to solve this problem

Eclipse features

Equinox composite bundles

Apache Aries Enterprise Bundle Archives (.ebas)

Page 95: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

This is not a new requirement

Lots of attempts to solve this problem

Eclipse features

Equinox composite bundles

Apache Aries Enterprise Bundle Archives (.ebas)

Liberty features (mark 1)

Page 96: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

Page 97: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Page 98: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Page 99: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Granularity

Page 100: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Granularity

Package isolation

Page 101: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Granularity

Package isolation

Packaging

Page 102: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Granularity

Package isolation

Packaging

Page 103: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Granularity

Package isolation

Packaging

Page 104: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi Subsystems are AWESOME

A new(ish) OSGi standard

Liberty uses the Apache Aries implementation

Granularity

Package isolation

Packaging

Page 105: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

When better boxes is not enoughbundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

Page 106: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

When better boxes is not enoughbundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

bundle M

Page 107: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

When better boxes is not enoughbundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

bundle M

Page 108: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

When better boxes is not enoughbundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

bundle M Extension

Page 109: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

When better boxes is not enoughbundle D

bundle F

bundle E

bundle G

bundle H

bundle M

bundle N

bundle I

bundle K

bundle Jbundle O bundle P

bundle N

bundle L bundle M

bundle Q

bundle C

bundle Abundle B

Resolver hook

bundle M Extension

Page 110: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Sophisticated package visibility

Features explicitly declare API and SPI packages (IBM-* metadata in the feature manifest)

Isolation between API/SPI, apps/extensions/runtime is enforced in a few ways:

Subsystems (the Aries impl) for OSGi Applications (API)

Resolver hooks and/or Eclipse Regions for isolation between runtime, extensions (SPI), and containers (API).

Page 111: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Page 112: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Dynamically install features (subsystems) based on configuration

Page 113: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Dynamically install features (subsystems) based on configuration

Adding or removing features …

Page 114: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Dynamically install features (subsystems) based on configuration

Adding or removing features …

installs or uninstalls bundles…

Page 115: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Dynamically install features (subsystems) based on configuration

Adding or removing features …

installs or uninstalls bundles…

which adds or removes configurations…

Page 116: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Dynamically install features (subsystems) based on configuration

Adding or removing features …

installs or uninstalls bundles…

which adds or removes configurations…

which triggers the creation or removal of services!

Page 117: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Provisioning

Dynamically install features (subsystems) based on configuration

Adding or removing features …

installs or uninstalls bundles…

which adds or removes configurations…

which triggers the creation or removal of services!

No restart needed. !

#really

Page 118: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Did we get rid of all the dragons?

Page 119: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Did we get rid of all the dragons?

By Abraham (Own work) CC-BY-3.0 via Wikimedia Commons

Page 120: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Did we get rid of all the dragons?

The OSGi dragon

By Abraham (Own work) CC-BY-3.0 via Wikimedia Commons

Page 121: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Did we get rid of all the dragons?

The OSGi dragon

By Abraham (Own work) CC-BY-3.0 via Wikimedia Commons

Page 122: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?

Page 123: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

Page 124: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

OSGi just makes the problem more obvious

Page 125: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

OSGi just makes the problem more obvious

Semantic versioning is …

Page 126: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

OSGi just makes the problem more obvious

Semantic versioning is …

Beautiful

Page 127: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

OSGi just makes the problem more obvious

Semantic versioning is …

Beautiful

Insufficient

Page 128: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

OSGi just makes the problem more obvious

Semantic versioning is …

Beautiful

Insufficient

Our developers never touch versions

Page 129: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What version should this be?This is ALWAYS a hard problem in any non-trivial evolving system

OSGi just makes the problem more obvious

Semantic versioning is …

Beautiful

Insufficient

Our developers never touch versions

That’s what a release team is for :)

Page 130: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

How do I interact with X?Let DS do it. Really.

DS is excellent at managing non-trivial service dependencies

It is very unlikely that you will be able to do better— just let DS do it. That means:

Don’t register services inside a component

Don’t manage references inside a component

Page 131: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Why is my test failing intermittently ?

Page 132: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Why is my test failing intermittently ?

Because something hasn’t happened yet.

Page 133: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can hurt!

Page 134: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can hurt!

Service dynamics are a huge hurdle for “new” developers

Page 135: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can hurt!

Service dynamics are a huge hurdle for “new” developers

DI and IoC can turn even experienced brains inside out if they aren’t prepared. Thankfully, they do seem to recover.

Page 136: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can hurt!

Service dynamics are a huge hurdle for “new” developers

DI and IoC can turn even experienced brains inside out if they aren’t prepared. Thankfully, they do seem to recover.

DS helps a LOT

Page 137: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can hurt!

Service dynamics are a huge hurdle for “new” developers

DI and IoC can turn even experienced brains inside out if they aren’t prepared. Thankfully, they do seem to recover.

DS helps a LOT

But …

Page 138: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can still hurt.

Page 139: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can still hurt.

Being really lazy is hard work!

Page 140: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can still hurt.

Being really lazy is hard work!

Easy to make assumptions

Page 141: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can still hurt.

Being really lazy is hard work!

Easy to make assumptions

Service availability

Page 142: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can still hurt.

Being really lazy is hard work!

Easy to make assumptions

Service availability

Event ordering

Page 143: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Service dynamics can still hurt.

Being really lazy is hard work!

Easy to make assumptions

Service availability

Event ordering

Especially in our tests

Page 144: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?

Page 145: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?

The server

Page 146: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?

The server

Page 147: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?What does this boundary even mean

in an extensible system?

The server

Page 148: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?What does this boundary even mean

in an extensible system?

The server

Page 149: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?What does this boundary even mean

in an extensible system?

The server

Page 150: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?What does this boundary even mean

in an extensible system?

The server

Page 151: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is the server started?What does this boundary even mean

in an extensible system?

Care about the services

you care about

Page 152: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Page 153: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Devolved configuration is great. But ..

Page 154: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Devolved configuration is great. But ..

Tolerating unrecognised elements is great when your config is correct.

Page 155: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Devolved configuration is great. But ..

Tolerating unrecognised elements is great when your config is correct.

It’s not so good when your config is wrong.

Page 156: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Devolved configuration is great. But ..

Tolerating unrecognised elements is great when your config is correct.

It’s not so good when your config is wrong.

Aggregated documentation is good for users.

Page 157: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Devolved configuration is great. But ..

Tolerating unrecognised elements is great when your config is correct.

It’s not so good when your config is wrong.

Aggregated documentation is good for users.

Aggregated documentation is (sort of) needed for tooling

Page 158: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

What’s the schema for the configuration?

Devolved configuration is great. But ..

Tolerating unrecognised elements is great when your config is correct.

It’s not so good when your config is wrong.

Aggregated documentation is good for users.

Aggregated documentation is (sort of) needed for tooling

We generate an xsd at build-time so tooling can validate user config

Page 159: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?

Page 160: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?OH YES.

Page 161: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?OH YES.

Our server is GREAT.

Page 162: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?OH YES.

Our server is GREAT.

Starts in 3s …

Page 163: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?OH YES.

Our server is GREAT.

Starts in 3s …

… which we never have to do anyway…

Page 164: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?OH YES.

Our server is GREAT.

Starts in 3s …

… which we never have to do anyway…

… because it’s fully dynamic

Page 165: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Is it worth it?OH YES.

Our server is GREAT.

Starts in 3s …

… which we never have to do anyway…

… because it’s fully dynamic

Concise, shareable configuration

Page 166: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Did it all turn out the way we expected?

A funny thing happened while we were developing for developers …

Page 167: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi was designed for …

Page 168: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

OSGi was designed for …

Small embedded system

Page 169: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

… but turned out to be perfect for …

Page 170: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

… but turned out to be perfect for …

Page 171: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Liberty was designed for …

Page 172: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Liberty was designed for …

Developer-scale

Page 173: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

… but turned out to be perfect for…

Page 174: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

… but turned out to be perfect for…

BIG scale

Page 175: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

BlueMix server farm

… but turned out to be perfect for…

BIG scale

Page 176: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

BlueMix server farm

… but turned out to be perfect for…

BIG scale

Lots of Liberty instances

Page 177: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Thank you!

Questions?

@holly_cummins www.wasdev.net

Page 178: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Thank you!

Questions?

Oh, and I have a book!

@holly_cummins www.wasdev.net

Page 179: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Backup

Page 180: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

</cleanSlate>Of course, we didn’t really get a clean

slate.Application compatibility had to be

preserved. !

Page 181: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Configuration Admin We rolled our own (sorry)

Parse and merge user configuration and bundle-provided defaults

Resolve variables

Provide configuration to consumers as required by the spec (mostly)

Page 182: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

unique, final, variable, etc.

Metatype Equinox impl + extensions

http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_extensions_osgi_metatype.html

human readable: 1h30m converted to unit of used by developer tools to

help prompt for the right kind of path: file vs. url

Page 183: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

unique, final, variable, etc.

Metatype Equinox impl + extensions

http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_extensions_osgi_metatype.html

type=“String”ibm:type=“password”

The value is a “SerializedProtectedString”,

which is not a String.

Page 184: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Uniform validation of user input

Define configuration and constraints in one place, it gets used everywhere else.

We favor metatype.xml for this reason

Custom namespace for additional types and validators

ibm:type — duration, location, password

pid/reference

unique, final, variable, etc.

Metatype Equinox impl + extensions

http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_extensions_osgi_metatype.html

This is some crazy stuff.

ibm:type=“pid” ibm:reference=“specific.service.pid”

Allows nested configuration elements

to define service relationships

Page 185: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

IsolationWe mean this in a good way.

Liberty runtime serves two masters:

Typical Application Server paradigm(apps strictly separated from runtime) — API

Platform extender paradigm(the “app” is the runtime) — SPI

Persistent problem:how to allow apps or extensions to use their own versions of libraries that don't conflict with the runtime!?

Page 186: Making everything better with OSGi - a happy case study in building a really nice runtime - H Cummins

©2014 IBM Corporation

Private-package declarations pull in redundant classes

Split packages never end well