[ 
https://issues.apache.org/jira/browse/FELIX-4955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14619475#comment-14619475
 ] 

Pierre De Rop commented on FELIX-4955:
--------------------------------------

committed STEP 1 in rv 1689973.

Created in my sandbox a new 
dependencymanager.ds/org.apache.felix.dependencymanager.ds sub module: this 
project contains the unmodified version of the current Apache SCR core, and all 
junit tests. Bndtools is used instead of maven. Only junit tests are included 
because bndtools (if I'm correct) requires separate module for integration 
tests.

Created a new dependencymanager.ds/org.apache.felix.dependencymanager.ds.itest 
sub module: this projects contains all scr integration tests. Pax-exam has been 
replaced by bndtools integration test environment, and a simple 
"BundleGenerator" class is used to dynamically generate "tiny bundles". See 
org.apache.felix.scr.integration.BundleGenerator.java

The ComponentTestBase class has been reworked in order to use the 
BundleGenerator, which creates "tiny bundle" in each setUp() methods, and the 
generated bundle is then uninstalled in the tearDown method.

Each test that expect some errors to be logged (through the OSGi log service) 
must now provide some regexp in the "ignoredWarnings" variable. If a test 
produces a warn or error log that is not mentioned in the "ignoredWarnings" 
variable, then the test will fail. 

The "ignoredWarnings" variable is now accepting some regex, like the following 
example:

{code}
public class CircularReferenceTest extends ComponentTestBase
{
    public CircularReferenceTest()
    {
        super("/resource/integration_test_circular.xml", "circular");
        ignoredWarnings = new String[] {
          "\\[.*\\] Circular reference detected, getService returning null",
          "FrameworkEvent: ERROR\\norg.osgi.framework.ServiceException: Service 
factory returned null.",
          "FrameworkEvent: ERROR\\norg.osgi.framework.ServiceException: 
ServiceFactory.getService\\(\\) resulted in a cycle.",
          "\\[.*\\] Cannot create component instance due to failure to bind 
reference b",
          "\\[.*\\] Failed creating the component instance; see log for reason",
          "\\[.*\\] Could not get service from ref 
\\[org.apache.felix.scr.integration.components.circular.A\\]",
          "\\[.*\\] Could not get service from ref 
\\[org.apache.felix.scr.integration.components.circular.B\\]",
        };
        //DS_LOGLEVEL = "debug";
    }
{code}

When an expected exception is logged, we only log the exception message, not 
the stacktrace.

Since bndtools does not restart the OSGi framework between each test, all tests 
have been reworked in order to ensure that every possibly created configuration 
is deleted at the end of each test methods.

Important note: during the reworking of the tests, it turns out that the 
"CircularReferenceTest" is unstable. Most of the time, the test passes OK, but 
sometimes it fails. For now, I don't know what is going on.

Also, the ComponentConcurrencyTest is throwing multiple times the following 
exception, and also many other exceptions:

{code}
java.lang.IllegalArgumentException: null source
        at java.util.EventObject.<init>(EventObject.java:56)
        at org.osgi.framework.FrameworkEvent.<init>(FrameworkEvent.java:196)
        at org.apache.felix.framework.Felix.fireFrameworkEvent(Felix.java:4533)
        at org.apache.felix.framework.Felix.getService(Felix.java:3696)
        at 
org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:470)
        at 
org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72)
        at 
org.apache.felix.scr.impl.helper.BindMethod.getServiceObject(BindMethod.java:649)
        at 
org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2061)
        at 
org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.prebind(DependencyManager.java:391)
        at 
org.apache.felix.scr.impl.manager.DependencyManager.prebind(DependencyManager.java:1405)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager.collectDependencies(AbstractComponentManager.java:983)
        at 
org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:791)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:724)
        at 
org.apache.felix.scr.impl.manager.ComponentFactoryImpl.newInstance(ComponentFactoryImpl.java:132)
        at 
org.apache.felix.scr.integration.components.concurrency.AFactory.run(AFactory.java:52)
        at java.lang.Thread.run(Thread.java:745)

java.lang.NullPointerException
        at 
org.apache.felix.scr.impl.manager.DependencyManager$AbstractCustomizer.isActive(DependencyManager.java:189)
        at 
org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.modifiedService(DependencyManager.java:350)
        at 
org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.modifiedService(DependencyManager.java:298)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerModified(ServiceTracker.java:1505)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerModified(ServiceTracker.java:1413)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:1161)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1444)
        at 
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:987)
        at 
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)
        at 
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4560)
        at org.apache.felix.framework.Felix.registerService(Felix.java:3542)
        at 
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)
        at 
org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)
        at 
org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:922)
        at 
org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:886)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1492)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1413)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:1222)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:1158)
        at 
org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1444)
        at 
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:987)
        at 
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)
        at 
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4560)
        at org.apache.felix.framework.Felix.registerService(Felix.java:3542)
        at 
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)
        at 
org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)
        at 
org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)
        at 
org.apache.felix.scr.impl.manager.ComponentFactoryImpl.newInstance(ComponentFactoryImpl.java:132)
        at 
org.apache.felix.scr.integration.components.concurrency.CFactory.run(CFactory.java:53)
        at java.lang.Thread.run(Thread.java:745)
{code}

Since I'm not sure if there is a problem in this test or if there is an issue 
in the current SCR implementation, the test is currently disabled.

- Here is an example output when running tests with gradle:

{code}
gradle org.apache.felix.dependencymanager.ds.itest:check

