You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by jkraushaar <jo...@doubleslash.de> on 2015/04/27 17:00:39 UTC

Karaf 3.0.1 does not consider service ranking set by Blueprint

Hi there,

we are using Karaf 3.0.1. I want to deploy two bundles providing the same
service with different service rankings. The rankings are set using
Blueprint.

I have the following scenario:

Bundle X uses the service defined by API Bundle A.
Bundle A1 implements A and has a service ranking of 1.
Bundle A2 implements A and has a service ranking of 10.

I'm installing bundle X and then bundle A1. X now uses A1. Then I install
A2. Bundle X still uses A1. I restart Karaf, but X still uses A1.

So I tried installing bundle X and then bundle A2. X now uses A2. Then I
install A1. Bundle X still uses A2. I restart Karaf, but X still uses A2.

It seems that the service ranking is not taken into account. Using the Karaf
command services -p shows me, that it is set.

Is it a failure of Karaf or doing I'm something wrong?

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by jkraushaar <jo...@doubleslash.de>.
Hi Achim,

I checked the release notes of Karaf. According to them, Aries Blueprint was
updated in 3.0.3 to 1.4.2. I would really like to update to this version.
Unfortunately some of our legacy libraries are incompatible with the updates
of the JPA libraries in 3.0.3. :-(

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991p4040042.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

did you think about upgrading to a newer release of Karaf, cause I think
this issue might have been fixed with a newer version of Aries.

regards, Achim

2015-04-28 16:13 GMT+02:00 jkraushaar <jo...@doubleslash.de>:

> Seems to be an issue of the Aries Blueprint implementation. To me it seems
> that the reference to the service (A1 or A2) is set when the component (X)
> is created. It only takes those services into account which exist at that
> moment. If later on another service with a higher ranking is added, the
> reference is not updated.
>
> As a workaround I've created a class which is a service reference listener.
> When a service is added, the service, ranking and ID is wrapped in an
> object
> and put into a TreeMap. The wrapper object implements compare to ensure the
> correct ordering of the services. With this workaround it is possible to
> add
> and remove new services with different rankings at runtime.
>
> Regards
> Jochen
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991p4040038.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by Guillaume Nodet <gn...@apache.org>.
I can read the following in the osgi spec, section 121.7.11

The backing service for a reference proxy must not be gotten from the
OSGi service registry until an actual service object is needed, that
is, when an actual method is called on the proxy. If the backing
service becomes unregistered, then the proxy must unget the reference
to the backing service (if it had gotten it) and get another service
object the next time a method on the proxy is called. If a replacement
can be found immediately, the reference listener’s bind method must be
called without calling the unbind method. Other threads that need the
same service object must block until the ser- vice object has become
available or times out.

I could not find anything more in the spec.

Anyway, I just find some meeting notes from the OSGi EEG meeting about this
exact situation.  The outcome was that there would be no rebinding in case
of a higher ranking service coming.

I suspect is it is changed, the TCK will fail to pass.



2015-04-28 17:24 GMT+02:00 Christian Schneider <ch...@die-schneider.net>:

> What I wanted to express is that users naively will expect that blueprint
> will select the service with the highest ranking. Of course when reading
> the spec they will probably guess that service damping might influence this.
>
> Do you know if we are free to change the current behaviour or if the spec
> mandates to stay with a service that was selected once?
>
> Christian
>
>
> On 28.04.2015 16:56, David Jencks wrote:
>
>> It may not be what you expect, but thinking it is what no one expects
>> seems a bit extreme to me.  DS has the concept of greedy and reluctant
>> references so you can specify which behavior you want.
>>
>> david jencks
>>
>>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>

Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by Christian Schneider <ch...@die-schneider.net>.
What I wanted to express is that users naively will expect that 
blueprint will select the service with the highest ranking. Of course 
when reading the spec they will probably guess that service damping 
might influence this.

Do you know if we are free to change the current behaviour or if the 
spec mandates to stay with a service that was selected once?

Christian


On 28.04.2015 16:56, David Jencks wrote:
> It may not be what you expect, but thinking it is what no one expects seems a bit extreme to me.  DS has the concept of greedy and reluctant references so you can specify which behavior you want.
>
> david jencks
>

-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by David Jencks <da...@yahoo.com>.
It may not be what you expect, but thinking it is what no one expects seems a bit extreme to me.  DS has the concept of greedy and reluctant references so you can specify which behavior you want.

david jencks

On Apr 28, 2015, at 10:26 AM, Christian Schneider <ch...@die-schneider.net> wrote:

> Blueprint will stay with the service it selected until this service goes away. So for example if you would stop A1 and start it again then blueprint would switch.
> This is obviously not what people expect when the ranking is used. So I would consider this to be either a bug or a good enhancement request.
> Can you open an issue at aries if there is none already? I can work on it.
> 
> Christian
> 
> On 28.04.2015 16:13, jkraushaar wrote:
>> Seems to be an issue of the Aries Blueprint implementation. To me it seems
>> that the reference to the service (A1 or A2) is set when the component (X)
>> is created. It only takes those services into account which exist at that
>> moment. If later on another service with a higher ranking is added, the
>> reference is not updated.
>> 
>> As a workaround I've created a class which is a service reference listener.
>> When a service is added, the service, ranking and ID is wrapped in an object
>> and put into a TreeMap. The wrapper object implements compare to ensure the
>> correct ordering of the services. With this workaround it is possible to add
>> and remove new services with different rankings at runtime.
>> 
>> Regards
>> Jochen
>> 
>> 
>> 
>> --
>> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991p4040038.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
> 
> 
> -- 
> Christian Schneider
> http://www.liquid-reality.de
> 
> Open Source Architect
> http://www.talend.com
> 


Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by jkraushaar <jo...@doubleslash.de>.
Hi Christian,

I opened an issue, thanks for your help:
https://issues.apache.org/jira/browse/ARIES-1314

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991p4040043.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by Christian Schneider <ch...@die-schneider.net>.
Blueprint will stay with the service it selected until this service goes 
away. So for example if you would stop A1 and start it again then 
blueprint would switch.
This is obviously not what people expect when the ranking is used. So I 
would consider this to be either a bug or a good enhancement request.
Can you open an issue at aries if there is none already? I can work on it.

Christian

On 28.04.2015 16:13, jkraushaar wrote:
> Seems to be an issue of the Aries Blueprint implementation. To me it seems
> that the reference to the service (A1 or A2) is set when the component (X)
> is created. It only takes those services into account which exist at that
> moment. If later on another service with a higher ranking is added, the
> reference is not updated.
>
> As a workaround I've created a class which is a service reference listener.
> When a service is added, the service, ranking and ID is wrapped in an object
> and put into a TreeMap. The wrapper object implements compare to ensure the
> correct ordering of the services. With this workaround it is possible to add
> and remove new services with different rankings at runtime.
>
> Regards
> Jochen
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991p4040038.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Karaf 3.0.1 does not consider service ranking set by Blueprint

Posted by jkraushaar <jo...@doubleslash.de>.
Seems to be an issue of the Aries Blueprint implementation. To me it seems
that the reference to the service (A1 or A2) is set when the component (X)
is created. It only takes those services into account which exist at that
moment. If later on another service with a higher ranking is added, the
reference is not updated.

As a workaround I've created a class which is a service reference listener.
When a service is added, the service, ranking and ID is wrapped in an object
and put into a TreeMap. The wrapper object implements compare to ensure the
correct ordering of the services. With this workaround it is possible to add
and remove new services with different rankings at runtime.

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-1-does-not-consider-service-ranking-set-by-Blueprint-tp4039991p4040038.html
Sent from the Karaf - User mailing list archive at Nabble.com.