X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Foperations%2Fruntimerpc%2FRuntimeRpc.java;h=ebbc0e5695f77dc9cf05c124e2ca6f5baedd7e83;hp=7790e09ceeb245b926f9c1c4c71fe1f2dde16589;hb=3997099eb61b0f2adc47f7a85952c324e9de223f;hpb=abca01a0016ee55b6cdcb71c81419c4b143bb63a diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java index 7790e09cee..ebbc0e5695 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java @@ -11,6 +11,9 @@ package org.opendaylight.controller.netconf.confignetconfconnector.operations.ru import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; +import java.util.Map; +import javax.management.ObjectName; +import javax.management.openmbean.OpenType; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry; @@ -18,6 +21,7 @@ import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc; import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc; import org.opendaylight.controller.config.yangjmxgenerator.attribute.VoidAttribute; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; +import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.AttributeMappingStrategy; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectMapper; @@ -26,37 +30,31 @@ import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.In import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.ModuleRpcs; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.Rpcs; import org.opendaylight.controller.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation; -import org.opendaylight.controller.netconf.confignetconfconnector.operations.Commit; -import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreContext; import org.opendaylight.controller.netconf.mapping.api.HandlingPriority; import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException; import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import javax.management.ObjectName; -import javax.management.openmbean.OpenType; -import java.util.Map; - public class RuntimeRpc extends AbstractConfigNetconfOperation { - private static final Logger logger = LoggerFactory.getLogger(Commit.class); + private static final Logger LOG = LoggerFactory.getLogger(RuntimeRpc.class); public static final String CONTEXT_INSTANCE = "context-instance"; - private final YangStoreSnapshot yangStoreSnapshot; + private final YangStoreContext yangStoreSnapshot; - public RuntimeRpc(final YangStoreSnapshot yangStoreSnapshot, ConfigRegistryClient configRegistryClient, + public RuntimeRpc(final YangStoreContext yangStoreSnapshot, ConfigRegistryClient configRegistryClient, String netconfSessionIdForReporting) { super(configRegistryClient, netconfSessionIdForReporting); this.yangStoreSnapshot = yangStoreSnapshot; } private Element toXml(Document doc, Object result, AttributeIfc returnType, String namespace, String elementName) throws NetconfDocumentedException { - AttributeMappingStrategy> mappingStrategy = new ObjectMapper(null).prepareStrategy(returnType); + AttributeMappingStrategy> mappingStrategy = new ObjectMapper().prepareStrategy(returnType); Optional mappedAttributeOpt = mappingStrategy.mapAttribute(result); Preconditions.checkState(mappedAttributeOpt.isPresent(), "Unable to map return value %s as %s", result, returnType.getOpenType()); @@ -79,8 +77,7 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation { final String[] signature = new String[attributes.size()]; int i = 0; - for (final String attrName : attributes.keySet()) { - final AttributeConfigElement attribute = attributes.get(attrName); + for (final AttributeConfigElement attribute : attributes.values()) { final Optional resolvedValueOpt = attribute.getResolvedValue(); params[i] = resolvedValueOpt.isPresent() ? resolvedValueOpt.get() : attribute.getResolvedDefaultValue(); @@ -97,7 +94,7 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation { try { namespace = xml.getNamespace(); } catch (MissingNameSpaceException e) { - logger.trace("Can't get namespace from xml element due to {}",e); + LOG.trace("Can't get namespace from xml element due to ",e); throw NetconfDocumentedException.wrap(e); } final XmlElement contextInstanceElement = xml.getOnlyChildElement(CONTEXT_INSTANCE); @@ -132,7 +129,7 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation { try { netconfOperationNamespace = operationElement.getNamespace(); } catch (MissingNameSpaceException e) { - logger.debug("Cannot retrieve netconf operation namespace from message due to {}", e); + LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e); return HandlingPriority.CANNOT_HANDLE; } @@ -158,7 +155,7 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation { netconfOperationName); } catch (IllegalStateException e) { - logger.debug("Cannot handle runtime operation {}:{}", netconfOperationNamespace, netconfOperationName, e); + LOG.debug("Cannot handle runtime operation {}:{}", netconfOperationNamespace, netconfOperationName, e); return HandlingPriority.CANNOT_HANDLE; } @@ -181,12 +178,12 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation { // TODO check for namespaces and unknown elements final NetconfOperationExecution execution = fromXml(xml); - logger.debug("Invoking operation {} on {} with arguments {}", execution.operationName, execution.on, + LOG.debug("Invoking operation {} on {} with arguments {}", execution.operationName, execution.on, execution.attributes); final Object result = executeOperation(getConfigRegistryClient(), execution.on, execution.operationName, execution.attributes); - logger.trace("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName, + LOG.trace("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName, execution.on, execution.attributes, result); if (execution.isVoid()) { @@ -246,23 +243,23 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation { final Map> map = Maps.newHashMap(); - for (final String namespace : mBeanEntries.keySet()) { + for (final Map.Entry> namespaceToModuleEntry : mBeanEntries.entrySet()) { - Map namespaceToModules = map.get(namespace); + Map namespaceToModules = map.get(namespaceToModuleEntry.getKey()); if (namespaceToModules == null) { namespaceToModules = Maps.newHashMap(); - map.put(namespace, namespaceToModules); + map.put(namespaceToModuleEntry.getKey(), namespaceToModules); } - for (final String moduleName : mBeanEntries.get(namespace).keySet()) { + for (final Map.Entry moduleEntry : namespaceToModuleEntry.getValue().entrySet()) { - ModuleRpcs rpcMapping = namespaceToModules.get(moduleName); + ModuleRpcs rpcMapping = namespaceToModules.get(moduleEntry.getKey()); if (rpcMapping == null) { rpcMapping = new ModuleRpcs(); - namespaceToModules.put(moduleName, rpcMapping); + namespaceToModules.put(moduleEntry.getKey(), rpcMapping); } - final ModuleMXBeanEntry entry = mBeanEntries.get(namespace).get(moduleName); + final ModuleMXBeanEntry entry = moduleEntry.getValue(); for (final RuntimeBeanEntry runtimeEntry : entry.getRuntimeBeans()) { rpcMapping.addNameMapping(runtimeEntry);