13

I have been trying to understand a bit more about the wider picture of OSGi without reading thru the entire specification. As with so many things, the introduction to what OSGi actually is was probably written by someone who had been working on it for a decade and perhaps wasn't best placed to put themselves in the mindset of someone who knows nothing about it :-)

Looking at Felix's example DictionaryService, I don't really understand what is going on. Is OSGi a distinct instance of a JVM into which you load bundles which can then find each other?

Obviously it is not just this because other answers on StackOverflow are explicit that OSGi can solve the dependency problem of a distributed system containing modules deployed within distinct JVMs (plus the FAQ keeps talking about networks).

In this latter case, how does a component running in one JVM interact with another component in a separate JVM? Can the two components "use" each other as if they were running within the same JVM (i.e. via local method calls), and how does OSGi manage the marshalling of data across a network (do you have to use Serializable for example)?

Or does the component author have to use some other distinct mechanism (either provided by OSGi or written themselves) for communication between remote components?

Any help much appreciated!

oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449

9 Answers9

6

Yes, OSGi only deals with bundles and services running on the same VM. However, one should note that it is a distinct feature of OSGi that it facilitates running multiple applications (in a controlled way and sharing common modules) on the same JVM at all.

When it comes to accessing services outside the clients JVM, there is currently no standardized solution. Paremus Infiniflow and the derived open-source project Newton use an SCA approach. The upcoming 4.2 release of the OSGi specs will address one side of the problem, namely how to use generic distribution software in such a way that it can bring remote services into the client's JVM.

As somebody mentioned R-OSGi, this approach also deals with the other side of the problem, being how to manage dependencies between distributed OSGi frameworks. Since R-OSGi is not generic distribution software but explicitly deals with the lifecycle issues and dependency management of OSGi bundles.

reinierpost
  • 8,425
  • 1
  • 38
  • 70
  • >> OSGi only deals with bundles and services running on the same VM << does it means that it runs like a Monolithic application running in VM ? If this one VM goes down, the entire application goes down ? – yathirigan Aug 04 '16 at 08:12
  • 1
    And how about **scalability**, if `OSGi only deals with bundles and services running on the same VM`? Btw, how is distributed OSGi going on right now? – Wuaner Aug 31 '16 at 08:53
4

As far as I know, OSGi does not solve this problem out of the box. There are OSGi-bundles, for example Remote OSGi, which allow the programmer to distribute services across a network.

Stefan Schmidt
  • 1,152
  • 11
  • 18
3

Not yet, i think it's being worked on for the next release.

But some companies have already implemented distributed osgi. One i'm aware of is Paremus' Infiniflow (http://www.paremus.com/products/products.html). At linkedin they are also working on this. More info here: Building Linkedin next gen architecture with osgi and here: Matt raible: building linkedin next gen architecture

Here's a summary of the changes for OSGI 4.2: Some thoughts on the OSGi R4.2 draft, There's a section on RFC-119 dealing with distributed OSGi.

Andrej
  • 606
  • 6
  • 12
2

AFAIK, bundles are running in the same JVM, but are not loaded using the same class loader (that why you can use two different versions of the same bundle at the same time).

To interact with components in another JVM, you must use a network protocol such as rmi.

Patriarch24
  • 281
  • 1
  • 4
  • 7
2

The OSGi alliance is working on a standard for distributed OSGi:

http://www.osgi.org/download/osgi-4.2-early-draft2.pdf


There even is an early Apache implementation of this new standard:

http://cxf.apache.org/distributed-osgi.html

paweloque
  • 18,466
  • 26
  • 80
  • 136
1

@Patriarch24

The accepted answer to this question would seem to indicate otherwise (unless I'm misreading it). Also, taken from the FAQ:

The OSGi Service Platform provides the functions to change the composition dynamically on the device of a variety of networks, without requiring a restart

(Emphasis my own). Although in the same FAQ it describes OSGi as in-VM.

Why am I so confused about this? Why is such a basic question about a decade-old technology not clear?

Community
  • 1
  • 1
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
  • 1
    I'd say that is a very confusing, even misleading, answer. OSGi at its core does not deal with distributed systems, just with keeping modules separate and reloadable inside a single VM. – Thilo Jan 08 '09 at 00:50
1

The original problem of OSGI was more related to distribution of code (and then configuration of bundle) than to distribution of execution.

People looking at distributed components are rather looking towards SCA

1

The "introduction" link is not really an intro, it is a FAQ entry. For more information, see http://www.osgi.org/About/WhatIsOSGi Not hard to find I would think.

Anyway, OSGi is an in-VM SOA. That is, the OSGi Framework is about what happens inside the VM, it provides a framework for structuring your application inside the VM so you can built it too a large extent from components. So the core has nothing to do with distribution, it is completely oblivious of who implements the services, it just provides a mechanism for modules to meet each other in a loosely coupled way.

That said, the µService model reifies the joints between the modules and it turns out that you can build support on top of the framework that provides distribution to the other components. In the last releases we specified some mechanisms that make this standardized in the core and provide a special service Remote Service Admin that can manage a distributed topology.

Peter Kriens
  • 15,196
  • 1
  • 37
  • 55
0

If you are looking for a distributed OSGi centric Cloud runtime - then the Paremus Service Fabric ( https://docs.paremus.com/display/SF16/Introduction ) provides these capabilities.

One or more Systems each consisting of a number of OSGi assemblies (Blueprint or Declarative Services) can be dynamically deployed and maintained across a population of OSGi runtime Frameworks (Knopflerfish, Felix or Equinox).

A light weight RSA remote framework is provided which provides Service discovery by default using DDS (a seriously good middleware messaging technology) - (thought ZooKeeper and other approach can be used). Currently supported re-moting protocols include RMI and Avro.

Regards

Richard

Richard
  • 119
  • 2