felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anuj (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FELIX-4709) Incorrect Named Dependencies are binded to the Service Instance
Date Sun, 23 Nov 2014 14:47:12 GMT
Anuj created FELIX-4709:
---------------------------

             Summary: Incorrect Named Dependencies are binded to the Service Instance
                 Key: FELIX-4709
                 URL: https://issues.apache.org/jira/browse/FELIX-4709
             Project: Felix
          Issue Type: Bug
          Components: Dependency Manager
    Affects Versions: dependencymanager.runtime-3.2.0
         Environment: Windows 7 Enterprise, Eclipse 3.8
            Reporter: Anuj


There is an issue when we use @FactoryConfigurationAdapterService with dynamic filtering using
init() method. 

Use Case: We want to have multiple instances of a service. For each service instance,  we
want to dynamically specify service dependency filter based on the configuration received
for the service instance.

Issue: Whenever  init() method of new created service instance is invoked, ALL Named dependencies(with
filters) defined in init method of previously created service instances are also added as
named dependencies for this service instance. This is not logical as init must ONLY  add filters
defined in the init of this particular service instance.  When we run DM command, this is
visible. We created two service instances with value of property: com.ericsson.rm.config.tag
 as main and v30. In the output of Dm command, we can see that second instance of the factory
i.e. 137 also has named dependencies with filters of the first service instance i.e. 136 .
Second instance must not have named dependencies with filter  com.ericsson.rm.config.tag=main
which was specified in configuration of first instance (136) . 137 must only have named dependencies
with filter com.ericsson.rm.config.tag=v30.

Output of DM command:

[110] com.ericsson.bss.voucher.traffic.persistence.cassandra
 [34] Adapter for factory pid com.ericsson.rm.voucher.traffic.persistence.cassandra registered
    com.ericsson.bss.ctrl.service.jmx.MBeanServerAdmin service required available
    javax.transaction.TransactionManager service required available
 [136] com.ericsson.rm.service.voucher.traffic.persistence.VoucherPersistenceService(service.pid=com.ericsson.rm.voucher.traffic.persistence.cassandra-1416741861126-0,com.ericsson.rm.config.tag=main,service.factoryPid=com.ericsson.rm.voucher.traffic.persistence.cassandra)
registered
javax.transaction.TransactionManager service required available       com.ericsson.rm.service.domain.types.cryption.DomainTypesCryption
(com.ericsson.rm.config.tag=main-db) service required available com.ericsson.rm.service.encryption.hash.EncryptionTokenService
(com.ericsson.rm.config.tag=main) service required available
 [137] com.ericsson.rm.service.voucher.traffic.persistence.VoucherPersistenceService(service.pid=com.ericsson.rm.voucher.traffic.persistence.cassandra-1416742092818-74,com.ericsson.rm.config.tag=v30,
,service.factoryPid=com.ericsson.rm.voucher.traffic.persistence.cassandra) registered
 javax.transaction.TransactionManager service required available com.ericsson.rm.service.domain.types.cryption.DomainTypesCryption
(com.ericsson.rm.config.tag=main-db) service required availablc
com.ericsson.rm.service.encryption.hash.EncryptionTokenService (com.ericsson.rm.config.tag=main)
service required available
 com.ericsson.rm.service.domain.types.cryption.DomainTypesCryption (com.ericsson.rm.config.tag=v30-db)
service required available
    com.ericsson.rm.service.encryption.hash.EncryptionTokenService (com.ericsson.rm.config.tag=v30)
service required available

We are intermittently facing issues where named dependencies (with filters specified in other
service instances) are getting bound to a service instance and we suspect that the above mentioned
issue is the reason. Please confirm our assumption. If you see any other problem in the code
, please let us know. Please also suggest workaround to make sure binding is correct.

Felix Code Analysis:
Looking into the code of ServiceLifeCycleHandler,we observed: Instead of creating new list
of named dependencies with their filter for EACH service instance created, ServiceLifecycleHandler
maintains a common list  of all named dependencies with their filters for all service instances.
 Thus when init method of a service instance is called, named dependencies with filters are
added to existing list of dependencies from previous service instances 

We used dependency manager as follows:

@FactoryConfigurationAdapterService(provides = VoucherPersistenceService.class, factoryPid
= "com.ericsson.rm.voucher.traffic.persistence.cassandra",
        propagate = true, updated = "configure")
public class CassandraPersistence implements VoucherPersistenceService
{
……
//Named Dependencies.
@ServiceDependency(name = "Cryption", added = "bindDomainTypesCryption", removed = "unbindDomainTypesCryption",
required = true)
    public void bindDomainTypesCryption(final DomainTypesCryption parDomainTypesCryption)
    { //some code }

@ServiceDependency(name = "EncryptionTokenService", added = "bindEncryptionTokenService",
removed = "unbindEncryptionTokenService", required = true)
    public void bindEncryptionTokenService(final EncryptionTokenService parEncryptionTokenService)
    { //some code  }

    
//Unnamed Dependencies
    @ServiceDependency(added = "bindTransactionManager", removed = "unbindTransactionManager",
required = true)
    public void bindTransactionManager(final TransactionManager parTransactionManager)
    {//some code}

    protected void configure(Dictionary<String, ?> parParameters)
    {
        myMvnoId = (String) parParameters.get(Constants.MVNO_CONFIG_TAG);
        
    }

@Init
    Map init()
    {
        Map m = new HashMap();
        String filter = "(com.ericsson.rm.config.tag=" + myMvnoId + ")";
 m.put("Cryption.filter", Constants.MVNO_FILTER_PREFIX + myMvnoId + Constants.MVNO_SEPARATOR
+ "db)");
        m.put("EncryptionTokenService.filter", filter);
        return m;
    }	

Thanks






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

Mime
View raw message