Search in sources :

Example 1 with ServiceReferenceTransactionRegistratorFactory

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method createSRWritableRegistry.

public static SearchableServiceReferenceWritableRegistry createSRWritableRegistry(final ServiceReferenceReadableRegistry oldReadableRegistry, final ConfigTransactionLookupRegistry txLookupRegistry, final Map<String, Map.Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories) {
    if (txLookupRegistry == null) {
        throw new IllegalArgumentException("txLookupRegistry is null");
    }
    ServiceReferenceRegistryImpl old = (ServiceReferenceRegistryImpl) oldReadableRegistry;
    Map<String, ModuleFactory> factories = extractFactoriesMap(currentlyRegisteredFactories);
    ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = new ServiceReferenceTransactionRegistratorFactoryImpl(txLookupRegistry.getTxModuleJMXRegistrator(), txLookupRegistry.getTxModuleJMXRegistrator().getTransactionName());
    ServiceReferenceRegistryImpl newRegistry = new ServiceReferenceRegistryImpl(factories, txLookupRegistry, serviceReferenceRegistratorFactory, true);
    copy(old, newRegistry, txLookupRegistry.getTransactionIdentifier().getName());
    return newRegistry;
}
Also used : ModuleFactory(org.opendaylight.controller.config.spi.ModuleFactory) ServiceReferenceTransactionRegistratorFactoryImpl(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactoryImpl) ServiceReferenceTransactionRegistratorFactory(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory)

Example 2 with ServiceReferenceTransactionRegistratorFactory

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method createInitialSRLookupRegistry.

/**
 * Static constructor for config registry. Since only transaction can write to
 * this registry, it will return blank state.
 *
 * @return service reference registry
 */
public static CloseableServiceReferenceReadableRegistry createInitialSRLookupRegistry() {
    // since this is initial state, just throw exception:
    LookupRegistry lookupRegistry = new LookupRegistry() {

        @Override
        public Set<ObjectName> lookupConfigBeans() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupConfigBeans(final String moduleName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupConfigBeans(final String moduleName, final String instanceName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public ObjectName lookupConfigBean(final String moduleName, final String instanceName) throws InstanceNotFoundException {
            throw new UnsupportedOperationException();
        }

        @Override
        public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException {
            throw new InstanceNotFoundException("Cannot find " + objectName + " - Tried to use mocking registry");
        }

        @Override
        public Set<String> getAvailableModuleFactoryQNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupRuntimeBeans() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupRuntimeBeans(final String moduleName, final String instanceName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public String toString() {
            return "initial";
        }
    };
    ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = () -> new ServiceReferenceRegistrator() {

        @Override
        public String getNullableTransactionName() {
            throw new UnsupportedOperationException();
        }

        @Override
        public ServiceReferenceJMXRegistration registerMBean(final ServiceReferenceMXBeanImpl object, final ObjectName on) throws InstanceAlreadyExistsException {
            throw new UnsupportedOperationException();
        }

        @Override
        public void close() {
        }
    };
    return new ServiceReferenceRegistryImpl(Collections.<String, ModuleFactory>emptyMap(), lookupRegistry, serviceReferenceRegistratorFactory, false);
}
Also used : ServiceReferenceMXBeanImpl(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl) InstanceNotFoundException(javax.management.InstanceNotFoundException) LookupRegistry(org.opendaylight.controller.config.api.LookupRegistry) ServiceReferenceTransactionRegistratorFactory(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory) ServiceReferenceRegistrator(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator) ObjectName(javax.management.ObjectName)

Example 3 with ServiceReferenceTransactionRegistratorFactory

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method createSRReadableRegistry.

/**
 * Copy back state to config registry after commit.
 *
 * @param oldWritableRegistry
 *            old registry
 * @param lookupRegistry
 *            lookup registry
 * @param baseJMXRegistrator
 *            JMX registrator
 * @return service reference
 */
public static CloseableServiceReferenceReadableRegistry createSRReadableRegistry(final ServiceReferenceWritableRegistry oldWritableRegistry, final LookupRegistry lookupRegistry, final BaseJMXRegistrator baseJMXRegistrator) {
    ServiceReferenceRegistryImpl old = (ServiceReferenceRegistryImpl) oldWritableRegistry;
    // even if factories do change, nothing in the mapping can change between
    // transactions
    ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = new ServiceReferenceTransactionRegistratorFactoryImpl(baseJMXRegistrator);
    ServiceReferenceRegistryImpl newRegistry = new ServiceReferenceRegistryImpl(old.factories, lookupRegistry, serviceReferenceRegistratorFactory, false);
    copy(old, newRegistry, null);
    return newRegistry;
}
Also used : ServiceReferenceTransactionRegistratorFactoryImpl(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactoryImpl) ServiceReferenceTransactionRegistratorFactory(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory)

Aggregations

ServiceReferenceTransactionRegistratorFactory (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory)3 ServiceReferenceTransactionRegistratorFactoryImpl (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactoryImpl)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 ObjectName (javax.management.ObjectName)1 LookupRegistry (org.opendaylight.controller.config.api.LookupRegistry)1 ServiceReferenceMXBeanImpl (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl)1 ServiceReferenceRegistrator (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator)1 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)1