+ All Categories
Home > Documents > Apache Karaf in Real Life_1

Apache Karaf in Real Life_1

Date post: 02-Jun-2018
Category:
Upload: aftabget2
View: 229 times
Download: 0 times
Share this document with a friend

of 51

Transcript
  • 8/10/2019 Apache Karaf in Real Life_1

    1/51

    Apache Karaf in real lifeApacheCon NA !"#$

  • 8/10/2019 Apache Karaf in Real Life_1

    2/51

  • 8/10/2019 Apache Karaf in Real Life_1

    3/51

    Agenda

    Very short history of Karaf

    Karaf basis

    A bit deeper dive into OSGi

    Modularity vs Extensibility

    DIY &Karaf based solutionWhat we have learned

    New and noteworthly in Karaf '("

  • 8/10/2019 Apache Karaf in Real Life_1

    4/51

    About me

    Im Pole

    Husband

    Open source commiter & consultant

    Traveller((and Construction worker :)

  • 8/10/2019 Apache Karaf in Real Life_1

    5/51

    Very short history of

    Apache Karaf

  • 8/10/2019 Apache Karaf in Real Life_1

    6/51

    Karaf the beginning

    Born as ServiceMix $platform kernel in !"")

    Moved to Apache Felix community in !""*

    Top level project since June !"#"

  • 8/10/2019 Apache Karaf in Real Life_1

    7/51

    Karaf versions

    #(x &legacy

    !(#&outdated

    !(!(x &Based on OSGi $(!

    !('(x&Based on OSGi

    $('

    '("&Based on OSGi +("

  • 8/10/2019 Apache Karaf in Real Life_1

    8/51

    Karaf versions cont(

    !($(x &might support OSGi +("frameworks and

    features

    '(#&future release for things delaying '("

    release

  • 8/10/2019 Apache Karaf in Real Life_1

    9/51

    Karaf basis

  • 8/10/2019 Apache Karaf in Real Life_1

    10/51

    What you already saw in

    most of presentations

    Source: http://felix(apache(org/

  • 8/10/2019 Apache Karaf in Real Life_1

    11/51

    What was told to you

    Source: http://denise&theonepersonproject(blogspot(com/

  • 8/10/2019 Apache Karaf in Real Life_1

    12/51

    Thats what you can do

    Source: http://freefoto(com/

  • 8/10/2019 Apache Karaf in Real Life_1

    13/51

    Karaf grown to be a

    platform foundation

    Might run multiple applications at same time

    Each app may use di,erent technologies

    Keeps things separate

    Has support for full product life cycle

    Failover & load balancing features

    Powerful infrastructure for extensions

  • 8/10/2019 Apache Karaf in Real Life_1

    14/51

    Bit deeper dive into

    OSGi

  • 8/10/2019 Apache Karaf in Real Life_1

    15/51

    OSGi

    Source: http://osgi(org/

  • 8/10/2019 Apache Karaf in Real Life_1

    16/51

    In many cases

    OSGi is shown as worthless technology forcing

    you to have extra entries in manifest

    OSGi brings more problems than solutions

    Many libraries deny to support it because small

    user base

  • 8/10/2019 Apache Karaf in Real Life_1

    17/51

    OSGi popularity by

    Maven Central

    Maven central is $!-k JARs.assigned to $-k

    projects

    Just #"/of projects provides valid OSGi

    bundles

    OSGi core jar is at '-th position in download

    statistics

    !$k projects has transient OSGi dependencies

    Source: http://blog(osgi(org/ analysis done by Peter Kriens

  • 8/10/2019 Apache Karaf in Real Life_1

    18/51

  • 8/10/2019 Apache Karaf in Real Life_1

    19/51

    OSGi services

    are main source

    of dynamism in system

  • 8/10/2019 Apache Karaf in Real Life_1

    20/51

    OSGi related design

    patterns

    Whiteboard

    Extender

  • 8/10/2019 Apache Karaf in Real Life_1

    21/51

    Modularity

    vsExtensibility

  • 8/10/2019 Apache Karaf in Real Life_1

    22/51

    Modular so0ware

    Provides clear API and SPI contract

    Small set of dependencies

    Fine grained dependencies

    Lack of implementation specific depdenencies

  • 8/10/2019 Apache Karaf in Real Life_1

    23/51

    Extensible so0ware

    Provides plug in capabilities

    Does not lock extension to have its own

    extensions

    Extension registration should be as less verbose

    as possible

  • 8/10/2019 Apache Karaf in Real Life_1

    24/51

    You cant build extensible

    solutions without making

    them modular first

    (C) Lukasz Dywicki

  • 8/10/2019 Apache Karaf in Real Life_1

    25/51

    Your solution might be

    modular but not

    extensible at all

    (C) Lukasz Dywicki

  • 8/10/2019 Apache Karaf in Real Life_1

    26/51

    Your so0ware can bemodular and extensible

    and still not run under

    OSGi

    (C) Lukasz Dywicki

  • 8/10/2019 Apache Karaf in Real Life_1

    27/51

    Karaf based solution

    ld l

  • 8/10/2019 Apache Karaf in Real Life_1

    28/51

    Building solution on top

    of Karaf

    Make it OSGi friendly

    Make use of services

    Decide to use helpers like blueprint/spring/

    declarative services

    Extend Karaf to support your domain

    Brand it.assemble as new product

    Ship it to customer

    ki hi O i

  • 8/10/2019 Apache Karaf in Real Life_1

    29/51

    Making things OSGi

    friendly

    For maven users &use maven&bundle&plugin

    Take care about OSGification of your dependenc

    Push changes back to origin project if you can

    If fail &then wrap it

    If you do &then share results with community

    Keep naming convention strict & clear

  • 8/10/2019 Apache Karaf in Real Life_1

    30/51

    Maven users

    org.apache.felix

    maven-bundle-plugin

  • 8/10/2019 Apache Karaf in Real Life_1

    31/51

    Dependency OSGification

    Quite simple if dependency uses Maven

    Best thing you can do is giving OSGi support bac

    to project

    Exporting wrapped packages is bad practiceIf you wrap &then make separate bundle

    Submit patch for ServiceMix bundles gain karma

  • 8/10/2019 Apache Karaf in Real Life_1

    32/51

    Extending Karaf

    Adopt default configuration to use own

    authentication source (or write new)

    Group your bundles into Karaf features

    Provide new set of commands supporting your

    product

  • 8/10/2019 Apache Karaf in Real Life_1

    33/51

    K f f

  • 8/10/2019 Apache Karaf in Real Life_1

    34/51

    Karaf features

    Simple descriptor with information which bundlfrom where should be installed

    Supports multiple protocols

    File

    HTTP / FTP etcmvn (pax&url&mvn)

    Supports transient dependencies.version ranges

    and custom resolvers

    K f f t t

  • 8/10/2019 Apache Karaf in Real Life_1

    35/51

    Karaf features cont(

    mvn:groupId/artifactId/version/xml/features

  • 8/10/2019 Apache Karaf in Real Life_1

    36/51

    Karaf features cont(

    Install it:

    features:addurl mvn:groupId/artifactId/!("/xm

    features

    features:install my&solution

    Add to default configuration

    etc/org(apache(karaf(features(cfg

    featuresRepositories 12url

    featuresBoot 12my&solution

  • 8/10/2019 Apache Karaf in Real Life_1

    37/51

    Implementing commands

    packageorg.apachecon.na;

    importorg.apache.felix.gogo.commands.Command;

    importorg.apache.karaf.shell.console.OsgiCommandSupport

    @Command(scope="example",name="do")

    publicclassSimpleCommand extendsOsgiCommandSupport {

    @Override

    protectedObject doExecute()throwsException {

    System.out.println("Something ...");

    returnnull;

    }

    }

  • 8/10/2019 Apache Karaf in Real Life_1

    38/51

    Dont forget about few additional things:

    blueprint descriptor

    transient dependencies

    org(apache(felix(service(command

    org(apache(felix(gogo(commands

    org(apache(karaf(shell(console

    Implementing commands

  • 8/10/2019 Apache Karaf in Real Life_1

    39/51

    Brand itcreate file branding(properties in org(apache(karaf(branding packa

    Package as OSGi bundle and copy to lib/ directory

  • 8/10/2019 Apache Karaf in Real Life_1

    40/51

    ((and assembleUse features&maven&plugin

    add&features&to&repo goalMost important configuration

    descriptors

    features

    repository 23output directory

  • 8/10/2019 Apache Karaf in Real Life_1

    41/51

  • 8/10/2019 Apache Karaf in Real Life_1

    42/51

    What we have learned*

    * These things might be obvi

  • 8/10/2019 Apache Karaf in Real Life_1

    43/51

    Getting runtime metrics

    from couple Apache

    projects is hard

  • 8/10/2019 Apache Karaf in Real Life_1

    44/51

    Common problems

    Developers not familiar with OSGi((

    (NET developers using Java in first project((

    Dependency upgrades

    Feature version ranges are hard to use

    By default shutdown timeout for Java Service

    Wrapper is just '"seconds

    VM queues are danger when processing is very

    slow (OOME)

  • 8/10/2019 Apache Karaf in Real Life_1

    45/51

    Common problems cont(

    Pre&defined assemlies are big

    Integration testing is slow

    Visual tools produces nice but useless artifacts

    Generated code

    Problematic testing

    Handling of KAR files

    Karaf feature URLs management

  • 8/10/2019 Apache Karaf in Real Life_1

    46/51

    Good things goes last

  • 8/10/2019 Apache Karaf in Real Life_1

    47/51

    Good things goes last

    Camel scales up very well

    ActiveMQ is good for having load balancing

    VM endpoints are damn fast

    Cassandra is damn fast too!

    Increase load by '""/just by enabling

    aggregation & batch processing

    Few patterns which

  • 8/10/2019 Apache Karaf in Real Life_1

    48/51

    Few patterns which

    works pretty wellActiveMQ queue as central entry point

    Content based routing to glue components

    Very easy to track incoming load and spikes

    Messages are published via service call

    Separate destinations for OSGi servicesUses Service Tracker to dynamically create

    camel routes

    VM endpoints everywhere.JMS where

    bottlenecks can occur

  • 8/10/2019 Apache Karaf in Real Life_1

    49/51

    New and noteworthly

    in Karaf'("

  • 8/10/2019 Apache Karaf in Real Life_1

    50/51

    Q&A

  • 8/10/2019 Apache Karaf in Real Life_1

    51/51

    Stay in touchTwitter & skype: ldywicki

    luke@code&house(org

    https://github(com/splatch/apacheco

    https://github.com/splatch/apacheconmailto:[email protected]

Recommended