Search in sources :

Example 1 with ModuleRuntime

use of org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime in project controller by opendaylight.

the class ConfigSubsystemFacade method get.

public Element get(final Document document) throws DocumentedException {
    final ObjectName testTransaction = transactionProvider.getOrCreateReadTransaction();
    final ConfigTransactionClient txClient = configRegistryClient.getConfigTransactionClient(testTransaction);
    try {
        // Runtime beans are not parts of transactions and have to be queried against
        // the central registry
        final Set<ObjectName> runtimeBeans = configRegistryClient.lookupRuntimeBeans();
        final Set<ObjectName> configBeans = Datastore.getInstanceQueryStrategy(Datastore.running, transactionProvider).queryInstances(configRegistryClient);
        final Map<String, Map<String, ModuleRuntime>> moduleRuntimes = createModuleRuntimes(configRegistryClient, yangStoreService.getModuleMXBeanEntryMap());
        final YangStoreContext yangStoreSnapshot = yangStoreService.getCurrentSnapshot();
        final Map<String, Map<String, ModuleConfig>> moduleConfigs = transformMbeToModuleConfigs(txClient, yangStoreSnapshot.getModuleMXBeanEntryMap());
        final org.opendaylight.controller.config.facade.xml.runtime.Runtime runtime = new Runtime(moduleRuntimes, moduleConfigs);
        return runtime.toXml(runtimeBeans, configBeans, document, yangStoreSnapshot.getEnumResolver());
    } finally {
        transactionProvider.closeReadTransaction();
    }
}
Also used : YangStoreContext(org.opendaylight.controller.config.facade.xml.osgi.YangStoreContext) ObjectName(javax.management.ObjectName) Runtime(org.opendaylight.controller.config.facade.xml.runtime.Runtime) InstanceRuntime(org.opendaylight.controller.config.facade.xml.runtime.InstanceRuntime) ModuleRuntime(org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime) Runtime(org.opendaylight.controller.config.facade.xml.runtime.Runtime) ConfigTransactionClient(org.opendaylight.controller.config.util.ConfigTransactionClient) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ModuleRuntime

use of org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime in project controller by opendaylight.

the class ConfigSubsystemFacade method createModuleRuntimes.

private Map<String, Map<String, ModuleRuntime>> createModuleRuntimes(final ConfigRegistryClient client, final Map<String, Map<String, ModuleMXBeanEntry>> mbeanentries) {
    Map<String, Map<String, ModuleRuntime>> retVal = new HashMap<>();
    for (Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleEntry : mbeanentries.entrySet()) {
        Map<String, ModuleRuntime> innerMap = new HashMap<>();
        Map<String, ModuleMXBeanEntry> entriesFromNamespace = namespaceToModuleEntry.getValue();
        for (Map.Entry<String, ModuleMXBeanEntry> moduleToMXEntry : entriesFromNamespace.entrySet()) {
            ModuleMXBeanEntry mbe = moduleToMXEntry.getValue();
            Map<RuntimeBeanEntry, InstanceConfig> cache = new HashMap<>();
            RuntimeBeanEntry root = null;
            for (RuntimeBeanEntry rbe : mbe.getRuntimeBeans()) {
                cache.put(rbe, new InstanceConfig(client, rbe.getYangPropertiesToTypesMap(), mbe.getNullableDummyContainerName()));
                if (rbe.isRoot()) {
                    root = rbe;
                }
            }
            if (root == null) {
                continue;
            }
            InstanceRuntime rootInstanceRuntime = createInstanceRuntime(root, cache);
            ModuleRuntime moduleRuntime = new ModuleRuntime(rootInstanceRuntime);
            innerMap.put(moduleToMXEntry.getKey(), moduleRuntime);
        }
        retVal.put(namespaceToModuleEntry.getKey(), innerMap);
    }
    return retVal;
}
Also used : InstanceRuntime(org.opendaylight.controller.config.facade.xml.runtime.InstanceRuntime) HashMap(java.util.HashMap) RuntimeBeanEntry(org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry) InstanceConfig(org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig) ModuleMXBeanEntry(org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry) ModuleRuntime(org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 InstanceRuntime (org.opendaylight.controller.config.facade.xml.runtime.InstanceRuntime)2 ModuleRuntime (org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime)2 ObjectName (javax.management.ObjectName)1 InstanceConfig (org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig)1 YangStoreContext (org.opendaylight.controller.config.facade.xml.osgi.YangStoreContext)1 Runtime (org.opendaylight.controller.config.facade.xml.runtime.Runtime)1 ConfigTransactionClient (org.opendaylight.controller.config.util.ConfigTransactionClient)1 ModuleMXBeanEntry (org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry)1 RuntimeBeanEntry (org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry)1