<java.version.target>1.7</java.version.target>
<!-- enforcer version -->
<enforcer.version>1.3.1</enforcer.version>
+ <xtend.version>2.4.3</xtend.version>
+ <xtend.dstdir>${project.build.directory}/generated-sources/xtend-gen</xtend.dstdir>
</properties>
<dependencyManagement>
</dependency>
<!-- md-sal -->
+ <dependency>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>org.eclipse.xtend.lib</artifactId>
+ <version>${xtend.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common</artifactId>
<artifactId>config-persister-impl</artifactId>
<version>${netconf.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ietf-netconf-monitoring</artifactId>
- <version>${netconf.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ietf-netconf-monitoring-extension</artifactId>
- <version>${netconf.version}</version>
- </dependency>
<!-- threadpool -->
<dependency>
<testTarget>${java.version.target}</testTarget>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ <version>${xtend.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${xtend.dstdir}</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</pluginManagement>
</build>
@ConstructorProperties(QNAME_ATTR_NAME)
public IdentityAttributeRef(String qNameOfIdentity) {
- if (qNameOfIdentity == null)
+ if (qNameOfIdentity == null) {
throw new NullPointerException("Parameter " + QNAME_ATTR_NAME + " is null");
+ }
this.qNameOfIdentity = qNameOfIdentity;
}
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof IdentityAttributeRef)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof IdentityAttributeRef)) {
+ return false;
+ }
IdentityAttributeRef that = (IdentityAttributeRef) o;
- if (!qNameOfIdentity.equals(that.qNameOfIdentity)) return false;
+ if (!qNameOfIdentity.equals(that.qNameOfIdentity)) {
+ return false;
+ }
return true;
}
private final String attributeName;
public JmxAttribute(String attributeName) {
- if (attributeName == null)
+ if (attributeName == null) {
throw new NullPointerException("Parameter 'attributeName' is null");
+ }
this.attributeName = attributeName;
}
@Override
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
JmxAttribute that = (JmxAttribute) o;
if (attributeName != null ? !attributeName.equals(that.attributeName)
- : that.attributeName != null)
+ : that.attributeName != null) {
return false;
+ }
return true;
}
private final String factoryName, instanceName;
public ModuleIdentifier(String factoryName, String instanceName) {
- if (factoryName == null)
- throw new IllegalArgumentException(
- "Parameter 'factoryName' is null");
- if (instanceName == null)
- throw new IllegalArgumentException(
- "Parameter 'instanceName' is null");
+ if (factoryName == null) {
+ throw new IllegalArgumentException("Parameter 'factoryName' is null");
+ }
+ if (instanceName == null) {
+ throw new IllegalArgumentException("Parameter 'instanceName' is null");
+ }
this.factoryName = factoryName;
this.instanceName = instanceName;
}
@Override
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
ModuleIdentifier that = (ModuleIdentifier) o;
- if (!factoryName.equals(that.factoryName))
+ if (!factoryName.equals(that.factoryName)) {
return false;
- if (!instanceName.equals(that.instanceName))
+ }
+ if (!instanceName.equals(that.instanceName)) {
return false;
+ }
return true;
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
ExceptionMessageWithStackTrace other = (ExceptionMessageWithStackTrace) obj;
if (message == null) {
- if (other.message != null)
+ if (other.message != null) {
return false;
- } else if (!message.equals(other.message))
+ }
+ } else if (!message.equals(other.message)) {
return false;
+ }
if (stackTrace == null) {
- if (other.stackTrace != null)
+ if (other.stackTrace != null) {
return false;
- } else if (!stackTrace.equals(other.stackTrace))
+ }
+ } else if (!stackTrace.equals(other.stackTrace)) {
return false;
+ }
return true;
}
*/
package org.opendaylight.controller.config.api.jmx;
+import javax.annotation.concurrent.Immutable;
+import javax.management.ObjectName;
import java.beans.ConstructorProperties;
import java.util.Collections;
import java.util.List;
-import javax.annotation.concurrent.Immutable;
-import javax.management.ObjectName;
-
@Immutable
public class CommitStatus {
private final List<ObjectName> newInstances, reusedInstances,
recreatedInstances;
/**
- *
- * @param newInstances
- * newly created instances
- * @param reusedInstances
- * reused instances
- * @param recreatedInstances
- * recreated instances
+ * @param newInstances newly created instances
+ * @param reusedInstances reused instances
+ * @param recreatedInstances recreated instances
*/
- @ConstructorProperties({ "newInstances", "reusedInstances",
- "recreatedInstances" })
+ @ConstructorProperties({"newInstances", "reusedInstances",
+ "recreatedInstances"})
public CommitStatus(List<ObjectName> newInstances,
- List<ObjectName> reusedInstances,
- List<ObjectName> recreatedInstances) {
+ List<ObjectName> reusedInstances,
+ List<ObjectName> recreatedInstances) {
this.newInstances = Collections.unmodifiableList(newInstances);
this.reusedInstances = Collections.unmodifiableList(reusedInstances);
this.recreatedInstances = Collections
}
/**
- *
* @return list of objectNames representing newly created instances
*/
public List<ObjectName> getNewInstances() {
}
/**
- *
* @return list of objectNames representing reused instances
*/
public List<ObjectName> getReusedInstances() {
}
/**
- *
* @return list of objectNames representing recreated instances
*/
public List<ObjectName> getRecreatedInstances() {
result = prime
* result
+ ((recreatedInstances == null) ? 0 : recreatedInstances
- .hashCode());
+ .hashCode());
result = prime * result
+ ((reusedInstances == null) ? 0 : reusedInstances.hashCode());
return result;
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
CommitStatus other = (CommitStatus) obj;
if (newInstances == null) {
- if (other.newInstances != null)
+ if (other.newInstances != null) {
return false;
- } else if (!newInstances.equals(other.newInstances))
+ }
+ } else if (!newInstances.equals(other.newInstances)) {
return false;
+ }
if (recreatedInstances == null) {
- if (other.recreatedInstances != null)
+ if (other.recreatedInstances != null) {
return false;
- } else if (!recreatedInstances.equals(other.recreatedInstances))
+ }
+ } else if (!recreatedInstances.equals(other.recreatedInstances)) {
return false;
+ }
if (reusedInstances == null) {
- if (other.reusedInstances != null)
+ if (other.reusedInstances != null) {
return false;
- } else if (!reusedInstances.equals(other.reusedInstances))
+ }
+ } else if (!reusedInstances.equals(other.reusedInstances)) {
return false;
+ }
return true;
}
import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
import javax.annotation.concurrent.ThreadSafe;
+import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import java.util.Arrays;
import java.util.HashMap;
public static ObjectName createON(String on) {
try {
return new ObjectName(on);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (MalformedObjectNameException e) {
+ throw new IllegalArgumentException(e);
}
}
Hashtable<String, String> table = new Hashtable<>(attribs);
try {
return new ObjectName(domain, table);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (MalformedObjectNameException e) {
+ throw new IllegalArgumentException(e);
}
}
public static String getServiceQName(ObjectName objectName) {
checkType(objectName, TYPE_SERVICE_REFERENCE);
String quoted = objectName.getKeyProperty(SERVICE_QNAME_KEY);
- String result = unquoteAndUnescape(objectName, quoted);
- return result;
+ return unquoteAndUnescape(objectName, quoted);
}
// ObjectName supports quotation and ignores tokens like =, but fails to ignore ? sign.
}
}
- public static void checkTypeOneOf(ObjectName objectName, String ... types) {
- for(String type: types) {
+ public static void checkTypeOneOf(ObjectName objectName, String... types) {
+ for (String type : types) {
if (type.equals(objectName.getKeyProperty(TYPE_KEY))) {
return;
}
public static ObjectName createModulePattern(String moduleName,
String instanceName) {
- if (moduleName == null)
+ if (moduleName == null) {
moduleName = "*";
- if (instanceName == null)
+ }
+ if (instanceName == null) {
instanceName = "*";
+ }
// do not return object names containing transaction name
ObjectName namePattern = ObjectNameUtil
.createON(ObjectNameUtil.ON_DOMAIN + ":"
String expectedType) {
checkType(objectName, expectedType);
String factoryName = getFactoryName(objectName);
- if (factoryName == null)
+ if (factoryName == null) {
throw new IllegalArgumentException(
"ObjectName does not contain module name");
+ }
String instanceName = getInstanceName(objectName);
- if (instanceName == null)
+ if (instanceName == null) {
throw new IllegalArgumentException(
"ObjectName does not contain instance name");
+ }
return new ModuleIdentifier(factoryName, instanceName);
}
*/
package org.opendaylight.controller.config.api.jmx.constants;
+import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
public class ConfigRegistryConstants {
public static final ObjectName OBJECT_NAME = createONWithDomainAndType(TYPE_CONFIG_REGISTRY);
- public static String GET_AVAILABLE_MODULE_NAMES_ATTRIBUT_NAME = "AvailableModuleNames";
+ public static final String GET_AVAILABLE_MODULE_NAMES_ATTRIBUT_NAME = "AvailableModuleNames";
public static ObjectName createONWithDomainAndType(String type) {
return createON(ON_DOMAIN, TYPE_KEY, type);
public static ObjectName createON(String name, String key, String value) {
try {
return new ObjectName(name, key, value);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (MalformedObjectNameException e) {
+ throw new IllegalArgumentException(e);
}
}
private List<ModuleFactory> lastListOfFactories = Collections.emptyList();
@GuardedBy("this") // switched in every 2ndPC
- private CloseableServiceReferenceReadableRegistry readableSRRegistry = ServiceReferenceRegistryImpl.createInitialSRLookupRegistry();
+ private CloseableServiceReferenceReadableRegistry readableSRRegistry = ServiceReferenceRegistryImpl.createInitialSRLookupRegistry();
// constructor
public ConfigRegistryImpl(ModuleFactoriesResolver resolver,
- MBeanServer configMBeanServer, CodecRegistry codecRegistry) {
+ MBeanServer configMBeanServer, CodecRegistry codecRegistry) {
this(resolver, configMBeanServer,
new BaseJMXRegistrator(configMBeanServer), codecRegistry);
}
// constructor
public ConfigRegistryImpl(ModuleFactoriesResolver resolver,
- MBeanServer configMBeanServer,
- BaseJMXRegistrator baseJMXRegistrator, CodecRegistry codecRegistry) {
+ MBeanServer configMBeanServer,
+ BaseJMXRegistrator baseJMXRegistrator, CodecRegistry codecRegistry) {
this.resolver = resolver;
- this.beanToOsgiServiceManager = new BeanToOsgiServiceManager();
+ beanToOsgiServiceManager = new BeanToOsgiServiceManager();
this.configMBeanServer = configMBeanServer;
this.baseJMXRegistrator = baseJMXRegistrator;
this.codecRegistry = codecRegistry;
- this.registryMBeanServer = MBeanServerFactory
+ registryMBeanServer = MBeanServerFactory
.createMBeanServer("ConfigRegistry" + configMBeanServer.getDefaultDomain());
- this.transactionsMBeanServer = MBeanServerFactory
+ transactionsMBeanServer = MBeanServerFactory
.createMBeanServer("ConfigTransactions" + configMBeanServer.getDefaultDomain());
}
* {@inheritDoc}
*/
@Override
+ @SuppressWarnings("PMD.AvoidCatchingThrowable")
public synchronized CommitStatus commitConfig(ObjectName transactionControllerON)
throws ConflictingVersionException, ValidationException {
final String transactionName = ObjectNameUtil
return secondPhaseCommit(
configTransactionController, commitInfo);
} catch (Throwable t) { // some libs throw Errors: e.g.
- // javax.xml.ws.spi.FactoryFinder$ConfigurationError
+ // javax.xml.ws.spi.FactoryFinder$ConfigurationError
isHealthy = false;
logger.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
if (t instanceof RuntimeException) {
} else if (t instanceof Error) {
throw (Error) t;
} else {
- throw new RuntimeException(t);
+ throw new IllegalStateException(t);
}
}
}
for (DestroyedModule toBeDestroyed : commitInfo
.getDestroyedFromPreviousTransactions()) {
toBeDestroyed.close(); // closes instance (which should close
- // runtime jmx registrator),
+ // runtime jmx registrator),
// also closes osgi registration and ModuleJMXRegistrator
// registration
currentConfig.remove(toBeDestroyed.getIdentifier());
for (ModuleIdentifier moduleIdentifier : orderedModuleIdentifiers) {
ModuleInternalTransactionalInfo entry = commitInfo.getCommitted()
.get(moduleIdentifier);
- if (entry == null)
+ if (entry == null) {
throw new NullPointerException("Module not found "
+ moduleIdentifier);
+ }
Module module = entry.getModule();
ObjectName primaryReadOnlyON = ObjectNameUtil
.createReadOnlyModuleON(moduleIdentifier);
// register to OSGi
if (osgiRegistration == null) {
ModuleFactory moduleFactory = entry.getModuleFactory();
- if(moduleFactory != null) {
+ if (moduleFactory != null) {
BundleContext bc = configTransactionController.
getModuleFactoryBundleContext(moduleFactory.getImplementationName());
osgiRegistration = beanToOsgiServiceManager.registerToOsgi(module.getClass(),
version = configTransactionController.getVersion();
// switch readable Service Reference Registry
- this.readableSRRegistry.close();
- this.readableSRRegistry = ServiceReferenceRegistryImpl.createSRReadableRegistry(
+ readableSRRegistry.close();
+ readableSRRegistry = ServiceReferenceRegistryImpl.createSRReadableRegistry(
configTransactionController.getWritableRegistry(), this, baseJMXRegistrator);
return new CommitStatus(newInstances, reusedInstances,
*/
@Override
public Set<ObjectName> lookupConfigBeans(String moduleName,
- String instanceName) {
+ String instanceName) {
ObjectName namePattern = ObjectNameUtil.createModulePattern(moduleName,
instanceName);
return baseJMXRegistrator.queryNames(namePattern, null);
*/
@Override
public Set<ObjectName> lookupRuntimeBeans(String moduleName,
- String instanceName) {
- if (moduleName == null)
+ String instanceName) {
+ if (moduleName == null) {
moduleName = "*";
- if (instanceName == null)
+ }
+ if (instanceName == null) {
instanceName = "*";
+ }
ObjectName namePattern = ObjectNameUtil.createRuntimeBeanPattern(
moduleName, instanceName);
return baseJMXRegistrator.queryNames(namePattern, null);
* {@link ConfigTransactionControllerInternal} instances, because platform
* MBeanServer transforms mbeans into another representation. Map is cleaned
* every time current transactions are requested.
- *
*/
@GuardedBy("ConfigRegistryImpl.this")
private final Map<String /* transactionName */, ConfigTransactionControllerInternal> transactions = new HashMap<>();
* Can only be called from within synchronized method.
*/
public void add(String transactionName,
- ConfigTransactionControllerInternal transactionController) {
+ ConfigTransactionControllerInternal transactionController) {
Object oldValue = transactions.put(transactionName,
transactionController);
if (oldValue != null) {
public Map<String, ConfigTransactionControllerInternal> getCurrentTransactions() {
// first, remove closed transaction
for (Iterator<Entry<String, ConfigTransactionControllerInternal>> it = transactions
- .entrySet().iterator(); it.hasNext();) {
+ .entrySet().iterator(); it.hasNext(); ) {
Entry<String, ConfigTransactionControllerInternal> entry = it
.next();
if (entry.getValue().isClosed()) {
class ConfigTransactionControllerImpl implements
ConfigTransactionControllerInternal,
ConfigTransactionControllerImplMXBean,
- Identifiable<TransactionIdentifier>{
+ Identifiable<TransactionIdentifier> {
private static final Logger logger = LoggerFactory.getLogger(ConfigTransactionControllerImpl.class);
private final ConfigTransactionLookupRegistry txLookupRegistry;
List<ModuleFactory> toBeAdded = new ArrayList<>();
List<ModuleFactory> toBeRemoved = new ArrayList<>();
- for(ModuleFactory moduleFactory: factoriesHolder.getModuleFactories()) {
- if (oldSet.contains(moduleFactory) == false){
+ for (ModuleFactory moduleFactory : factoriesHolder.getModuleFactories()) {
+ if (oldSet.contains(moduleFactory) == false) {
toBeAdded.add(moduleFactory);
}
}
- for(ModuleFactory moduleFactory: lastListOfFactories){
+ for (ModuleFactory moduleFactory : lastListOfFactories) {
if (newSet.contains(moduleFactory) == false) {
toBeRemoved.add(moduleFactory);
}
}
// remove modules belonging to removed factories
- for(ModuleFactory removedFactory: toBeRemoved){
+ for (ModuleFactory removedFactory : toBeRemoved) {
List<ModuleIdentifier> modulesOfRemovedFactory = dependencyResolverManager.findAllByFactory(removedFactory);
for (ModuleIdentifier name : modulesOfRemovedFactory) {
destroyModule(name);
@Override
public synchronized ObjectName createModule(String factoryName,
- String instanceName) throws InstanceAlreadyExistsException {
+ String instanceName) throws InstanceAlreadyExistsException {
transactionStatus.checkNotCommitStarted();
transactionStatus.checkNotAborted();
throws InstanceAlreadyExistsException {
logger.debug("Adding module {} to transaction {}", moduleIdentifier, this);
- if (moduleIdentifier.equals(module.getIdentifier())==false) {
+ if (moduleIdentifier.equals(module.getIdentifier()) == false) {
throw new IllegalStateException("Incorrect name reported by module. Expected "
- + moduleIdentifier + ", got " + module.getIdentifier());
+ + moduleIdentifier + ", got " + module.getIdentifier());
}
- if (dependencyResolver.getIdentifier().equals(moduleIdentifier) == false ) {
+ if (dependencyResolver.getIdentifier().equals(moduleIdentifier) == false) {
throw new IllegalStateException("Incorrect name reported by dependency resolver. Expected "
+ moduleIdentifier + ", got " + dependencyResolver.getIdentifier());
}
// first remove refNames, it checks for objectname existence
try {
writableSRRegistry.removeServiceReferences(
- ObjectNameUtil.createTransactionModuleON(getTransactionName(),moduleIdentifier));
+ ObjectNameUtil.createTransactionModuleON(getTransactionName(), moduleIdentifier));
} catch (InstanceNotFoundException e) {
logger.error("Possible code error: cannot find {} in {}", moduleIdentifier, writableSRRegistry);
throw new IllegalStateException("Possible code error: cannot find " + moduleIdentifier, e);
@Override
public synchronized void validateConfig() throws ValidationException {
- if (configBeanModificationDisabled.get())
+ if (configBeanModificationDisabled.get()) {
throw new IllegalStateException("Cannot start validation");
+ }
configBeanModificationDisabled.set(true);
try {
validate_noLocks();
logger.error("Commit failed on {} in transaction {}", name,
getTransactionIdentifier(), e);
internalAbort();
- throw new RuntimeException(
+ throw new IllegalStateException(
format("Error - getInstance() failed for %s in transaction %s",
name, getTransactionIdentifier()), e);
}
*/
package org.opendaylight.controller.config.manager.impl;
-import javax.annotation.Nullable;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
-import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator
- .TransactionModuleJMXRegistration;
+import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator.TransactionModuleJMXRegistration;
import org.opendaylight.controller.config.spi.Module;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.yangtools.concepts.Identifiable;
+import javax.annotation.Nullable;
+
public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
private final ModuleIdentifier name;
private final Module module;
private final boolean isDefaultBean;
ModuleInternalTransactionalInfo(ModuleIdentifier name, Module module,
- ModuleFactory moduleFactory,
- ModuleInternalInfo maybeOldInternalInfo,
- TransactionModuleJMXRegistration transactionModuleJMXRegistration,
- boolean isDefaultBean) {
+ ModuleFactory moduleFactory,
+ ModuleInternalInfo maybeOldInternalInfo,
+ TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+ boolean isDefaultBean) {
this.name = name;
this.module = module;
this.moduleFactory = moduleFactory;
@Nullable
public ModuleInternalInfo getOldInternalInfo() {
- if (maybeOldInternalInfo == null)
+ if (maybeOldInternalInfo == null) {
throw new NullPointerException();
+ }
return maybeOldInternalInfo;
}
this.serviceReferenceRegistrator = serviceReferenceRegistratorFactory.create();
- Map<String, Set<String /* QName */>> factoryNamesToQNames = new HashMap<>();
+ Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
Set<String /* qName */> allQNames = new HashSet<>();
for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
}
allAnnotations.addAll(siAnnotations);
allQNames.addAll(qNames);
- factoryNamesToQNames.put(entry.getKey(), Collections.unmodifiableSet(qNames));
+ modifiableFactoryNamesToQNames.put(entry.getKey(), Collections.unmodifiableSet(qNames));
}
- this.factoryNamesToQNames = Collections.unmodifiableMap(factoryNamesToQNames);
+ this.factoryNamesToQNames = Collections.unmodifiableMap(modifiableFactoryNamesToQNames);
this.allQNames = Collections.unmodifiableSet(allQNames);
// fill namespacesToAnnotations
- Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> namespacesToAnnotations =
+ Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations =
new HashMap<>();
for (ServiceInterfaceAnnotation sia : allAnnotations) {
- Map<String, ServiceInterfaceAnnotation> ofNamespace = namespacesToAnnotations.get(sia.namespace());
+ Map<String, ServiceInterfaceAnnotation> ofNamespace = modifiableNamespacesToAnnotations.get(sia.namespace());
if (ofNamespace == null) {
ofNamespace = new HashMap<>();
- namespacesToAnnotations.put(sia.namespace(), ofNamespace);
+ modifiableNamespacesToAnnotations.put(sia.namespace(), ofNamespace);
}
if (ofNamespace.containsKey(sia.localName())) {
logger.error("Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
- sia.namespace(), sia.localName(), namespacesToAnnotations);
+ sia.namespace(), sia.localName(), modifiableNamespacesToAnnotations);
throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
}
ofNamespace.put(sia.localName(), sia);
}
- this.namespacesToAnnotations = Collections.unmodifiableMap(namespacesToAnnotations);
+ this.namespacesToAnnotations = Collections.unmodifiableMap(modifiableNamespacesToAnnotations);
// copy refNames
logger.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
}
@Override
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
TransactionIdentifier that = (TransactionIdentifier) o;
- if (name != null ? !name.equals(that.name) : that.name != null)
+ if (name != null ? !name.equals(that.name) : that.name != null) {
return false;
+ }
return true;
}
}
public synchronized void checkNotCommitStarted() {
- if (secondPhaseCommitStarted == true)
+ if (secondPhaseCommitStarted == true) {
throw new IllegalStateException("Commit was triggered");
+ }
}
public synchronized void checkCommitStarted() {
- if (secondPhaseCommitStarted == false)
+ if (secondPhaseCommitStarted == false) {
throw new IllegalStateException("Commit was not triggered");
+ }
}
public synchronized void checkNotAborted() {
- if (aborted == true)
+ if (aborted == true) {
throw new IllegalStateException("Configuration was aborted");
+ }
}
public synchronized void checkNotCommitted() {
* during validation. Tracks dependencies for ordering purposes.
*/
final class DependencyResolverImpl implements DependencyResolver,
- Comparable<DependencyResolverImpl> {
+ Comparable<DependencyResolverImpl> {
private static final Logger logger = LoggerFactory.getLogger(DependencyResolverImpl.class);
private final ModulesHolder modulesHolder;
throw new NullPointerException(
"Parameter 'expectedServiceInterface' is null");
}
- if (jmxAttribute == null)
+ if (jmxAttribute == null) {
throw new NullPointerException("Parameter 'jmxAttribute' is null");
+ }
JmxAttributeValidationException.checkNotNull(dependentReadOnlyON,
"is null, expected dependency implementing "
+ expectedServiceInterface, jmxAttribute);
-
// check that objectName belongs to this transaction - this should be
// stripped
// in DynamicWritableWrapper
//TODO: check for cycles
@Override
public <T> T resolveInstance(Class<T> expectedType, ObjectName dependentReadOnlyON,
- JmxAttribute jmxAttribute) {
+ JmxAttribute jmxAttribute) {
if (expectedType == null || dependentReadOnlyON == null || jmxAttribute == null) {
throw new IllegalArgumentException(format(
"Null parameters not allowed, got %s %s %s", expectedType,
throw new JmxAttributeValidationException(message, jmxAttribute);
}
try {
- T result = expectedType.cast(instance);
- return result;
+ return expectedType.cast(instance);
} catch (ClassCastException e) {
String message = format(
"Instance cannot be cast to expected type. Instance class is %s , "
IdentityCodec<?> identityCodec = codecRegistry.getIdentityCodec();
Class<? extends BaseIdentity> deserialized = identityCodec.deserialize(qName);
if (deserialized == null) {
- throw new RuntimeException("Unable to retrieve identity class for " + qName + ", null response from "
+ throw new IllegalStateException("Unable to retrieve identity class for " + qName + ", null response from "
+ codecRegistry);
}
if (expectedBaseClass.isAssignableFrom(deserialized)) {
public <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass, JmxAttribute jmxAttribute) {
try {
resolveIdentity(identityRef, expectedBaseClass);
- } catch(Exception e) {
+ } catch (Exception e) {
throw JmxAttributeValidationException.wrap(e, jmxAttribute);
}
}
}
private static int getMaxDepth(DependencyResolverImpl impl,
- DependencyResolverManager manager,
- LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
+ DependencyResolverManager manager,
+ LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
int maxDepth = 0;
LinkedHashSet<ModuleIdentifier> chainForDetectingCycles2 = new LinkedHashSet<>(
chainForDetectingCycles);
* requests (getAttribute, setAttribute, invoke) into the actual instance, but
* provides additional functionality - namely it disallows setting attribute on
* a read only wrapper.
- *
*/
abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
private static final Logger logger = LoggerFactory
protected final MBeanServer internalServer;
public AbstractDynamicWrapper(Module module, boolean writable,
- ModuleIdentifier moduleIdentifier,
- ObjectName thisWrapperObjectName, MBeanOperationInfo[] dOperations,
- MBeanServer internalServer, MBeanServer configMBeanServer) {
+ ModuleIdentifier moduleIdentifier,
+ ObjectName thisWrapperObjectName, MBeanOperationInfo[] dOperations,
+ MBeanServer internalServer, MBeanServer configMBeanServer) {
this.writable = writable;
this.module = module;
* case unregister the module and remove listener.
*/
private final NotificationListener registerActualModule(Module module,
- final ObjectName thisWrapperObjectName,
- final ObjectName objectNameInternal,
- final MBeanServer internalServer,
- final MBeanServer configMBeanServer) {
+ final ObjectName thisWrapperObjectName,
+ final ObjectName objectNameInternal,
+ final MBeanServer internalServer,
+ final MBeanServer configMBeanServer) {
try {
internalServer.registerMBean(module, objectNameInternal);
public void handleNotification(Notification n, Object handback) {
if (n instanceof MBeanServerNotification
&& n.getType()
- .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
+ .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
if (((MBeanServerNotification) n).getMBeanName().equals(
thisWrapperObjectName)) {
try {
}
private static MBeanInfo generateMBeanInfo(String className, Module module,
- Map<String, AttributeHolder> attributeHolderMap,
- MBeanOperationInfo[] dOperations, Set<Class<?>> jmxInterfaces) {
+ Map<String, AttributeHolder> attributeHolderMap,
+ MBeanOperationInfo[] dOperations, Set<Class<?>> jmxInterfaces) {
String dDescription = findDescription(module.getClass(), jmxInterfaces);
MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[0];
// inspect all exported interfaces ending with MXBean, extract getters &
// setters into attribute holder
private static Map<String, AttributeHolder> buildMBeanInfo(Module module,
- boolean writable, ModuleIdentifier moduleIdentifier,
- Set<Class<?>> jmxInterfaces, MBeanServer internalServer,
- ObjectName internalObjectName) {
+ boolean writable, ModuleIdentifier moduleIdentifier,
+ Set<Class<?>> jmxInterfaces, MBeanServer internalServer,
+ ObjectName internalObjectName) {
// internal variables for describing MBean elements
Set<Method> methods = new HashSet<>();
}
AttributeHolder attributeHolder = new AttributeHolder(
attribName, module, attributeMap.get(attribName)
- .getType(), writable, ifc, description);
+ .getType(), writable, ifc, description);
attributeHolderMap.put(attribName, attributeHolder);
}
}
}
- if(isDependencyListAttr(attributeName, obj)) {
+ if (isDependencyListAttr(attributeName, obj)) {
obj = fixDependencyListAttribute(obj);
}
}
private Object fixDependencyListAttribute(Object attribute) {
- if(attribute.getClass().isArray() == false)
+ if (attribute.getClass().isArray() == false) {
throw new IllegalArgumentException("Unexpected attribute type, should be an array, but was " + attribute.getClass());
+ }
for (int i = 0; i < Array.getLength(attribute); i++) {
Object on = Array.get(attribute, i);
- if(on instanceof ObjectName == false)
+ if (on instanceof ObjectName == false) {
throw new IllegalArgumentException("Unexpected attribute type, should be an ObjectName, but was " + on.getClass());
+ }
on = fixObjectName((ObjectName) on);
Array.set(attribute, i, on);
}
private boolean isDependencyListAttr(String attributeName, Object attribute) {
- if (attributeHolderMap.containsKey(attributeName) == false)
+ if (attributeHolderMap.containsKey(attributeName) == false) {
return false;
+ }
AttributeHolder attributeHolder = attributeHolderMap.get(attributeName);
}
protected ObjectName fixObjectName(ObjectName on) {
- if (!ObjectNameUtil.ON_DOMAIN.equals(on.getDomain()))
+ if (!ObjectNameUtil.ON_DOMAIN.equals(on.getDomain())) {
throw new IllegalArgumentException("Wrong domain, expected "
+ ObjectNameUtil.ON_DOMAIN + " setter on " + on);
+ }
// if on contains transaction name, remove it
String transactionName = ObjectNameUtil.getTransactionName(on);
- if (transactionName != null)
+ if (transactionName != null) {
return ObjectNameUtil.withoutTransactionName(on);
- else
+ } else {
return on;
+ }
}
@Override
*/
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
+import org.opendaylight.controller.config.api.annotations.Description;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.opendaylight.controller.config.api.annotations.Description;
-
-class AnnotationsHelper {
+public class AnnotationsHelper {
/**
* Look for annotation specified by annotationType on method. First observe
}
public AttributeHolder(String name, Object object, String returnType,
- boolean writable,
- @Nullable RequireInterface requireInterfaceAnnotation,
- String description) {
+ boolean writable,
+ @Nullable RequireInterface requireInterfaceAnnotation,
+ String description) {
if (name == null) {
throw new NullPointerException();
}
/**
* @return annotation if setter sets ObjectName or ObjectName[], and is
- * annotated. Return null otherwise.
+ * annotated. Return null otherwise.
*/
RequireInterface getRequireInterfaceOrNull() {
return requireInterfaceAnnotation;
* @param setter
* @param jmxInterfaces
* @return empty string if no annotation is found, or list of descriptions
- * separated by newline
+ * separated by newline
*/
static String findDescription(Method setter, Set<Class<?>> jmxInterfaces) {
List<Description> descriptions = AnnotationsHelper
*
* @param setter
* @param inspectedInterfaces
- * @throws IllegalStateException
- * if more than one value is specified by found annotations
- * @throws IllegalArgumentException
- * if set of exported interfaces contains non interface type
* @return null if no annotation is found, otherwise return the annotation
+ * @throws IllegalStateException if more than one value is specified by found annotations
+ * @throws IllegalArgumentException if set of exported interfaces contains non interface type
*/
static RequireInterface findRequireInterfaceAnnotation(final Method setter,
- Set<Class<?>> inspectedInterfaces) {
+ Set<Class<?>> inspectedInterfaces) {
// only allow setX(ObjectName y) or setX(ObjectName[] y) or setX(List<ObjectName> y) to continue
- if (setter.getParameterTypes().length > 1)
+ if (setter.getParameterTypes().length > 1) {
return null;
- if(PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.contains(setter.getParameterTypes()[0]) == false)
+ }
+ if (PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.contains(setter.getParameterTypes()[0]) == false) {
return null;
+ }
List<RequireInterface> foundRequireInterfaces = AnnotationsHelper
.findMethodAnnotationInSuperClassesAndIfcs(setter, RequireInterface.class, inspectedInterfaces);
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.util.Map.Entry;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Collections;
+import java.util.Map.Entry;
+import java.util.Set;
import java.util.TreeSet;
-import java.util.Collection;
-import java.util.ArrayList;
/**
* Hold sorted ConfigMBeanFactories by their module names. Check that module
* names are globally unique.
*/
public class HierarchicalConfigMBeanFactoriesHolder {
- private static final Logger logger = LoggerFactory
- .getLogger(HierarchicalConfigMBeanFactoriesHolder.class);
private final Map<String, Map.Entry<ModuleFactory, BundleContext>> moduleNamesToConfigBeanFactories;
private final Set<String> moduleNames;
*/
package org.opendaylight.controller.config.manager.impl.jmx;
-import java.io.Closeable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.annotation.concurrent.GuardedBy;
import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
import javax.management.JMX;
+import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.QueryExp;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
public class InternalJMXRegistrator implements Closeable {
private static final Logger logger = LoggerFactory
private final ObjectName on;
InternalJMXRegistration(InternalJMXRegistrator internalJMXRegistrator,
- ObjectName on) {
+ ObjectName on) {
this.internalJMXRegistrator = internalJMXRegistrator;
this.on = on;
}
private final List<InternalJMXRegistrator> children = new ArrayList<>();
public synchronized InternalJMXRegistration registerMBean(Object object,
- ObjectName on) throws InstanceAlreadyExistsException {
+ ObjectName on) throws InstanceAlreadyExistsException {
try {
configMBeanServer.registerMBean(object, on);
- } catch (InstanceAlreadyExistsException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (MBeanRegistrationException | NotCompliantMBeanException e) {
+ throw new IllegalStateException(e);
}
registeredObjectNames.add(on);
return new InternalJMXRegistration(this, on);
private synchronized void unregisterMBean(ObjectName on) {
// first check that on was registered using this instance
boolean removed = registeredObjectNames.remove(on);
- if (!removed)
- throw new IllegalStateException(
- "Cannot unregister - ObjectName not found in 'registeredObjectNames': "
- + on);
+ if (!removed) {
+ throw new IllegalStateException("Cannot unregister - ObjectName not found in 'registeredObjectNames': " + on);
+ }
try {
configMBeanServer.unregisterMBean(on);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (InstanceNotFoundException | MBeanRegistrationException e) {
+ throw new IllegalStateException(e);
}
}
}
public <T> T newMBeanProxy(ObjectName objectName, Class<T> interfaceClass,
- boolean notificationBroadcaster) {
+ boolean notificationBroadcaster) {
return JMX.newMBeanProxy(configMBeanServer, objectName, interfaceClass,
notificationBroadcaster);
}
}
public <T> T newMXBeanProxy(ObjectName objectName, Class<T> interfaceClass,
- boolean notificationBroadcaster) {
+ boolean notificationBroadcaster) {
return JMX.newMXBeanProxy(configMBeanServer, objectName,
interfaceClass, notificationBroadcaster);
}
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
ServiceReference that = (ServiceReference) o;
- if (!refName.equals(that.refName)) return false;
- if (!serviceInterfaceName.equals(that.serviceInterfaceName)) return false;
+ if (!refName.equals(that.refName)) {
+ return false;
+ }
+ if (!serviceInterfaceName.equals(that.serviceInterfaceName)) {
+ return false;
+ }
return true;
}
*/
package org.opendaylight.controller.config.manager.impl.jmx;
-import java.io.Closeable;
-import java.util.Set;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.manager.impl.jmx.InternalJMXRegistrator.InternalJMXRegistration;
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
import javax.management.QueryExp;
-
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.jmx.InternalJMXRegistrator.InternalJMXRegistration;
+import java.io.Closeable;
+import java.util.Set;
/**
* Contains constraints on passed {@link ObjectName} parameters. Only allow (un)
private final String transactionName;
TransactionJMXRegistrator(InternalJMXRegistrator internalJMXRegistrator,
- String transactionName) {
+ String transactionName) {
this.childJMXRegistrator = internalJMXRegistrator.createChild();
this.transactionName = transactionName;
}
public TransactionJMXRegistration registerMBean(Object object, ObjectName on)
throws InstanceAlreadyExistsException {
- if (!transactionName.equals(ObjectNameUtil.getTransactionName(on)))
+ if (!transactionName.equals(ObjectNameUtil.getTransactionName(on))) {
throw new IllegalArgumentException(
"Transaction name mismatch between expected "
+ transactionName + " " + "and " + on);
+ }
ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_CONFIG_TRANSACTION);
return new TransactionJMXRegistration(
childJMXRegistrator.registerMBean(object, on));
if(factory == null) {
throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found.");
}
- StringBuffer errors = new StringBuffer();
+
String moduleName = factory.getImplementationName();
if (moduleName == null || moduleName.isEmpty()) {
throw new IllegalStateException(
throw new NullPointerException("Bundle context of " + factory + " ModuleFactory not found.");
}
logger.debug("Reading factory {} {}", moduleName, factory);
- String error = null;
+
Map.Entry<ModuleFactory, BundleContext> conflicting = result.get(moduleName);
if (conflicting != null) {
- error = String
- .format("Module name is not unique. Found two conflicting factories with same name '%s': " +
- "\n\t%s\n\t%s\n", moduleName, conflicting.getKey(), factory);
-
- }
-
- if (error == null) {
+ String error = String
+ .format("Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
+ moduleName, conflicting.getKey(), factory);
+ logger.error(error);
+ throw new IllegalArgumentException(error);
+ } else {
result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
serviceReference.getBundle().getBundleContext()));
- } else {
- errors.append(error);
- }
- if (errors.length() > 0) {
- throw new IllegalArgumentException(errors.toString());
}
}
return result;
private RuntimeGeneratedMappingServiceActivator mappingServiceActivator;
@Override
- public void start(BundleContext context) throws Exception {
+ public void start(BundleContext context) {
// track bundles containing YangModuleInfo
ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker();
try {
configRegistryJMXRegistrator.registerToJMX(configRegistry);
} catch (InstanceAlreadyExistsException e) {
- throw new RuntimeException("Config Registry was already registered to JMX", e);
+ throw new IllegalStateException("Config Registry was already registered to JMX", e);
}
ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
}
@Override
- public void stop(BundleContext context) throws Exception {
+ public void stop(BundleContext context) {
try {
configRegistry.close();
} catch (Exception e) {
ftlFile.getFtlTempleteLocation());
try {
template.process(ftlFile, writer);
- } catch (Throwable e) {
+ } catch (Exception e) {
throw new IllegalStateException(
"Template error while generating " + ftlFile, e);
}
boolean providedServiceWasSet = false;
for (UnknownSchemaNode unknownNode : id.getUnknownSchemaNodes()) {
// TODO: test this
- if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
- // no op: 0 or more provided identities are allowed
- } else if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
+ boolean unknownNodeIsProvidedServiceExtension = ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType());
+ // true => no op: 0 or more provided identities are allowed
+
+ if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
// 0..1 allowed
checkState(
providedServiceWasSet == false,
format("More than one language extension %s is not allowed here: %s",
ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME, id));
providedServiceWasSet = true;
- } else {
+ } else if (unknownNodeIsProvidedServiceExtension == false) {
throw new IllegalStateException("Unexpected language extension " + unknownNode.getNodeType());
}
}
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@Override
public CompositeType getOpenType() {
- String description = getNullableDescription() == null ? getAttributeYangName()
- : getNullableDescription();
- final String[] itemNames = new String[yangNameToAttributeMap.keySet()
- .size()];
- String[] itemDescriptions = itemNames;
- FunctionImpl functionImpl = new FunctionImpl(itemNames);
+ String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+
+ FunctionImpl functionImpl = new FunctionImpl();
Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
OpenType<?>[] itemTypes = Collections2.transform(
jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(
new OpenType<?>[] {});
+ String[] itemNames = functionImpl.getItemNames();
try {
// TODO add package name to create fully qualified name for this
// type
CompositeType compositeType = new CompositeType(
getUpperCaseCammelCase(), description, itemNames,
- itemDescriptions, itemTypes);
+ itemNames, itemTypes);
return compositeType;
} catch (OpenDataException e) {
throw new RuntimeException("Unable to create CompositeType for "
return packageName;
}
- private static final class FunctionImpl implements
- Function<Entry<String, AttributeIfc>, OpenType<?>> {
- private final String[] itemNames;
- int i = 0;
+}
- private FunctionImpl(String[] itemNames) {
- this.itemNames = itemNames;
- }
+class FunctionImpl implements
+ Function<Entry<String, AttributeIfc>, OpenType<?>> {
+ private final List<String> itemNames = new ArrayList<>();
- @Override
- public OpenType<?> apply(Entry<String, AttributeIfc> input) {
- AttributeIfc innerType = input.getValue();
- itemNames[i++] = input.getKey();
- return innerType.getOpenType();
- }
+ @Override
+ public OpenType<?> apply(Entry<String, AttributeIfc> input) {
+ AttributeIfc innerType = input.getValue();
+ itemNames.add(input.getKey());
+ return innerType.getOpenType();
+ }
+
+ public String[] getItemNames(){
+ return itemNames.toArray(new String[itemNames.size()]);
}
}
@Override
public java.lang.AutoCloseable createInstance() {
- System.err.println(getAfi());
- System.err.println(getAfiIdentity());
+ org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
+ logger.info("Afi: {}", getAfi());
+ logger.info("Afi class: {}", getAfiIdentity());
- getAfiIdentity();
for (Identities identities : getIdentities()) {
- identities.resolveAfi();
- identities.resolveSafi();
+ logger.info("Identities Afi class: {}", identities.resolveAfi());
+ logger.info("Identities Safi class: {}", identities.resolveSafi());
+
}
- getIdentitiesContainer().resolveAfi();
+ logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi());
return new AutoCloseable() {
@Override
- System.err.println(getAfi());
- System.err.println(getAfiIdentity());
+ org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
+ logger.info("Afi: {}", getAfi());
+ logger.info("Afi class: {}", getAfiIdentity());
- getAfiIdentity();
for (Identities identities : getIdentities()) {
- identities.resolveAfi();
- identities.resolveSafi();
+ logger.info("Identities Afi class: {}", identities.resolveAfi());
+ logger.info("Identities Safi class: {}", identities.resolveSafi());
+
}
- getIdentitiesContainer().resolveAfi();
+ logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi());
return new AutoCloseable() {
@Override
fi
function usage {
- echo "Usage: $0 [-jmx] [-jmxport <num>] [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [<other args will automatically be used for the JVM>]"
+ echo "Usage: $0 [-jmx] [-jmxport <num>] [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [-agentpath:<path to lib>] [<other args will automatically be used for the JVM>]"
exit 1
}
consolestart=1
dohelp=0
extraJVMOpts=""
+agentPath=""
unknown_option=0
while true ; do
case "$1" in
-help) dohelp=1; shift;;
-D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
-X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
+ -agentpath:*) agentPath="$1"; shift;;
"") break ;;
*) echo "Unknown option $1"; unknown_option=1; shift ;;
esac
exit -1
fi
$JAVA_HOME/bin/java ${extraJVMOpts} \
+ ${agentPath} \
-Djava.io.tmpdir="${iotmpdir}/work/tmp" \
-Dosgi.install.area="${bdir}" \
-Dosgi.configuration.area="${confarea}/configuration" \
exit -1
fi
$JAVA_HOME/bin/java ${extraJVMOpts} \
+ ${agentPath} \
-Djava.io.tmpdir="${iotmpdir}/work/tmp" \
-Dosgi.install.area="${bdir}" \
-Dosgi.configuration.area="${confarea}/configuration" \
<!-- Dependency Versions -->
<mockito.version>1.9.5</mockito.version>
- <xtend.version>2.4.3</xtend.version>
+
<!-- Sonar properties using jacoco to retrieve integration test results -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- <version>${xtend.version}</version>
- </dependency>
+
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<dependencies>
+ <!--Compile scopes for all testing dependencies are intentional-->
+ <!--This way, all testing dependencies can be transitively used by other integration test modules-->
+ <!--If the dependencies are test scoped, they are not visible to other maven modules depending on sal-binding-it-->
+ <!--TODO Create generic utilities(extract from this module) for integration tests on the controller-->
<dependency>
<groupId>org.opendaylight.yangtools.thirdparty</groupId>
<artifactId>xtend-lib-osgi</artifactId>
<version>2.4.3</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-broker-impl</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-netconf-connector</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>org.eclipse.osgi</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.model</groupId>
/**
* Core component of the SAL layer responsible for wiring the SAL consumers.
- *
+ *
* The responsibility of the broker is to maintain registration of SAL
* functionality {@link Consumer}s and {@link Provider}s, store provider and
* consumer specific context and functionality registration via
* {@link ConsumerSession} and provide access to infrastructure services, which
* removes direct dependencies between providers and consumers.
- *
- *
+ *
+ *
* <h3>Infrastructure services</h3> Some examples of infrastructure services:
- *
+ *
* <ul>
* <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},
* {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and
* <li>Data Store access and modification - see {@link DataBrokerService} and
* {@link DataProviderService}
* </ul>
- *
+ *
* The services are exposed via session.
- *
+ *
* <h3>Session-based access</h3>
- *
+ *
* The providers and consumers needs to register in order to use the
* binding-independent SAL layer and to expose functionality via SAL layer.
- *
+ *
* For more information about session-based access see {@link ConsumerSession}
* and {@link ProviderSession}
- *
- *
- *
+ *
+ *
+ *
*/
public interface Broker {
/**
* Registers the {@link Consumer}, which will use the SAL layer.
- *
+ *
* <p>
* During the registration, the broker obtains the initial functionality
* from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
* register that functionality into system and concrete infrastructure
* services.
- *
+ *
* <p>
* Note that consumer could register additional functionality at later point
* by using service and functionality specific APIs.
- *
+ *
* <p>
* The consumer is required to use returned session for all communication
* with broker or one of the broker services. The session is announced to
* the consumer by invoking
* {@link Consumer#onSessionInitiated(ConsumerSession)}.
- *
+ *
* @param cons
* Consumer to be registered.
* @param context
/**
* Registers the {@link Provider}, which will use the SAL layer.
- *
+ *
* <p>
* During the registration, the broker obtains the initial functionality
* from consumer, using the {@link Provider#getProviderFunctionality()}, and
* register that functionality into system and concrete infrastructure
* services.
- *
+ *
* <p>
* Note that consumer could register additional functionality at later point
* by using service and functionality specific APIs (e.g.
* {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
- *
+ *
* <p>
* The consumer is <b>required to use</b> returned session for all
* communication with broker or one of the broker services. The session is
* announced to the consumer by invoking
* {@link Provider#onSessionInitiated(ProviderSession)}.
- *
- *
+ *
+ *
* @param prov
* Provider to be registered.
* @param context
/**
* {@link Consumer} specific access to the SAL functionality.
- *
+ *
* <p>
* ConsumerSession is {@link Consumer}-specific access to the SAL
* functionality and infrastructure services.
- *
+ *
* <p>
* The session serves to store SAL context (e.g. registration of
* functionality) for the consumer and provides access to the SAL
* infrastructure services and other functionality provided by
* {@link Provider}s.
- *
- *
- *
+ *
+ *
+ *
*/
public interface ConsumerSession {
/**
* Sends an RPC to other components registered to the broker.
- *
+ *
* @see RpcImplementation
* @param rpc
* Name of RPC
/**
* Returns a session specific instance (implementation) of requested
* service
- *
+ *
* @param service
* Broker service
* @return Session specific implementation of service
/**
* Closes a session between consumer and broker.
- *
+ *
* <p>
* The close operation unregisters a consumer and remove all registered
* functionality of the consumer from the system.
- *
+ *
*/
void close();
}
/**
* {@link Provider} specific access to the SAL functionality.
- *
+ *
* <p>
* ProviderSession is {@link Provider}-specific access to the SAL
* functionality and infrastructure services, which also allows for exposing
* the provider's functionality to the other {@link Consumer}s.
- *
+ *
* <p>
* The session serves to store SAL context (e.g. registration of
* functionality) for the providers and exposes access to the SAL
* infrastructure services, dynamic functionality registration and any other
* functionality provided by other {@link Provider}s.
- *
+ *
*/
public interface ProviderSession extends ConsumerSession {
/**
* Registers an implementation of the rpc.
- *
+ *
* <p>
* The registered rpc functionality will be available to all other
* consumers and providers registered to the broker, which are aware of
* the {@link QName} assigned to the rpc.
- *
+ *
* <p>
* There is no assumption that rpc type is in the set returned by
* invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
* for dynamic rpc implementations.
- *
+ *
* @param rpcType
* Name of Rpc
* @param implementation
/**
* Closes a session between provider and SAL.
- *
+ *
* <p>
* The close operation unregisters a provider and remove all registered
* functionality of the provider from the system.
boolean isClosed();
Set<QName> getSupportedRpcs();
-
+
ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener);
}
public interface RpcRegistration extends Registration<RpcImplementation> {
QName getType();
+
+ @Override
+ void close();
}
public interface RoutedRpcRegistration extends RpcRegistration,
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.restconf.broker.client;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+
+public interface SalRemoteClient extends AutoCloseable {
+
+ ConsumerContext registerConsumer();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.restconf.broker.client;
+
+import java.net.URL;
+
+public class SalRemoteClientDeployer {
+
+ public static SalRemoteClient createSalRemoteClient(final URL url) {
+ return new SalRemoteClientImpl(url);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.restconf.broker.client;
+
+import java.net.URL;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.restconf.broker.SalRemoteServiceBroker;
+import org.opendaylight.yangtools.restconf.client.RestconfClientFactory;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
+import org.opendaylight.yangtools.restconf.client.api.UnsupportedProtocolException;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+class SalRemoteClientImpl implements SalRemoteClient {
+
+ private static final Logger logger = LoggerFactory.getLogger(SalRemoteClientImpl.class);
+
+ private final RestconfClientContext restconfClientContext;
+ private final SalRemoteServiceBroker salRemoteBroker;
+ private final RuntimeGeneratedMappingServiceImpl mappingService;
+
+ public SalRemoteClientImpl(final URL url) {
+ Preconditions.checkNotNull(url);
+
+ this.mappingService = new RuntimeGeneratedMappingServiceImpl();
+ this.mappingService.setPool(ClassPool.getDefault());
+ this.mappingService.init();
+
+ final ModuleInfoBackedContext moduleInfo = ModuleInfoBackedContext.create();
+ moduleInfo.addModuleInfos(BindingReflections.loadModuleInfos());
+ this.mappingService.onGlobalContextUpdated(moduleInfo.tryToCreateSchemaContext().get());
+
+ try {
+ this.restconfClientContext = new RestconfClientFactory().getRestconfClientContext(url, this.mappingService,
+ this.mappingService);
+
+ this.salRemoteBroker = new SalRemoteServiceBroker("remote-broker", restconfClientContext);
+ this.salRemoteBroker.start();
+ } catch (UnsupportedProtocolException e) {
+ logger.error("Unsupported protocol {}.", url.getProtocol(), e);
+ throw new IllegalArgumentException("Unsupported protocol.", e);
+ }
+ }
+
+ @Override
+ public ConsumerContext registerConsumer() {
+ return this.salRemoteBroker.registerConsumer(new BindingAwareConsumer() {
+
+ @Override
+ public void onSessionInitialized(ConsumerContext session) {
+ }
+ }, null);
+ }
+
+ @Override
+ public void close() throws Exception {
+ this.restconfClientContext.close();
+ this.salRemoteBroker.close();
+ }
+
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext,streamName);
ListenableEventStreamContext restConfListenableEventStreamContext = restconfClientContext.getEventStreamContext(desiredEventStream.get(streamName));
RemoteDataChangeNotificationListener remoteDataChangeNotificationListener = new RemoteDataChangeNotificationListener(listener);
- restConfListenableEventStreamContext.registerNotificationListener(remoteDataChangeNotificationListener);
- return new SalRemoteDataListenerRegistration(listener);
- }
-
- private class SalRemoteDataListenerRegistration implements ListenerRegistration<DataChangeListener> {
- private final DataChangeListener dataChangeListener;
- public SalRemoteDataListenerRegistration(DataChangeListener dataChangeListener){
- this.dataChangeListener = dataChangeListener;
- }
- @Override
- public DataChangeListener getInstance() {
- return this.dataChangeListener;
- }
- @Override
- public void close() {
- //noop
- }
+ final ListenerRegistration<?> reg = restConfListenableEventStreamContext.registerNotificationListener(remoteDataChangeNotificationListener);
+ return new AbstractListenerRegistration<DataChangeListener>(listener) {
+ @Override
+ protected void removeRegistration() {
+ reg.close();
+ }
+ };
}
}
<artifactId>yang-store-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>yang-test</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-api</artifactId>
<artifactId>netconf-monitoring</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-it</artifactId>
+ <version>${mdsal.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-mapping-api</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-test</artifactId>
+ <version>${config.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>yang-store-impl</artifactId>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>maven-paxexam-plugin</artifactId>
+ <version>1.2.4</version>
+ <executions>
+ <execution>
+ <id>generate-config</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.netconf.it.pax;
+
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import javax.inject.Inject;
+import javax.xml.parsers.ParserConfigurationException;
+
+import com.google.common.base.Preconditions;
+import io.netty.channel.nio.NioEventLoopGroup;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.matchers.JUnitMatchers;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.client.NetconfClient;
+import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.util.Filter;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+@RunWith(PaxExam.class)
+public class IdentityRefNetconfTest {
+
+ public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 5000;
+
+ // Wait for controller to start
+ @Inject
+ @Filter(timeout = 60 * 1000)
+ BindingAwareBroker broker;
+
+ @Configuration
+ public Option[] config() {
+ return options(
+ systemProperty("osgi.console").value("2401"),
+ systemProperty("osgi.bundles.defaultStartLevel").value("4"),
+ systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+
+ testingModules(),
+ loggingModules(),
+ mdSalCoreBundles(),
+ bindingAwareSalBundles(), configMinumumBundles(), baseModelBundles(), flowCapableModelBundles(),
+ junitAndMockitoBundles());
+ }
+
+ private Option loggingModules() {
+ return new DefaultCompositeOption(
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+ mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject());
+ }
+
+ private Option testingModules() {
+ return new DefaultCompositeOption(
+ mavenBundle("org.opendaylight.controller", "yang-test").versionAsInProject());
+ }
+
+ private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 18383);
+
+ @Test
+ public void testIdRef() throws Exception {
+ Preconditions.checkNotNull(broker, "Controller not initialized");
+
+ NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup();
+ NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup,
+ CLIENT_CONNECTION_TIMEOUT_MILLIS);
+
+ NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
+ NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml");
+ NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
+
+ try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) {
+ sendMessage(edit, netconfClient);
+ sendMessage(commit, netconfClient);
+ sendMessage(getConfig, netconfClient, "id-test",
+ "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>",
+ "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>",
+ "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>",
+ "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>");
+ }
+
+ clientDispatcher.close();
+ }
+
+ private void sendMessage(NetconfMessage edit, NetconfClient netconfClient, String... containingResponse)
+ throws ExecutionException, InterruptedException, TimeoutException {
+ NetconfMessage response = netconfClient.sendRequest(edit).get();
+ if (containingResponse == null) {
+ Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<ok/>"));
+ } else {
+ for (String resp : containingResponse) {
+ Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString(resp));
+ }
+ }
+ }
+
+ public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
+ ParserConfigurationException {
+ return new NetconfMessage(xmlFileToDocument(fileName));
+ }
+
+ public static Document xmlFileToDocument(final String fileName) throws IOException, SAXException,
+ ParserConfigurationException {
+ // TODO xml messages from netconf-util test-jar cannot be loaded here(in OSGi), since test jar is not a bundle
+ try (InputStream resourceAsStream = IdentityRefNetconfTest.class.getClassLoader().getResourceAsStream(fileName)) {
+ Preconditions.checkNotNull(resourceAsStream);
+ final Document doc = XmlUtil.readXmlToDocument(resourceAsStream);
+ return doc;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<persisted-snapshots>
+ <snapshots>
+ <snapshot>
+ <required-capabilities>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config:test:types?module=test-types&revision=2013-11-27</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:test:impl?module=config-test-impl&revision=2013-04-03</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:test?module=config-test&revision=2013-06-13</capability>
+ </required-capabilities>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:impl-identity-test</type>
+ <name>id-test</name>
+ <identities-container xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+ </identities-container>
+ <identities xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+ <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</safi>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+ </identities>
+ <identities xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+ <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</safi>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+ </identities>
+ <afi xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl" xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
+ <name>binding-broker-impl</name>
+ <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+ <name>ref_binding-notification-broker</name>
+ </notification-service>
+ <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+ <name>ref_binding-data-broker</name>
+ </data-broker>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
+ <name>runtime-mapping-singleton</name>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
+ <name>binding-notification-broker</name>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
+ <name>binding-data-broker</name>
+ <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+ <name>ref_dom-broker</name>
+ </dom-broker>
+ <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+ <name>ref_runtime-mapping-singleton</name>
+ </mapping-service>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:logback:config">prefix:logback</type>
+ <name>singleton</name>
+ <console-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+ <threshold-filter>DEBUG</threshold-filter>
+ <name>console</name>
+ <encoder-pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</encoder-pattern>
+ </console-appenders>
+ <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+ <level>DEBUG</level>
+ <logger-name>ROOT</logger-name>
+ <appenders>console</appenders>
+ </loggers>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
+ <name>yang-schema-service</name>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
+ <name>hash-map-data-store</name>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
+ <name>dom-broker</name>
+ <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-data-store</type>
+ <name>ref_hash-map-data-store</name>
+ </data-store>
+ </module>
+ </modules>
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+ <instance>
+ <name>ref_yang-schema-service</name>
+ <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-data-store</type>
+ <instance>
+ <name>ref_hash-map-data-store</name>
+ <provider>/modules/module[type='hash-map-data-store'][name='hash-map-data-store']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+ <instance>
+ <name>ref_dom-broker</name>
+ <provider>/modules/module[type='dom-broker-impl'][name='dom-broker']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test">prefix:testing</type>
+ <instance>
+ <name>ref_id-test</name>
+ <provider>/modules/module[type='impl-identity-test'][name='id-test']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+ <instance>
+ <name>ref_runtime-mapping-singleton</name>
+ <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-consumer-broker</type>
+ <instance>
+ <name>ref_binding-data-broker</name>
+ <provider>/modules/module[type='binding-data-broker'][name='binding-data-broker']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry</type>
+ <instance>
+ <name>ref_binding-broker-impl</name>
+ <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+ <instance>
+ <name>ref_binding-notification-broker</name>
+ <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
+ <instance>
+ <name>ref_binding-broker-impl</name>
+ <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-subscription-service</type>
+ <instance>
+ <name>ref_binding-notification-broker</name>
+ <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+ <instance>
+ <name>ref_binding-data-broker</name>
+ <provider>/modules/module[type='binding-data-broker'][name='binding-data-broker']</provider>
+ </instance>
+ </service>
+ </services>
+ </data>
+ </configuration>
+ </snapshot>
+ </snapshots>
+</persisted-snapshots>
--- /dev/null
+<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+ <commit></commit>
+</rpc>
--- /dev/null
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+<edit-config>
+ <target>
+ <candidate/>
+ </target>
+ <test-option>
+ set
+ </test-option>
+ <default-operation>merge</default-operation>
+ <config>
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:test-impl="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+ test-impl:impl-identity-test
+ </type>
+ <name>id-test</name>
+ <identities>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+ <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</safi>
+ </identities>
+ <identities>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+ <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</safi>
+ </identities>
+ <identities-container>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+ </identities-container>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+ </module>
+ </modules>
+
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+
+ </services>
+ </config>
+</edit-config>
+</rpc>
--- /dev/null
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+ <get-config>
+ <source>
+ <running/>
+ </source>
+ </get-config>
+</rpc>