p2, modular provisioning for OSGi


Published on

In its 3.4 release, Eclipse introduced a new installation / update mechanism called p2. Beyond its Eclipse specific appearance, p2 is a modular provisioning platform for OSGi based systems (currently focused on Equinox) addressing the wide spectrum of provisioning needs from small devices to servers through desktops. In this talk, p2 key concepts and architecture will be introduced, and p2's flexibility will also be demonstrated. As importantly as the actual technology, this talk will also discuss how p2 and the various tools help throughout the software lifecycle from development to serviceability.

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • JEFF
  • JEFF
  • p2, modular provisioning for OSGi

    1. 1. p2, modular provisioning for OSGi Pascal Rapicault IBM Rational TM , p2 lead
    2. 2. <ul><li>OSGi proves the power of componentization </li></ul><ul><li>Componentization naturally spreads </li></ul><ul><li>More components -> more management </li></ul><ul><li>Management is hard </li></ul><ul><li>It’s all about the Contract </li></ul><ul><ul><li>Defining </li></ul></ul><ul><ul><li>Instantiating </li></ul></ul><ul><ul><li>Executing </li></ul></ul><ul><ul><li>Maintaining </li></ul></ul>OSGi is good for you!
    3. 3. How does p2 help? <ul><li>Manages the contract </li></ul><ul><ul><li>Dependencies </li></ul></ul><ul><ul><li>Code </li></ul></ul><ul><ul><li>Settings (VM args, start level, etc) </li></ul></ul><ul><ul><li>Integrations </li></ul></ul><ul><ul><li>Non-OSGi parts (e.g. native launcher) </li></ul></ul><ul><li>Extensible </li></ul><ul><li>GUI and Headless </li></ul><ul><li>One consistent model from installation to servicing </li></ul>
    4. 4. <ul><li>A provisioning solution for OSGi™ systems </li></ul><ul><ul><li>Managing non-running instance (only on Equinox for now) </li></ul></ul><ul><ul><li>Start level, framework extension </li></ul></ul><ul><ul><li>Fine-grained dependency management </li></ul></ul><ul><li>An extensible provisioning platform </li></ul>p2 is about installing!
    5. 5. <ul><li>Concepts </li></ul><ul><li>Architecture </li></ul><ul><li>Tooling </li></ul>
    6. 6. One construct to rule them all Decouple decision making from the actual content Everything is an IU Everything is installable It is also referred to as “metadata” IU (id, ver)
    7. 7. Anatomy of an IU Provided Capabilities Required Capabilities Properties Artifact reference Actions IU (id, ver)
    8. 8. Anatomy of an IU, requirements / capabilities <ul><li>Capabilities and requirements are the mechanism by which an IU express what it provides and what needs. </li></ul><ul><li>A capability is composed of a: </li></ul><ul><ul><li>Namespace (string), name (string) and version </li></ul></ul><ul><li>A requirement is composed of a: </li></ul><ul><ul><li>Namespace, name and version range </li></ul></ul><ul><li>Namespace, name and version are open ended. </li></ul><ul><li>The requirements and capabilities expressed by IUs can be arbitrary and don’t have to all be in the same namespace. </li></ul><ul><ul><li>Resources – RPMs, .exes, docs, … </li></ul></ul><ul><ul><li>Virtual – if you can define a capability, I can depend on it </li></ul></ul>
    9. 9. Separation of concerns <ul><li>Installable Unit </li></ul><ul><ul><li>Exists independently of the repository </li></ul></ul><ul><li>Metadata Repository </li></ul><ul><ul><li>Store only Installable Units. </li></ul></ul><ul><ul><li>API, no specified serialization format </li></ul></ul><ul><li>Artifact Repository </li></ul><ul><ul><li>Store only Artifacts </li></ul></ul><ul><ul><li>API, no specified serialization or layout format </li></ul></ul>Metadata Artifacts
    10. 10. Artifacts <ul><li>Bytes/content to be installed </li></ul><ul><li>Any form </li></ul><ul><ul><li>JARs (e.g., bundles, features, …)‏ </li></ul></ul><ul><ul><li>Binary executables </li></ul></ul><ul><ul><li>RPM, MSI, … </li></ul></ul><ul><li>Defined, maintained, loaded and used separately from the metadata </li></ul>
    11. 11. <ul><li>Concepts </li></ul><ul><li>Architecture </li></ul><ul><li>Tooling </li></ul>
    12. 12. p2 Architecture Metadata Artifacts Runtimes Profiles OS Eclipse Engine Eclipse Classic Eclipse for C++ Other Director Repositories Touchpoints
    13. 13. Terminology <ul><li>p2 / Agent </li></ul><ul><ul><li>The provisioning infrastructure on client machines </li></ul></ul><ul><li>Installable Unit (IU) </li></ul><ul><ul><li>Metadata that describes things that can be installed/configured </li></ul></ul><ul><li>Artifact </li></ul><ul><ul><li>The actual content being installed/configured(e.g., bundle JARs) </li></ul></ul><ul><li>Repository </li></ul><ul><ul><li>A store of metadata or artifacts </li></ul></ul><ul><li>Profile </li></ul><ul><ul><li>The target of install/management operations </li></ul></ul><ul><li>Planner </li></ul><ul><ul><li>The decision-making entity in the provisioning system </li></ul></ul><ul><li>Engine </li></ul><ul><ul><li>The mechanism for executing provisioning requests </li></ul></ul><ul><li>Touchpoint </li></ul><ul><ul><li>The part of the engine responsible for integrating the provisioning system to a particular runtime or management system </li></ul></ul>
    14. 14. p2 in Action – internal management - milli Transports Http/Https File system Volume Director Profiles Runtimes Provisioning operation requested Metadata fetched and constraints analyzed IU install, uninstall, update operations Artifact availability and mirroring Mirroring Data transfer IUs configured into runtimes Profile updated Repositories p2 Update Site Engine OSGi Native/OS
    15. 15. External management - nano Managed application Agent Director OSGi fwk The agent writes out file to control the application. The “provisioning” presence in the managed application is small. Engine OSGi Native/OS Repositories p2 Update Site Transports Http/Https File system Volume
    16. 16. External management - micro Director OSGi fwk The decision making on what to install is done on the agent and communicated to the managed application (no remoting provided in the open source). The agent could also carry a copy of the profile registry. Demo - http://eclipsesource.com/blogs/2009/05/05/remote-provisioning-with-p2 / Managed application Agent Engine OSGi Native/OS Repositories p2 Update Site Transports Http/Https File system Volume Repositories p2 Update Site
    17. 17. <ul><li>Concepts </li></ul><ul><li>Architecture </li></ul><ul><li>Tooling </li></ul>
    18. 18. Build, when the metadata comes to be <ul><li>Metadata matters </li></ul><ul><li>The p2.publisher is responsible for metadata / artifact generation </li></ul><ul><ul><li>Produces p2 metadata from bundles, Eclipse features and products </li></ul></ul><ul><ul><li>Can be used in any build system </li></ul></ul><ul><ul><ul><li>PDE Build is the richest (from source to repo) </li></ul></ul></ul><ul><ul><ul><li>Maven / tycho integration </li></ul></ul></ul><ul><li>Not all metadata can be inferred </li></ul><ul><ul><li>Actions to be executed on a given phase </li></ul></ul><ul><ul><li>Some tweaking is necessary </li></ul></ul><ul><ul><li>Author metadata advice </li></ul></ul>
    19. 19. Repository management <ul><li>Everybody creates repos, they need to be managed </li></ul><ul><li>Problems </li></ul><ul><ul><li>You want to promote one build over another one </li></ul></ul><ul><ul><ul><li>Composite repositories </li></ul></ul></ul><ul><ul><li>You build more than you want to make available </li></ul></ul><ul><ul><ul><li>Slicing </li></ul></ul></ul><ul><ul><li>You want to replicate builds from one repository to another </li></ul></ul><ul><ul><ul><li>Mirroring applications </li></ul></ul></ul><ul><li>Repository validation </li></ul><ul><ul><li>Repository validation that everything is installable </li></ul></ul><ul><ul><li>For every IU, each artifact is available </li></ul></ul><ul><ul><li>IU comparison tools, to ensure that the metadata is not changed </li></ul></ul><ul><ul><li>Artifact comparison tool to ensure that one artifact has not changed [1] </li></ul></ul><ul><ul><li>Repository diff’ing tool </li></ul></ul>[1] - Talk on versioning and provisioning - http://www.eclipsecon.org/2009/sessions?id=585
    20. 20. What is p2? <ul><li>A provisioning solution for OSGi™ systems </li></ul><ul><li>An extensible provisioning platform </li></ul><ul><li>A complete offering from Build time to Runtime </li></ul><ul><li>A community and an ecosystem </li></ul>
    21. 21. References <ul><li>p2 landing page http://wiki.eclipse.org/Equinox_p2 </li></ul><ul><li>All p2 articles http://wiki.eclipse.org/Category:Equinox_p2 </li></ul><ul><li>Getting the code http://wiki.eclipse.org/Equinox_p2_Getting_Started_for_Developers </li></ul><ul><li>Contacting us </li></ul><ul><ul><li>Equinox newsgroup </li></ul></ul><ul><ul><li>Mailing list: p2-dev@eclipse.org </li></ul></ul>
    22. 22. <ul><li>Appendix </li></ul>
    23. 23. Profile <ul><li>A profile is the complete description in terms of IU of what is installed </li></ul><ul><li>A profile contains </li></ul><ul><ul><li>Properties defining the “environment” such as os, ws, arch, install location, bundle pool location </li></ul></ul><ul><ul><li>The list of IUs </li></ul></ul><ul><ul><li>Properties associated with IUs </li></ul></ul><ul><li>Class: Org.eclipse.equinox.internal.provisional.p2.engine.IProfile </li></ul>
    24. 24. Planning a profile change <ul><ul><li>Because of inter IU dependencies, </li></ul></ul><ul><ul><li>modification against a profile should be planned </li></ul></ul><ul><li>ProfileChangeRequest </li></ul><ul><ul><li>Capture the changes you want to make to the profile (e.g. Install, Uninstall). </li></ul></ul><ul><ul><li>The request is processed by the Planner </li></ul></ul><ul><ul><li>An update is a removal and an addition </li></ul></ul><ul><li>Planner </li></ul><ul><ul><li>The entity responsible for the evaluation of the change request, computing the transitive closure and checking the dependencies </li></ul></ul><ul><ul><li>If a solution exists it will find it </li></ul></ul><ul><li>ProvisioningPlan </li></ul><ul><ul><li>The planner returns a provisioning plan. The planning succeed pass or fail. Upon failure explanations are provided. Upon success the plan returns a set of operands to go from the initial state of the profile to the desired state. </li></ul></ul>
    25. 25. Engine <ul><ul><li>The mechanism by which the profile is actually changed </li></ul></ul><ul><li>The engine ensures consistency of the modification by performing a “transaction”. </li></ul><ul><li>Runs over a set of operands (usually resulting from a planning operation) and executes a given set of phases on them. No profile consistency validation is done </li></ul><ul><ul><li>Engine.perform(Operand[] ops, PhaseSet phases, IProgressMonitor pm) </li></ul></ul><ul><li>For each phase, the engine interprets from the touchpoint data of the IU, the action specific to the phase. The engine looks up the action to execute. </li></ul><ul><li>Currently 8 phases are defined, and the typical set of phases (and their order) is defined in DefaultPhaseSet . The design allows for new phases could be added. </li></ul><ul><li>The engine emit events on the IProvisoningEventBus to describe what is happening. Events on the bus are post events and can not be vetoed. </li></ul>
    26. 26. Installable Unit Fragments <ul><li>An installable unit fragment is an entity that attaches to an installable unit. </li></ul><ul><li>Much like OSGi fragments, IU fragments are used to complement an existing installable unit and appear as one with the IU they attached to. </li></ul><ul><li>They are typically used to deliver action to an installable unit (e.g. start level) because IUs should stay as context agnostic as possible </li></ul><ul><li>IU fragments can be attached to several IU at the same time. See for example the tooling.osgi.bundle.default IU that applies to all bundles. </li></ul><ul><li>Note that IU fragments are not how OSGi fragments are delivered. OSGi fragments are delivered as regular IU with requirements on their host. </li></ul>
    27. 27. Installable Unit Patches <ul><li>An installable unit patch has the ability to “modify” the requirements of any other installable unit. </li></ul><ul><li>Deal with three concerns: </li></ul><ul><ul><li>The IUs to which the patch apply </li></ul></ul><ul><ul><li>The lifecycle of patch </li></ul></ul><ul><ul><li>The changes applied </li></ul></ul>Note: In 3.5 the feature patch editor only exposes some of those capabilities .