Running org.apache.felix.scr.integration.ActivateSignatureTest.test
Running org.apache.felix.scr.integration.AnnoConfigTest.testAnnoConfig
Running org.apache.felix.scr.integration.CircularFactoryTest.testCircularFactory
Running 
org.apache.felix.scr.integration.CircularReferenceTest.test_A11_B01_immediate_B_first
L=1 D=22:58:30,794 T="main" (log Expected): [2.A.1.1.dynamic(2)] Circular 
reference detected, getService returning null
L=2 D=22:58:30,833 T="main" (log Expected): [2.B.0.n.dynamic(3)] Could not get 
service from ref [org.apache.felix.scr.integration.components.circular.A]
L=1 D=22:58:30,833 T="FelixDispatchQueue" (log Expected): FrameworkEvent: ERROR
org.osgi.framework.ServiceException: Service factory returned null.
L=1 D=22:58:30,846 T="main" (log Expected): [5.A.1.1.dynamic(10)] Circular 
reference detected, getService returning null
L=2 D=22:58:30,855 T="main" (log Expected): [5.B.0.1.dynamic(11)] Could not get 
service from ref [org.apache.felix.scr.integration.components.circular.A]
L=1 D=22:58:30,855 T="FelixDispatchQueue" (log Expected): FrameworkEvent: ERROR
org.osgi.framework.ServiceException: Service factory returned null.
Running 
org.apache.felix.scr.integration.CircularReferenceTest.test_A11_B0n_immediate_B_first
L=1 D=22:58:30,934 T="main" (log Expected): [2.A.1.1.dynamic(2)] Circular 
reference detected, getService returning null
L=2 D=22:58:30,942 T="main" (log Expected): [2.B.0.n.dynamic(3)] Could not get 
service from ref [org.apache.felix.scr.integration.components.circular.A]
L=1 D=22:58:30,942 T="FelixDispatchQueue" (log Expected): FrameworkEvent: ERROR
org.osgi.framework.ServiceException: Service factory returned null.
L=1 D=22:58:30,955 T="main" (log Expected): [5.A.1.1.dynamic(10)] Circular 
reference detected, getService returning null
L=2 D=22:58:30,964 T="main" (log Expected): [5.B.0.1.dynamic(11)] Could not get 
service from ref [org.apache.felix.scr.integration.components.circular.A]
L=1 D=22:58:30,964 T="FelixDispatchQueue" (log Expected): FrameworkEvent: ERROR
org.osgi.framework.ServiceException: Service factory returned null.
etc ...

here, excepted warnings/error are prefixed with a "(log expected)" header.

Notice that currently, many 300 millis delays are used in integration tests. So 
the performance gain is not as quicker as expected, even if tests are now 
running under bndtools. To make tests faster, some latchs could be used but 
this is another improvement that could be done later.


  


> DS based on Dependency Manager
> ------------------------------
>
>                 Key: FELIX-4955
>                 URL: https://issues.apache.org/jira/browse/FELIX-4955
>             Project: Felix
>          Issue Type: New Feature
>          Components: Dependency Manager
>            Reporter: Pierre De Rop
>            Assignee: Pierre De Rop
>
> (this is an experimental issue)
> Whilst Apache Felix Dependency Manager is a powerful tool that allows to 
> manage OSGi service components, it is not standard. On the other hand, at 
> Felix we have SCR which is an implementation of the standard OSGi Declarative 
> Service (DS) specification.
> The intent of this experimental issue is to unify and align both DS and DM in 
> order to provide a Declarative Service library based on Dependency Manager.
> This new DS library will bring the following benefits:
> - For those who love DM, this new library will provide a unified solution 
> that align both DM and DS, where each DS component would be actually 
> implemented as a DM component, browsable from the DM shell.
> - provide some DM extension to DS component: for example, the ability to add 
> some extra dependencies dynamically from DS component's "init" method.
> This experimentation can be split in the following steps:
> h5. STEP 1: build current SCR in a DM submodule using bndtools
> Create a new DM dependencymanager/org.apache.felix.dependencymanager.ds 
> module that includes the current Apache SCR implementation. As DM is based on 
> bndtools, the current SCR implementation will have to be de-mavenified and 
> built using bndtools. The new module will also include the current SCR junit 
> tests, but not integration tests because current released bndtools requires 
> to have separate modules
> for integration tests (if I'm correct).
> h5. STEP 2: create a new DM submodule for SCR integration tests.
> Create a new DM dependencymanager/org.apache.felix.dependencymanager.ds.itest 
> sub module that includes the current Apache SCR integration tests.
> Pax-exam seems to not work well within bndtools. So, it has to be replaced by 
> a simpler tool that allows to dynamically build a "tiny" bundle under 
> bndtools. That tool will be simply based on bndlib.
> All tests will also have to be reworked in order to cleanup possibly created 
> test configurations because in bndtools, the framework is not restarted 
> between tests.
> h5. STEP 3: update the dependency manager load test suite
> Add a new loadtest suite based on current Apache Felix SCR
> Add a new loadtest suite based on the new 
> org.apache.felix.dependencymanager.ds bundle.
> This will allow to compare and make sure that the new DS library will be at 
> minimum as fast as the current SCR implementation. It will also be used to 
> observe the gain of using the actor thread model of DM with DS components.
> h5. STEP 4: rework SCR with DM
> That will be of course the most difficult part to do: rework
> dependencymanager/org.apache.felix.dependencymanager.ds in order to map each 
> DS components to DM components (internally).
> After a quick look over the current implementation, the following things 
> could be done:
> - modify the classes derived from 
> org.apache.felix.scr.impl.manager.AbstractComponentManager and transform them 
> into DM component.
> - Rework the org.apache.felix.scr.impl.manager.DependencyManager and 
> implements it as a DM dependency (by extending the 
> org.apache.felix.dm.context.AbstractDependency class).
> h5. STEP 5: build everything in java8
> Java7 is in end of life and the DM loadtest suite requires java8.
> So, for consistency reasons, build every DM submodules using java8.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to