Home » Eclipse Projects » Equinox » DS ignores service.ranking?
|
Re: DS ignores service.ranking? [message #891524 is a reply to message #890734] |
Mon, 25 June 2012 07:17 |
|
Johan,
can you check the definition of the service.ranking property in the
component xml? I remember a similar situation in the past I was
scratching my head on. It turned out that I missed declaring the
property as type "Integer". Thus, it was registered as String which is
the wrong type and thus being ignored as a ranking value.
-Gunnar
--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
|
|
| | |
Re: DS ignores service.ranking? [message #891936 is a reply to message #891598] |
Tue, 26 June 2012 15:57 |
Johan Van Noten Messages: 87 Registered: July 2009 |
Member |
|
|
Hi all,
I tried today with the new Eclipse Juno, hoping that this would behave differently.
Unfortunately, I don't see a better behaviour.
Anybody who can explain the following console session?
The first line is printed by the bindA method of my service B that required an implementation for A.
You see that A2 (ranking 2) gets bound instead of A1 (ranking 3).
I must be missing something, cause DS is used extensively...
[BImpl] Bound to com.acme.a2.A2@eca36e
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.8.0.v20120529-1548
1 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705
2 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515
3 ACTIVE com.acme.a2_1.0.0.qualifier
4 ACTIVE org.eclipse.equinox.ds_1.4.0.v20120522-1841
5 ACTIVE org.apache.felix.gogo.command_0.8.0.v201108120515
6 ACTIVE org.eclipse.osgi.util_3.2.300.v20120522-1822
7 ACTIVE com.acme.a_1.0.0.qualifier
8 ACTIVE org.eclipse.osgi.services_3.3.100.v20120522-1822
9 ACTIVE com.acme.b_1.0.0.qualifier
10 ACTIVE org.eclipse.equinox.util_1.0.400.v20120522-2049
11 ACTIVE com.acme.a1_1.0.0.qualifier
12 ACTIVE org.eclipse.equinox.console_1.0.0.v20120522-1841
osgi> services
{org.osgi.service.packageadmin.PackageAdmin}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.framework.internal.core.PackageAdminImpl, service.vendor=Eclipse.org - Equinox, service.id=2}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.osgi_3.8.0.v20120529-1548 [0]
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.osgi.service.permissionadmin.PermissionAdmin, org.osgi.service.condpermadmin.ConditionalPermissionAdmin}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.internal.permadmin.SecurityAdmin, service.vendor=Eclipse.org - Equinox, service.id=3}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.osgi.service.startlevel.StartLevel}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.framework.internal.core.StartLevelManager, service.vendor=Eclipse.org - Equinox, service.id=4}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.eclipse.osgi.service.debug.DebugOptions}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.framework.debug.FrameworkDebugOptions, service.vendor=Eclipse.org - Equinox, service.id=5}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{java.lang.ClassLoader}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.ContextFinder, service.vendor=Eclipse.org - Equinox, equinox.classloader.type=contextClassLoader, service.id=6}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.framework.log.FrameworkLog}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory, service.vendor=Eclipse.org - Equinox, service.id=9}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
{org.eclipse.osgi.service.environment.EnvironmentInfo}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.EclipseEnvironmentInfo, service.vendor=Eclipse.org - Equinox, service.id=19}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.resolver.PlatformAdmin}={service.ranking=2147483647, service.pid=0.org.eclipse.osgi.internal.baseadaptor.StateManager, service.vendor=Eclipse.org - Equinox, service.id=20}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.eclipse.osgi.service.pluginconversion.PluginConverter}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.PluginConverterImpl, service.vendor=Eclipse.org - Equinox, service.id=21}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.localization.BundleLocalization}={service.ranking=2147483647, service.pid=0.org.eclipse.core.runtime.internal.adaptor.BundleLocalizationImpl, service.vendor=Eclipse.org - Equinox, service.id=22}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.framework.console.CommandProvider}={service.ranking=2147483647, service.id=28}
"Registered by bundle:" org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
"Bundles using service"
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.eclipse.equinox.console.commands.EquinoxCommandProvider}={service.ranking=2147483647, osgi.command.function=[exit,shutdown,sta,start,sto,stop,i,install,up,up,up,update,update,update,un,uninstall,s,status,se,services,p,p,packages,packages,bundles,b,bundle,gc,init,close,r,refresh,exec,fork,h,headers,pr,props,setp,setprop,ss,t,threads,sl,setfwsl,setbsl,setibsl,requiredBundles,classSpaces,profilelog,getPackages,getprop,diag,enableBundle,disableBundle,disabledBundles], osgi.command.scope=equinox, service.id=48}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.eclipse.equinox.console.commands.HelpCommand}={service.ranking=2147483647, osgi.command.function=[help], osgi.command.scope=equinox, service.id=49}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{com.acme.a.A}={service.ranking=3, component.name=com.acme.a1.A1, component.id=2, service.id=44}
"Registered by bundle:" com.acme.a1_1.0.0.qualifier [11]
"No bundles using service."
{com.acme.a.A}={service.ranking=2, component.name=com.acme.a2.A2, component.id=0, service.id=40}
"Registered by bundle:" com.acme.a2_1.0.0.qualifier [3]
"Bundles using service"
com.acme.b_1.0.0.qualifier [9]
{org.osgi.service.log.LogReaderService, org.eclipse.equinox.log.ExtendedLogReaderService}={service.id=7}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.osgi.service.log.LogService, org.eclipse.equinox.log.ExtendedLogService}={service.id=8}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{javax.xml.parsers.SAXParserFactory}={service.id=11}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{javax.xml.parsers.DocumentBuilderFactory}={service.id=12}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.user.area, service.id=13}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.instance.area, service.id=14}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.configuration.area, service.id=15}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=osgi.install.area, service.id=16}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.datalocation.Location}={type=eclipse.home.location, service.id=17}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.urlconversion.URLConverter}={protocol=[bundleentry,bundleresource], service.id=18}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.signedcontent.SignedContentFactory}={service.id=24}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"Bundles using service"
org.eclipse.osgi_3.8.0.v20120529-1548 [0]
{org.eclipse.osgi.internal.provisional.verifier.CertificateVerifierFactory}={service.id=25}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.osgi.service.framework.CompositeBundleFactory}={service.id=26}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.osgi.service.cm.ConfigurationListener}={service.id=27}
"Registered by bundle:" org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
"No bundles using service."
{org.apache.felix.scr.ScrService}={service.id=29}
"Registered by bundle:" org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
"No bundles using service."
{org.apache.felix.service.threadio.ThreadIO}={service.id=30}
"Registered by bundle:" org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
"No bundles using service."
{org.apache.felix.service.command.CommandProcessor}={service.id=31}
"Registered by bundle:" org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
"Bundles using service"
org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
{org.apache.felix.service.command.Converter}={service.id=32}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.apache.felix.gogo.shell.Builtin}={osgi.command.function=[format,getopt,new,set,tac,type], osgi.command.scope=gogo, service.id=33}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Procedural}={osgi.command.function=[each,if,not,throw,try,until,while], osgi.command.scope=gogo, service.id=34}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Posix}={osgi.command.function=[cat,echo,grep], osgi.command.scope=gogo, service.id=35}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Telnet}={osgi.command.function=[telnetd], osgi.command.scope=gogo, service.id=36}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"No bundles using service."
{org.apache.felix.gogo.shell.Shell}={osgi.command.function=[gosh,sh,source], osgi.command.scope=gogo, service.id=37}
"Registered by bundle:" org.apache.felix.gogo.shell_0.8.0.v201110170705 [1]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.eclipse.equinox.internal.util.threadpool.ThreadPoolManager, org.eclipse.equinox.internal.util.threadpool.ThreadPoolFactory}={service.id=38}
"Registered by bundle:" org.eclipse.equinox.util_1.0.400.v20120522-2049 [10]
"Bundles using service"
org.eclipse.equinox.ds_1.4.0.v20120522-1841 [4]
{org.eclipse.equinox.internal.util.timer.Timer}={service.id=39}
"Registered by bundle:" org.eclipse.equinox.util_1.0.400.v20120522-2049 [10]
"No bundles using service."
{org.apache.felix.gogo.command.Basic}={osgi.command.function=[bundlelevel,frameworklevel,headers,help,install,inspect,lb,log,refresh,resolve,start,stop,uninstall,update,which], osgi.command.scope=felix, service.id=41}
"Registered by bundle:" org.apache.felix.gogo.command_0.8.0.v201108120515 [5]
"No bundles using service."
{org.apache.felix.gogo.command.Files}={osgi.command.function=[cd,ls], osgi.command.scope=felix, service.id=42}
"Registered by bundle:" org.apache.felix.gogo.command_0.8.0.v201108120515 [5]
"No bundles using service."
{org.apache.felix.gogo.command.OBR}={osgi.command.function=[deploy,info,javadoc,list,repos,source], osgi.command.scope=obr, service.id=43}
"Registered by bundle:" org.apache.felix.gogo.command_0.8.0.v201108120515 [5]
"No bundles using service."
{java.lang.Object}={osgi.command.function=[comp,component,dis,disAll,disable,disableAll,en,enAll,enable,enableAll,list,ls], osgi.command.scope=equinox, service.id=45}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.eclipse.equinox.console.telnet.TelnetCommand}={osgi.command.function=[telnet], osgi.command.scope=equinox, service.id=46}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.apache.felix.service.command.Converter}={service.id=47}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"Bundles using service"
org.apache.felix.gogo.runtime_0.8.0.v201108120515 [2]
{org.eclipse.equinox.console.commands.ManCommand}={osgi.command.function=[man], osgi.command.scope=equinox, service.id=50}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.eclipse.equinox.console.commands.DisconnectCommand}={osgi.command.function=[disconnect], osgi.command.scope=equinox, service.id=51}
"Registered by bundle:" org.eclipse.equinox.console_1.0.0.v20120522-1841 [12]
"No bundles using service."
{org.eclipse.osgi.service.runnable.StartupMonitor}={service.ranking=-2147483648, service.id=1}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.framework.log.FrameworkLog}={service.ranking=-2147483648, performance=true, service.pid=46org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory$1, service.vendor=Eclipse.org - Equinox, service.id=10}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
{org.eclipse.osgi.service.security.TrustEngine}={service.ranking=-2147483648, osgi.signedcontent.trust.engine=org.eclipse.osgi, service.id=23}
"Registered by bundle:" org.eclipse.osgi_3.8.0.v20120529-1548 [0]
"No bundles using service."
osgi> list -c
All Components:
ID Component details
1 Component[
name = com.acme.a2.A2
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = com.acme.a2.A2
state = Unsatisfied
properties = {service.ranking=2}
serviceFactory = false
serviceInterface = [com.acme.a.A]
references = null
located in bundle = com.acme.a2_1.0.0.qualifier [3]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
objectClass = String[com.acme.a.A]
service.ranking = 2
component.name = com.acme.a2.A2
component.id = 0
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@e8a0cd
2 Component[
name = com.acme.b.BImpl
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = com.acme.b.BImpl
state = Unsatisfied
properties =
serviceFactory = false
serviceInterface = null
references = {
Reference[name = A, interface = com.acme.a.A, policy = static, cardinality = 1..1, target = null, bind = bindA, unbind = unbindA]
}
located in bundle = com.acme.b_1.0.0.qualifier [9]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
component.name = com.acme.b.BImpl
component.id = 1
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@95215b
Bound References:
String[com.acme.a.A]
-> com.acme.a2.A2@eca36e
3 Component[
name = com.acme.a1.A1
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = com.acme.a1.A1
state = Unsatisfied
properties = {service.ranking=3}
serviceFactory = false
serviceInterface = [com.acme.a.A]
references = null
located in bundle = com.acme.a1_1.0.0.qualifier [11]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
objectClass = String[com.acme.a.A]
service.ranking = 3
component.name = com.acme.a1.A1
component.id = 2
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@c10de0
|
|
|
Re: DS ignores service.ranking? [message #892189 is a reply to message #891936] |
Wed, 27 June 2012 11:07 |
|
Am 26.06.2012 17:57, schrieb Johan Van Noten:
> The first line is printed by the bindA method of my service B that required an implementation for A.
> You see that A2 (ranking 2) gets bound instead of A1 (ranking 3).
It may be a result of activation order. I noticed that you use policy
"static" in the dependency with cardinality "1..". I think that in this
case the component is not re-bound to a newer service as long as the old
is still available.
Did you try with a dynamic policy?
-Gunnar
--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
|
|
|
Re: DS ignores service.ranking? [message #892218 is a reply to message #892189] |
Wed, 27 June 2012 12:33 |
Johan Van Noten Messages: 87 Registered: July 2009 |
Member |
|
|
Hi Gunnar,
Once again thanks for your feedback.
Without being an expert on DS, I dare to disagree with you
I agree that mentioning "static" causes my component B not to be re-bound unless the original binding becomes invalid (e.g. service disappeared).
Registering a service with a higher service.ranking afterwards, will not break the previous binding.
To my understanding, the original binding should be respecting the service.ranking, though.
On one and the same start-level, I have two service-candidates with specific service.ranking.
The DS should then make a choice according to the spec and not just chose the first one that accidently is encountered...
To validate this, I tried your suggestion by making the binding in B dynamic.
Unfortunately, this didn't change the behaviour.
Based on my experiments, I'm convinced by now that it is just a very annoying tooling issue.
Maybe someone could try and follow these steps below, see whether you encounter the same:
* Use Eclipse Juno (I use the modeling 32-bit version).
* Start it in an empty workspace.
* Import the projects from my dsTestJuno.zip except for com.acme.A2.
* Now right-click on Runtime/dsTestRun.launch and run it in debugging.
* The first line in the console should state that B is bound to A1 (of course, there is no A2).
* Then also import the A2 project.
* Run again in the same way.
* Using the settings in the archive (A1 and A2 on service.ranking 6 and 5 respectively), A1 should remain the chosen one.
* If it does, try playing a bit with the rankings of A1 and A2 and every time run again.
* I don't see any regularity: sometimes works, sometimes not.
* Restarting Eclipse can suddenly produce another result.
If you would have a clue...
Johan
|
|
| |
Re: DS ignores service.ranking? [message #892289 is a reply to message #892218] |
Wed, 27 June 2012 15:34 |
|
Am 27.06.2012 14:33, schrieb Johan Van Noten:
> Without being an expert on DS, I dare to disagree with you
Well, DS (the implementation as well as the tooling) still surprises me
once in a while... and I haven't memorized the spec. I usually fall back
to a trial and error mode when analyzing DS problems.
> To my understanding, the original binding should be respecting the service.ranking, though.
> On one and the same start-level, I have two service-candidates with specific service.ranking.
> The DS should then make a choice according to the spec and not just chose the first one that accidently is encountered...
So the start-level doesn't say anything about activation order within
the same level. Timing issues are possible. For example, it is possible
that the bundle providing the service with the lower ranking is
activated before the other bundle. The DS implementation listens for
events and might immediately start creating the component when the first
bundle was activated because all dependencies are satisfied. The DS
implementation can't predict the future and doesn't know anything about
bundles with services yet to be activated.
Here is another thing you can try. Instead of activating all bundles and
components right away you could use lazy activation for bundles A1 and
A2. This might help. But I really wonder why dynamic doesn't do the
trick. Maybe even a "dynamic 1..1" won't change an already established
binding.
BTW, I use multiple service implementations with service ranking in my
RT tutorial. But I haven't encountered the issue so far.
https://github.com/eclipseguru/eclipsert-tutorial
provider: hello.service and hello.preferences
consumer: hello.job
-Gunnar
--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
|
|
| | | |
Goto Forum:
Current Time: Sun Oct 13 20:11:31 GMT 2024
Powered by FUDForum. Page generated in 0.04921 seconds
|