import java.util.List;
import java.util.Set;
-
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
package org.opendaylight.controller.config.api;
import java.util.Set;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
package org.opendaylight.controller.config.api;
import javax.management.DynamicMBean;
-
import org.opendaylight.controller.config.spi.Module;
/**
*/
package org.opendaylight.controller.config.api;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-
import java.beans.ConstructorProperties;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
public final class IdentityAttributeRef {
*/
package org.opendaylight.controller.config.api;
+import java.util.Set;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-import java.util.Set;
public interface LookupRegistry {
*/
package org.opendaylight.controller.config.api;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
import java.util.Map;
import java.util.Set;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
public interface ServiceReferenceReadableRegistry {
*/
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;
+ recreatedInstances;
/**
* @param newInstances newly created instances
*/
package org.opendaylight.controller.config.api.jmx;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-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;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import javax.annotation.concurrent.ThreadSafe;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
/**
* Provides ObjectName creation. Each created ObjectName consists of domain that
*/
package org.opendaylight.controller.config.spi;
+import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.yangtools.concepts.Identifiable;
-import javax.annotation.concurrent.NotThreadSafe;
-
/**
* Represents one service that is to be configured. These methods need to be
*/
package org.opendaylight.controller.config.spi;
+import java.util.Set;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.DependencyResolverFactory;
import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
import org.osgi.framework.BundleContext;
-import java.util.Set;
-
/**
* Factory which creates {@link Module instances. An instance of this interface
* needs to be exported into the OSGi Service Registry. Such an instance
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
package org.opendaylight.controller.config.api;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+
public class JmxAttributeTest {
@Test
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+
import com.google.common.collect.Lists;
import java.nio.file.AccessDeniedException;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+
import org.junit.Test;
public class ModuleIdentifierTest {
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import com.google.common.collect.Lists;
import java.util.Map;
import org.junit.Assert;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import java.util.HashMap;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-
import javax.annotation.concurrent.Immutable;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule;
import org.opendaylight.controller.config.manager.impl.dependencyresolver.ModuleInternalTransactionalInfo;
package org.opendaylight.controller.config.manager.impl;
import com.google.common.collect.Maps;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import javax.annotation.concurrent.GuardedBy;
+import javax.annotation.concurrent.NotThreadSafe;
+import javax.annotation.concurrent.ThreadSafe;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.NotThreadSafe;
-import javax.annotation.concurrent.ThreadSafe;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
/**
* Singleton that is responsible for creating and committing Config
* Transactions. It is registered in Platform MBean Server.
*/
@ThreadSafe
public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBean {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConfigRegistryImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigRegistryImpl.class);
private final ModuleFactoriesResolver resolver;
private final MBeanServer configMBeanServer;
for (ModuleInternalInfo moduleInternalInfo : currentConfig.getEntries()) {
String name = moduleInternalInfo.getModuleFactory().getImplementationName();
if (allCurrentFactories.containsKey(name) == false) {
- LOGGER.trace("Factory {} not found in SR, using reference from previous commit", name);
+ LOG.trace("Factory {} not found in SR, using reference from previous commit", name);
allCurrentFactories.put(name,
Maps.immutableEntry(moduleInternalInfo.getModuleFactory(), moduleInternalInfo.getBundleContext()));
}
throws ConflictingVersionException, ValidationException {
final String transactionName = ObjectNameUtil
.getTransactionName(transactionControllerON);
- LOGGER.trace("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version, versionCounter);
+ LOG.trace("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version, versionCounter);
// find ConfigTransactionController
Map<String, Entry<ConfigTransactionControllerInternal, ConfigTransactionLookupRegistry>> transactions = transactionsHolder.getCurrentTransactions();
} catch (Error | RuntimeException t) { // some libs throw Errors: e.g.
// javax.xml.ws.spi.FactoryFinder$ConfigurationError
isHealthy = false;
- LOGGER.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
+ LOG.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else {
int orderingIdx = 0;
for (ModuleIdentifier moduleIdentifier : orderedModuleIdentifiers) {
- LOGGER.trace("Registering {}", moduleIdentifier);
+ LOG.trace("Registering {}", moduleIdentifier);
ModuleInternalTransactionalInfo entry = commitInfo.getCommitted()
.get(moduleIdentifier);
if (entry == null) {
configTransactionControllerEntry.getValue().close();
configTransactionController.abortConfig();
} catch (RuntimeException e) {
- LOGGER.warn("Ignoring exception while aborting {}",
+ LOG.warn("Ignoring exception while aborting {}",
configTransactionController, e);
}
}
ConfigTransactionControllerInternal,
ConfigTransactionControllerImplMXBean,
Identifiable<TransactionIdentifier> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConfigTransactionControllerImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigTransactionControllerImpl.class);
private final ConfigTransactionLookupRegistry txLookupRegistry;
private final ObjectName controllerON;
boolean isDefaultBean, BundleContext bundleContext)
throws InstanceAlreadyExistsException {
- LOGGER.debug("Adding module {} to transaction {}", moduleIdentifier, this);
+ LOG.debug("Adding module {} to transaction {}", moduleIdentifier, this);
if (moduleIdentifier.equals(module.getIdentifier()) == false) {
throw new IllegalStateException("Incorrect name reported by module. Expected "
+ moduleIdentifier + ", got " + module.getIdentifier());
}
private synchronized void destroyModule(ModuleIdentifier moduleIdentifier) {
- LOGGER.debug("Destroying module {} in transaction {}", moduleIdentifier, this);
+ LOG.debug("Destroying module {} in transaction {}", moduleIdentifier, this);
transactionStatus.checkNotAborted();
ModuleInternalTransactionalInfo found = dependencyResolverManager.findModuleInternalTransactionalInfo(moduleIdentifier);
if (blankTransaction == false &&
found.isDefaultBean()) {
- LOGGER.warn("Warning: removing default bean. This will be forbidden in next version of config-subsystem");
+ LOG.warn("Warning: removing default bean. This will be forbidden in next version of config-subsystem");
}
// first remove refNames, it checks for objectname existence
writableSRRegistry.removeServiceReferences(
ObjectNameUtil.createTransactionModuleON(getTransactionName(), moduleIdentifier));
} catch (InstanceNotFoundException e) {
- LOGGER.error("Possible code error: cannot find {} in {}", moduleIdentifier, writableSRRegistry);
+ LOG.error("Possible code error: cannot find {} in {}", moduleIdentifier, writableSRRegistry);
throw new IllegalStateException("Possible code error: cannot find " + moduleIdentifier, e);
}
private void validateNoLocks() throws ValidationException {
transactionStatus.checkNotAborted();
- LOGGER.trace("Validating transaction {}", getTransactionIdentifier());
+ LOG.trace("Validating transaction {}", getTransactionIdentifier());
// call validate()
List<ValidationException> collectedExceptions = new ArrayList<>();
for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager
try {
module.validate();
} catch (Exception e) {
- LOGGER.warn("Validation exception in {}", getTransactionName(),
+ LOG.warn("Validation exception in {}", getTransactionName(),
e);
collectedExceptions.add(ValidationException
.createForSingleException(name, e));
throw ValidationException
.createFromCollectedValidationExceptions(collectedExceptions);
}
- LOGGER.trace("Validated transaction {}", getTransactionIdentifier());
+ LOG.trace("Validated transaction {}", getTransactionIdentifier());
}
/**
try {
validateNoLocks();
} catch (ValidationException e) {
- LOGGER.trace("Commit failed on validation");
+ LOG.trace("Commit failed on validation");
configBeanModificationDisabled.set(false); // recoverable error
throw e;
}
+ "to obtain a lock");
}
- LOGGER.trace("Committing transaction {}", getTransactionIdentifier());
+ LOG.trace("Committing transaction {}", getTransactionIdentifier());
// call getInstance()
for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager
Module module = entry.getValue();
ModuleIdentifier name = entry.getKey();
try {
- LOGGER.debug("About to commit {} in transaction {}",
+ LOG.debug("About to commit {} in transaction {}",
name, getTransactionIdentifier());
AutoCloseable instance = module.getInstance();
checkNotNull(instance, "Instance is null:{} in transaction {}", name, getTransactionIdentifier());
} catch (Exception e) {
- LOGGER.error("Commit failed on {} in transaction {}", name,
+ LOG.error("Commit failed on {} in transaction {}", name,
getTransactionIdentifier(), e);
internalAbort();
throw new IllegalStateException(
// count dependency order
- LOGGER.trace("Committed configuration {}", getTransactionIdentifier());
+ LOG.trace("Committed configuration {}", getTransactionIdentifier());
transactionStatus.setCommitted();
return dependencyResolverManager.getSortedModuleIdentifiers();
}
private void internalAbort() {
- LOGGER.trace("Aborting {}", this);
+ LOG.trace("Aborting {}", this);
transactionStatus.setAborted();
close();
}
*/
package org.opendaylight.controller.config.manager.impl;
+import java.util.Collection;
+import java.util.List;
+import javax.management.ObjectName;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import javax.management.ObjectName;
-import java.util.Collection;
-import java.util.List;
-
/**
* Defines contract between {@link ConfigTransactionControllerImpl} (producer)
* and {@link ConfigRegistryImpl} (consumer).
*/
package org.opendaylight.controller.config.manager.impl;
+import java.io.Closeable;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
import org.opendaylight.controller.config.api.LookupRegistry;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.manager.impl.jmx.TransactionJMXRegistrator;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-import java.io.Closeable;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
/**
* Responsible for creating TransactionJMXRegistrator, registering transaction and all its beans,
* lookup of beans, closing of TransactionJMXRegistrator.
package org.opendaylight.controller.config.manager.impl;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.GuardedBy;
import java.util.Deque;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DeadlockMonitor implements AutoCloseable {
- private static final Logger LOGGER = LoggerFactory.getLogger(DeadlockMonitorRunnable.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DeadlockMonitor.class);
private static final long WARN_AFTER_MILLIS = 5000;
moduleIdentifierWithNanosStack.push(current);
top = current;
}
- LOGGER.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
+ LOG.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
}
public boolean isAlive() {
// is the getInstance() running longer than WARN_AFTER_MILLIS ?
long runningTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - copy.nanoTime);
if (runningTime > WARN_AFTER_MILLIS) {
- LOGGER.warn("{} did not finish after {} ms", copy.moduleIdentifier, runningTime);
+ LOG.warn("{} did not finish after {} ms", copy.moduleIdentifier, runningTime);
}
}
try {
interrupt();
}
}
- LOGGER.trace("Exiting {}", this);
+ LOG.trace("Exiting {}", this);
}
@Override
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.dependencyresolver.DestroyedModule;
import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
package org.opendaylight.controller.config.manager.impl;
import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.Collections;
import org.slf4j.LoggerFactory;
public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceReadableRegistry, SearchableServiceReferenceWritableRegistry {
- private static final Logger LOGGER = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class);
private final Map<String, ModuleFactory> factories;
private final Map<String, Set<String>> factoryNamesToQNames;
boolean skipChecks = true;
newRegistry.saveServiceReference(refNameEntry.getKey(), currentImplementation, skipChecks);
} catch (InstanceNotFoundException e) {
- LOGGER.error("Cannot save service reference({}, {})", refNameEntry.getKey(), currentImplementation);
+ LOG.error("Cannot save service reference({}, {})", refNameEntry.getKey(), currentImplementation);
throw new IllegalStateException("Possible code error", e);
}
}
for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
if (entry.getKey().equals(entry.getValue().getImplementationName()) == false) {
- LOGGER.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
+ LOG.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
throw new IllegalArgumentException("Possible error in code: Mismatch between supplied and actual name of " + entry);
}
Set<ServiceInterfaceAnnotation> siAnnotations = InterfacesHelper.getServiceInterfaceAnnotations(entry.getValue());
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 {}",
+ LOG.error("Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
sia.namespace(), sia.localName(), modifiableNamespacesToAnnotations);
throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
}
}
this.namespacesToAnnotations = ImmutableMap.copyOf(modifiableNamespacesToAnnotations);
this.serviceQNamesToAnnotations = ImmutableMap.copyOf(modifiableServiceQNamesToAnnotations);
- LOGGER.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
+ LOG.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
}
@Override
String factoryName = ObjectNameUtil.getFactoryName(objectName);
Set<String> serviceInterfaceAnnotations = factoryNamesToQNames.get(factoryName);
if (serviceInterfaceAnnotations == null) {
- LOGGER.error("Possible error in code: cannot find factory annotations of '{}' extracted from ON {} in {}",
+ LOG.error("Possible error in code: cannot find factory annotations of '{}' extracted from ON {} in {}",
factoryName, objectName, factoryNamesToQNames);
throw new IllegalArgumentException("Cannot find factory with name " + factoryName);
}
public synchronized String getServiceInterfaceName(final String namespace, final String localName) {
Map<String /* localName */, ServiceInterfaceAnnotation> ofNamespace = namespacesToAnnotations.get(namespace);
if (ofNamespace == null) {
- LOGGER.error("Cannot find namespace {} in {}", namespace, namespacesToAnnotations);
+ LOG.error("Cannot find namespace {} in {}", namespace, namespacesToAnnotations);
throw new IllegalArgumentException("Cannot find namespace " + namespace);
}
ServiceInterfaceAnnotation sia = ofNamespace.get(localName);
if (sia == null) {
- LOGGER.error("Cannot find local name {} in namespace {}, found only {}", localName, namespace, ofNamespace);
+ LOG.error("Cannot find local name {} in namespace {}, found only {}", localName, namespace, ofNamespace);
throw new IllegalArgumentException("Cannot find local name " + localName + " in namespace " + namespace);
}
return sia.value();
try {
on = lookupRegistry.lookupConfigBean(moduleIdentifier.getFactoryName(), moduleIdentifier.getInstanceName());
} catch (InstanceNotFoundException e) {
- LOGGER.error("Cannot find instance {}", moduleIdentifier);
+ LOG.error("Cannot find instance {}", moduleIdentifier);
throw new IllegalStateException("Cannot find instance " + moduleIdentifier, e);
}
return on;
ServiceReference serviceReference = new ServiceReference(serviceInterfaceQName, refName);
ModuleIdentifier moduleIdentifier = refNames.get(serviceReference);
if (moduleIdentifier == null) {
- LOGGER.error("Cannot find qname {} and refName {} in {}", serviceInterfaceQName, refName, refName);
+ LOG.error("Cannot find qname {} and refName {} in {}", serviceInterfaceQName, refName, refName);
throw new IllegalArgumentException("Cannot find " + serviceReference);
}
return getObjectName(moduleIdentifier);
Map<String, Map<String, ObjectName>> serviceMapping = getServiceMapping();
Map<String, ObjectName> innerMap = serviceMapping.get(serviceInterfaceQName);
if (innerMap == null) {
- LOGGER.error("Cannot find qname {} in {}", serviceInterfaceQName, refNames);
+ LOG.error("Cannot find qname {} in {}", serviceInterfaceQName, refNames);
throw new IllegalArgumentException("Cannot find " + serviceInterfaceQName);
}
return innerMap;
String referenceName = ObjectNameUtil.getReferenceName(objectName);
ServiceReference serviceReference = new ServiceReference(serviceQName, referenceName);
if (refNames.containsKey(serviceReference) == false) {
- LOGGER.warn("Cannot find {} in {}", serviceReference, refNames);
+ LOG.warn("Cannot find {} in {}", serviceReference, refNames);
throw new InstanceNotFoundException("Service reference not found:" + objectName);
}
}
// check that service interface name exist
Set<String> serviceInterfaceQNames = factoryNamesToQNames.get(moduleIdentifier.getFactoryName());
if (serviceInterfaceQNames == null) {
- LOGGER.error("Possible error in code: cannot find factoryName {} in {}, {}", moduleIdentifier.getFactoryName(),
+ LOG.error("Possible error in code: cannot find factoryName {} in {}, {}", moduleIdentifier.getFactoryName(),
factoryNamesToQNames, moduleIdentifier);
throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + moduleIdentifier.getFactoryName());
}
// supplied serviceInterfaceName must exist in this collection
if (serviceInterfaceQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
- LOGGER.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceQName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
+ LOG.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceQName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName() + " within factory " + moduleIdentifier.getFactoryName());
}
}
private synchronized void removeServiceReference(final ServiceReference serviceReference) throws InstanceNotFoundException {
- LOGGER.debug("Removing service reference {} from {}", serviceReference, this);
+ LOG.debug("Removing service reference {} from {}", serviceReference, this);
assertWritable();
// is the qName known?
if (allQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
- LOGGER.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
+ LOG.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName());
}
ModuleIdentifier removed = refNames.remove(serviceReference);
private Set<ServiceReference> findServiceReferencesLinkingTo(final ObjectName moduleObjectName, final Set<String> serviceInterfaceQNames) {
String factoryName = ObjectNameUtil.getFactoryName(moduleObjectName);
if (serviceInterfaceQNames == null) {
- LOGGER.warn("Possible error in code: cannot find factoryName {} in {}, object name {}", factoryName, factoryNamesToQNames, moduleObjectName);
+ LOG.warn("Possible error in code: cannot find factoryName {} in {}, object name {}", factoryName, factoryNamesToQNames, moduleObjectName);
throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + factoryName);
}
String instanceName = ObjectNameUtil.getInstanceName(moduleObjectName);
*/
final class DependencyResolverImpl implements DependencyResolver,
Comparable<DependencyResolverImpl> {
- private static final Logger LOGGER = LoggerFactory.getLogger(DependencyResolverImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DependencyResolverImpl.class);
private final ModulesHolder modulesHolder;
private final ModuleIdentifier name;
format("ObjectName should not contain "
+ "transaction name. %s set to %s. ", jmxAttribute,
dependentReadOnlyON
- ), jmxAttribute
+ ), jmxAttribute
);
ObjectName newDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
if (expectedBaseClass.isAssignableFrom(deserialized)) {
return (Class<T>) deserialized;
} else {
- LOGGER.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.",
+ LOG.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.",
identityRef, deserialized, expectedBaseClass);
throw new IllegalArgumentException("Deserialized identity " + deserialized + " cannot be cast to " + expectedBaseClass);
}
*/
public class DestroyedModule implements AutoCloseable,
Comparable<DestroyedModule>, Identifiable<ModuleIdentifier> {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(DestroyedModule.class);
private final ModuleIdentifier identifier;
@Override
public void close() {
- LOGGER.trace("Destroying {}", identifier);
+ LOG.trace("Destroying {}", identifier);
try {
instance.close();
} catch (Exception e) {
- LOGGER.error("Error while closing instance of {}", identifier, e);
+ LOG.error("Error while closing instance of {}", identifier, e);
}
try {
oldJMXRegistrator.close();
} catch (Exception e) {
- LOGGER.error("Error while closing jmx registrator of {}", identifier, e);
+ LOG.error("Error while closing jmx registrator of {}", identifier, e);
}
try {
osgiRegistration.close();
} catch (Exception e) {
- LOGGER.error("Error while closing osgi registration of {}", identifier, e);
+ LOG.error("Error while closing osgi registration of {}", identifier, e);
}
}
*/
package org.opendaylight.controller.config.manager.impl.dependencyresolver;
+import javax.annotation.Nullable;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.manager.impl.ModuleInternalInfo;
import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
import org.opendaylight.controller.config.spi.Module;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.yangtools.concepts.Identifiable;
-
-import javax.annotation.Nullable;
import org.osgi.framework.BundleContext;
public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
*/
package org.opendaylight.controller.config.manager.impl.dependencyresolver;
-import org.opendaylight.controller.config.api.JmxAttribute;
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.manager.impl.CommitInfo;
-import org.opendaylight.controller.config.manager.impl.TransactionIdentifier;
-import org.opendaylight.controller.config.spi.Module;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-
-import javax.annotation.concurrent.GuardedBy;
-import javax.management.InstanceAlreadyExistsException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.annotation.concurrent.GuardedBy;
+import javax.management.InstanceAlreadyExistsException;
+import org.opendaylight.controller.config.api.JmxAttribute;
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.manager.impl.CommitInfo;
+import org.opendaylight.controller.config.manager.impl.TransactionIdentifier;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.spi.ModuleFactory;
/**
* Represents modules to be committed.
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
import static java.lang.String.format;
+
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.lang.String.format;
+
/**
* Contains common code for readable/rw dynamic mbean wrappers. Routes all
* requests (getAttribute, setAttribute, invoke) into the actual instance, but
}
AttributeHolder attributeHolder = new AttributeHolder(
attribName, module, attributeMap.get(attribName)
- .getType(), writable, ifc, description);
+ .getType(), writable, ifc, description);
attributeHolderMap.put(attribName, attributeHolder);
}
}
*/
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;
public class AnnotationsHelper {
*/
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
-import org.opendaylight.controller.config.api.annotations.Description;
-import org.opendaylight.controller.config.api.annotations.RequireInterface;
-
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-import javax.management.MBeanAttributeInfo;
-import javax.management.ObjectName;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.Immutable;
+import javax.management.MBeanAttributeInfo;
+import javax.management.ObjectName;
+import org.opendaylight.controller.config.api.annotations.Description;
+import org.opendaylight.controller.config.api.annotations.RequireInterface;
@Immutable
class AttributeHolder {
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.ReflectionException;
-
import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
*/
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.TransactionIdentifier;
-import org.opendaylight.controller.config.spi.Module;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import java.lang.reflect.Method;
import javax.annotation.concurrent.ThreadSafe;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.ReflectionException;
-import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.manager.impl.TransactionIdentifier;
+import org.opendaylight.controller.config.spi.Module;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Wraps {@link org.opendaylight.controller.config.spi.Module} instance in a
*/
@ThreadSafe
public class DynamicWritableWrapper extends AbstractDynamicWrapper {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(DynamicWritableWrapper.class);
private final ReadOnlyAtomicBoolean configBeanModificationDisabled;
setAttribute(attribute);
result.add(attribute);
} catch (Exception e) {
- LOGGER.warn("Setting attribute {} failed on {}", attribute.getName(), moduleIdentifier, e);
+ LOG.warn("Setting attribute {} failed on {}", attribute.getName(), moduleIdentifier, e);
throw new IllegalArgumentException(
"Setting attribute failed - " + attribute.getName()
+ " on " + moduleIdentifier, e);
*/
package org.opendaylight.controller.config.manager.impl.factoriesresolver;
+import java.util.Map;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import java.util.Map;
-
/**
* {@link org.opendaylight.controller.config.manager.impl.ConfigTransactionControllerImpl}
* receives list of factories using this interface. For testing, this could be
*/
package org.opendaylight.controller.config.manager.impl.jmx;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-
+import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.QueryExp;
-import java.util.Set;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
public class BaseJMXRegistrator implements AutoCloseable, NestableJMXRegistrator {
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanServer;
-
import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
import org.opendaylight.controller.config.manager.impl.ConfigRegistryImplMXBean;
import java.util.HashMap;
import java.util.Map;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.api.runtime.HierarchicalRuntimeBeanRegistration;
*/
package org.opendaylight.controller.config.manager.impl.jmx;
-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;
import javax.annotation.concurrent.GuardedBy;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.QueryExp;
-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;
public class InternalJMXRegistrator implements Closeable {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(InternalJMXRegistrator.class);
private final MBeanServer configMBeanServer;
try {
configMBeanServer.unregisterMBean(on);
} catch (Exception e) {
- LOGGER.warn("Ignoring error while unregistering {}", on, e);
+ LOG.warn("Ignoring error while unregistering {}", on, e);
}
}
registeredObjectNames.clear();
package org.opendaylight.controller.config.manager.impl.jmx;
import java.io.Closeable;
-
import javax.annotation.concurrent.ThreadSafe;
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.manager.impl.jmx.InternalJMXRegistrator.InternalJMXRegistration;
package org.opendaylight.controller.config.manager.impl.jmx;
import java.util.Collections;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
*/
package org.opendaylight.controller.config.manager.impl.jmx;
-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 org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.manager.impl.jmx.InternalJMXRegistrator.InternalJMXRegistration;
public interface ServiceReferenceRegistrator extends AutoCloseable {
*/
package org.opendaylight.controller.config.manager.impl.jmx;
-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;
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
import javax.management.QueryExp;
-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;
/**
* Contains constraints on passed {@link ObjectName} parameters. Only allow (un)
import java.io.Closeable;
import java.util.Set;
-
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;
public static class OsgiRegistration implements AutoCloseable {
- private static final Logger LOGGER = LoggerFactory.getLogger(OsgiRegistration.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OsgiRegistration.class);
@GuardedBy("this")
private AutoCloseable instance;
try {
serviceRegistration.unregister();
} catch(IllegalStateException e) {
- LOGGER.trace("Cannot unregister {}", serviceRegistration, e);
+ LOG.trace("Cannot unregister {}", serviceRegistration, e);
}
}
serviceRegistrations.clear();
notEquals |= newAnnotationMapping.equals(serviceNamesToAnnotations) == false;
if (notEquals) {
// FIXME: changing from old state to new state can be improved by computing the diff
- LOGGER.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier,
+ LOG.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier,
serviceNamesToAnnotations, newAnnotationMapping);
close();
this.instance = newInstance;
* functionality.
*/
public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<ModuleFactory, Object> {
- private static final Logger LOGGER = LoggerFactory.getLogger(BlankTransactionServiceTracker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(BlankTransactionServiceTracker.class);
public static final int DEFAULT_MAX_ATTEMPTS = 10;
try {
// create transaction
CommitStatus commitStatus = blankTransaction.hit();
- LOGGER.debug("Committed blank transaction with status {}", commitStatus);
+ LOG.debug("Committed blank transaction with status {}", commitStatus);
return;
} catch (ConflictingVersionException e) {
lastException = e;
throw new IllegalStateException(interruptedException);
}
} catch (ValidationException e) {
- LOGGER.error("Validation exception while running blank transaction indicates programming error", e);
+ LOG.error("Validation exception while running blank transaction indicates programming error", e);
throw new RuntimeException("Validation exception while running blank transaction indicates programming error", e);
}
}
*/
package org.opendaylight.controller.config.manager.impl.osgi;
+import java.util.AbstractMap;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.AbstractMap;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Retrieves list of currently registered Module Factories using bundlecontext.
*/
public class BundleContextBackedModuleFactoriesResolver implements
ModuleFactoriesResolver {
- private static final Logger LOGGER = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(BundleContextBackedModuleFactoriesResolver.class);
private final BundleContext bundleContext;
if (serviceReference.getBundle() == null || serviceReference.getBundle().getBundleContext() == null) {
throw new NullPointerException("Bundle context of " + factory + " ModuleFactory not found.");
}
- LOGGER.debug("Reading factory {} {}", moduleName, factory);
+ LOG.debug("Reading factory {} {}", moduleName, factory);
Map.Entry<ModuleFactory, BundleContext> conflicting = result.get(moduleName);
if (conflicting != 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);
+ LOG.error(error);
throw new IllegalArgumentException(error);
} else {
result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
LOG.trace("AddingBundle for {} and event {} finished successfully",bundle,event);
return primaryTrackerRetVal;
} catch (Exception e) {
- LOG.error("Failed to add bundle {}",e);
+ LOG.error("Failed to add bundle ",e);
throw e;
}
}
import java.io.InputStream;
import java.net.URL;
import java.util.List;
-
import org.apache.commons.io.IOUtils;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.Bundle;
*/
public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Object> {
private final BlankTransactionServiceTracker blankTransactionServiceTracker;
- private static final Logger LOGGER = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class);
public ModuleFactoryBundleTracker(BlankTransactionServiceTracker blankTransactionServiceTracker) {
this.blankTransactionServiceTracker = blankTransactionServiceTracker;
@Override
public Object addingBundle(Bundle bundle, BundleEvent event) {
URL resource = bundle.getEntry("META-INF/services/" + ModuleFactory.class.getName());
- LOGGER.trace("Got addingBundle event of bundle {}, resource {}, event {}",
+ LOG.trace("Got addingBundle event of bundle {}, resource {}, event {}",
bundle, resource, event);
if (resource != null) {
try (InputStream inputStream = resource.openStream()) {
registerFactory(factoryClassName, bundle);
}
} catch (Exception e) {
- LOGGER.error("Error while reading {}", resource, e);
+ LOG.error("Error while reading {}", resource, e);
throw new RuntimeException(e);
}
}
Class<?> clazz = bundle.loadClass(factoryClassName);
if (ModuleFactory.class.isAssignableFrom(clazz)) {
try {
- LOGGER.debug("Registering {} in bundle {}",
+ LOG.debug("Registering {} in bundle {}",
clazz.getName(), bundle);
return bundle.getBundleContext().registerService(
ModuleFactory.class.getName(), clazz.newInstance(),
}
public static String logMessage(String slfMessage, Object... params) {
- LOGGER.info(slfMessage, params);
+ LOG.info(slfMessage, params);
String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
return format(formatMessage, params);
}
package org.opendaylight.controller.config.manager.impl.osgi.mapping;
import javassist.ClassPool;
-
import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil;
import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
-
import org.apache.commons.io.IOUtils;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.sal.binding.generator.api.ModuleInfoRegistry;
*/
public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<ObjectRegistration<YangModuleInfo>>> {
- private static final Logger LOGGER = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/";
@Override
public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
- LOGGER.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
+ LOG.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
if(resource==null) {
return null;
}
try (InputStream inputStream = resource.openStream()) {
List<String> lines = IOUtils.readLines(inputStream);
for (String moduleInfoName : lines) {
- LOGGER.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle);
+ LOG.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle);
YangModuleInfo moduleInfo = retrieveModuleInfo(moduleInfoName, bundle);
registrations.add(moduleInfoRegistry.registerModuleInfo(moduleInfo));
}
} catch (Exception e) {
- LOGGER.error("Error while reading {}", resource, e);
+ LOG.error("Error while reading {}", resource, e);
throw new RuntimeException(e);
}
- LOGGER.trace("Got following registrations {}", registrations);
+ LOG.trace("Got following registrations {}", registrations);
return registrations;
}
} catch (NoClassDefFoundError e) {
- LOGGER.error("Error while executing getModuleInfo on {}", instance, e);
+ LOG.error("Error while executing getModuleInfo on {}", instance, e);
throw e;
}
}
}
public static String logMessage(String slfMessage, Object... params) {
- LOGGER.info(slfMessage, params);
+ LOG.info(slfMessage, params);
String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
return format(formatMessage, params);
}
package org.opendaylight.controller.config.manager.impl.osgi.mapping;
+import java.util.Hashtable;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.sal.binding.generator.api.ModuleInfoRegistry;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import java.util.Hashtable;
-
/**
* Update SchemaContext service in Service Registry each time new YangModuleInfo is added or removed.
*/
package org.opendaylight.controller.config.manager.impl.util;
import java.util.Set;
-
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.LookupRegistry;
public class LookupBeansUtil {
*/
package org.opendaylight.controller.config.manager.impl.util;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.osgi.framework.BundleContext;
-
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.osgi.framework.BundleContext;
public class ModuleQNameUtil {
package org.opendaylight.controller.config.manager.impl.util;
import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.slf4j.LoggerFactory;
public class OsgiRegistrationUtil {
- private static final Logger LOGGER = LoggerFactory.getLogger(OsgiRegistrationUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OsgiRegistrationUtil.class);
private OsgiRegistrationUtil() {
}
try {
ac.close();
} catch (Exception e) {
- LOGGER.warn("Exception while closing {}", ac, e);
+ LOG.warn("Exception while closing {}", ac, e);
if (firstException == null) {
firstException = e;
} else {
*/
package org.opendaylight.controller.config.manager;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.lang.management.ManagementFactory;
import org.junit.Test;
import org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest;
import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.management.ManagementFactory;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verifyZeroInteractions;
-
public class ConfigRegistryImplTest extends
AbstractLockedPlatformMBeanServerTest {
- private static final Logger logger = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(ConfigRegistryImplTest.class);
@Test
configRegistry.close();
} catch (Exception e) {
// ignore
- logger.warn("Ignoring exception", e);
+ LOG.warn("Ignoring exception", e);
}
}
}
*/
package org.opendaylight.controller.config.manager.impl;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+
import com.google.common.base.Preconditions;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Dictionary;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.RuntimeMBeanException;
import org.junit.After;
import org.junit.Before;
import org.mockito.Matchers;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.RuntimeMBeanException;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Dictionary;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-
/**
* Each test that relies on
* {@link org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl}
public static interface BundleContextServiceRegistrationHandler {
- void handleServiceRegistration(Class<?> clazz, Object serviceInstance, Dictionary<String, ?> props);
+ void handleServiceRegistration(Class<?> clazz, Object serviceInstance, Dictionary<String, ?> props);
}
Object proxy = Proxy.newProxyInstance(innerObject.getClass().getClassLoader(),
innerObject.getClass().getInterfaces(), new InvocationHandler() {
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- try {
- return method.invoke(innerObject, args);
- } catch (InvocationTargetException e) {
- try {
- throw e.getTargetException();
- } catch (RuntimeMBeanException e2) {
- throw e2.getTargetException();
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ try {
+ return method.invoke(innerObject, args);
+ } catch (InvocationTargetException e) {
+ try {
+ throw e.getTargetException();
+ } catch (RuntimeMBeanException e2) {
+ throw e2.getTargetException();
+ }
+ }
+ }
}
- }
- }
- });
+ );
return (T) proxy;
}
import java.lang.management.ManagementFactory;
import java.util.concurrent.locks.ReentrantLock;
-
import javax.management.MBeanServer;
-
import org.junit.After;
import org.junit.Before;
package org.opendaylight.controller.config.manager.impl;
import com.google.common.base.Preconditions;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.DependencyResolverFactory;
import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* Creates new modules by reflection. Provided class must have this constructor:
* ctor(DynamicMBeanWithInstance.class, ModuleIdentifier.class).
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import com.google.common.collect.Sets;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.ObjectName;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl;
import org.opendaylight.controller.config.manager.impl.runtimembean.TestingRuntimeBean;
-import com.google.common.collect.Sets;
-
public class ConfigRegistryImplLookupTest extends
AbstractLockedPlatformMBeanServerTest {
*/
package org.opendaylight.controller.config.manager.impl;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.collect.Sets;
+import java.lang.management.ManagementFactory;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-
public class ConfigTransactionControllerImplTest extends
AbstractLockedPlatformMBeanServerTest {
*/
package org.opendaylight.controller.config.manager.impl;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import javax.management.InstanceAlreadyExistsException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.InstanceAlreadyExistsException;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
public class ConfigTransactionManagerImplTest extends
AbstractConfigTest {
*/
package org.opendaylight.controller.config.manager.impl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.withoutTransactionName;
+
import com.google.common.collect.ImmutableMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMX;
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.api.jmx.ServiceReferenceMXBean;
import org.opendaylight.controller.config.manager.impl.AbstractConfigTest.RecordingBundleContextServiceRegistrationHandler.RegistrationHolder;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.api.jmx.ServiceReferenceMXBean;
import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
import org.opendaylight.controller.config.manager.testingservices.parallelapsp.test.AbstractParallelAPSPTest;
import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.withoutTransactionName;
-
public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
boolean isDefaultBean = false;
tested.put(moduleIdentifier,
- mockedModule(),
- moduleFactory,
- maybeOldInternalInfo,
- transactionModuleJMXRegistration,
- isDefaultBean, mock(BundleContext.class));
+ mockedModule(),
+ moduleFactory,
+ maybeOldInternalInfo,
+ transactionModuleJMXRegistration,
+ isDefaultBean, mock(BundleContext.class));
}
private static Module mockedModule() {
*/
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
+import static org.junit.Assert.assertEquals;
+
+import java.lang.management.ManagementFactory;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.DynamicMBean;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
import org.opendaylight.controller.config.spi.Module;
-import static org.junit.Assert.assertEquals;
-
public abstract class AbstractDynamicWrapperTest extends
AbstractLockedPlatformMBeanServerTest {
protected final MBeanServer platformMBeanServer = ManagementFactory
proxy.getAttribute(TRIGGER_NEW_INSTANCE_CREATION));
AttributeList attributes = proxy.getAttributes(new String[] {
- THREAD_COUNT, TRIGGER_NEW_INSTANCE_CREATION });
+ THREAD_COUNT, TRIGGER_NEW_INSTANCE_CREATION });
assertEquals(2, attributes.size());
Attribute threadCountAttr = (Attribute) attributes.get(0);
assertEquals(THREAD_COUNT, threadCountAttr.getName());
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Sets;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
-
import javax.management.ObjectName;
-
import org.junit.Test;
import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
import org.opendaylight.controller.config.api.annotations.Description;
import org.opendaylight.controller.config.api.annotations.RequireInterface;
import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Sets;
-
public class AnnotationsTest {
private final String setSomethingString = "setSomething";
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
import java.lang.management.ManagementFactory;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.spi.Module;
*/
package org.opendaylight.controller.config.manager.impl.dynamicmbean;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.DynamicMBean;
+import javax.management.JMX;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
import org.junit.Test;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
import org.opendaylight.controller.config.spi.Module;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.DynamicMBean;
-import javax.management.JMX;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
public class DynamicWritableWrapperTest extends AbstractDynamicWrapperTest {
private final int newThreadCount = 10;
private final AtomicBoolean atomicBoolean = new AtomicBoolean();
*/
package org.opendaylight.controller.config.manager.impl.factoriesresolver;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import java.io.Closeable;
+import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
-import java.util.AbstractMap;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
public class HardcodedModuleFactoriesResolver implements ModuleFactoriesResolver {
private Map<String, Map.Entry<ModuleFactory, BundleContext>> factories;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+
import java.util.Collections;
import javax.management.ObjectName;
import org.junit.Before;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+
import com.google.common.collect.Lists;
import java.util.Map;
import org.junit.Before;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
+
import java.util.Dictionary;
import java.util.Set;
import org.junit.Before;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+
import java.util.Dictionary;
import org.junit.Test;
import org.mockito.Mockito;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
-
import java.lang.management.ManagementFactory;
import java.util.Map;
-
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
package org.opendaylight.controller.config.manager.impl.util;
import static org.junit.Assert.assertEquals;
+
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.util.Collections;
Set<Class<?>> expected = ImmutableSet.of((Class<?>) TestingScheduledThreadPoolServiceInterface.class,
TestingThreadPoolServiceInterface.class
- );
+ );
assertEquals(expected, result);
}
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+
import org.junit.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;
package org.opendaylight.controller.config.manager.testingservices.parallelapsp;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
@ServiceInterfaceAnnotation(value = TestingParallelAPSPConfigMXBean.NAME, osgiRegistrationType = TestingAPSP.class,
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.base.Strings;
import java.io.Closeable;
import java.io.IOException;
-
import javax.annotation.concurrent.NotThreadSafe;
-
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
-import com.google.common.base.Strings;
-
@NotThreadSafe
public class TestingParallelAPSPImpl implements TestingAPSP, Closeable {
public static final int MINIMAL_NUMBER_OF_THREADS = 10;
@NotThreadSafe
public class TestingParallelAPSPModule implements Module,
TestingParallelAPSPConfigMXBean {
- private static final Logger logger = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(TestingParallelAPSPModule.class);
private final DependencyResolver dependencyResolver;
// changing thread pool is not supported
boolean reuse = threadPoolInstance == oldInstance.getThreadPool();
if (reuse) {
- logger.debug("Reusing old instance");
+ LOG.debug("Reusing old instance");
instance = oldInstance;
instance.setSomeParam(someParam);
}
}
if (instance == null) {
- logger.debug("Creating new instance");
+ LOG.debug("Creating new instance");
if (oldCloseable != null) {
try {
oldCloseable.close();
*/
package org.opendaylight.controller.config.manager.testingservices.parallelapsp;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import javax.annotation.concurrent.ThreadSafe;
+import javax.management.ObjectName;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.DependencyResolverFactory;
import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
-import javax.annotation.concurrent.ThreadSafe;
-import javax.management.ObjectName;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
@ThreadSafe
public class TestingParallelAPSPModuleFactory implements ModuleFactory {
*/
package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
public abstract class AbstractParallelAPSPTest extends AbstractConfigTest {
protected final String fixed1 = "fixed1";
protected final String apsp1 = "apsp-parallel";
import static org.junit.Assert.fail;
import java.util.Map;
-
import javax.management.ObjectName;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public void testUsingServiceReferences() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
ObjectName threadPoolON = createFixed1(transaction, 10);
- transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
+ transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
String refName = "ref";
ObjectName serviceReferenceON = transaction.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName,
threadPoolON);
*/
package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.Executor;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
import org.opendaylight.controller.config.spi.Module;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.ObjectName;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.concurrent.Executor;
-
public class MockedDependenciesTest extends AbstractParallelAPSPTest {
private final String threadPoolImplementationName = "mockedthreadpool";
*/
package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool;
+import com.google.common.collect.Lists;
import java.io.Closeable;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
-
import org.opendaylight.controller.config.api.runtime.HierarchicalRuntimeBeanRegistration;
import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.runtimebeans
- .TestingScheduledRuntimeBean;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.runtimebeans.TestingScheduledRuntimeBean;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
-import com.google.common.collect.Lists;
-
public class TestingScheduledThreadPoolImpl implements TestingThreadPoolIfc,
TestingScheduledThreadPoolIfc, Closeable {
private static volatile int numberOfCloseMethodCalls = 0;
import static org.junit.Assert.assertNull;
import java.io.Closeable;
-
import javax.annotation.Nullable;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
*/
package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.test;
+import static org.junit.Assert.assertEquals;
+
import org.junit.After;
import org.junit.Before;
import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
-import static org.junit.Assert.assertEquals;
-
public abstract class AbstractScheduledTest extends AbstractConfigTest {
protected static final String scheduled1 = "scheduled1";
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import java.util.Collections;
import java.util.List;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool
- .TestingScheduledThreadPoolConfigBeanMXBean;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool
- .TestingScheduledThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolConfigBeanMXBean;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
/**
* TestingScheduledThreadPool exports 2 interfaces: <br>
* {@link org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory#NAME}
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import javax.annotation.Nullable;
import javax.management.DynamicMBean;
import javax.management.InstanceAlreadyExistsException;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.Lists;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
-import com.google.common.collect.Lists;
-
public class TestingFixedThreadPool implements TestingThreadPoolIfc, Closeable,
TestingModifiableThreadPoolIfc {
private final ThreadPoolExecutor executorService;
import static com.google.common.base.Preconditions.checkState;
import java.io.Closeable;
-
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
-
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.manager.testingservices.seviceinterface.ModifiableThreadPoolServiceInterface;
import org.opendaylight.controller.config.spi.Module;
*/
package org.opendaylight.controller.config.manager.testingservices.threadpool.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import com.google.common.collect.Sets;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ThreadPoolExecutor;
+import javax.management.DynamicMBean;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.ConfigTransactionClient;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
/**
* Tests basic functionality of configuration registry:
* <ol>
package org.opendaylight.controller.config.persist.storage.directory.xml;
import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.base.Optional;
import com.google.common.io.Files;
import java.io.File;
} catch (JAXBException e) {
// In case of parse error, issue a warning, ignore and continue
LOG.warn(
- "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. " +
- "Note that subsequent config files may fail due to this problem. " +
+ "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. ",
+ file, file);
+ LOG.warn(
+ "Note that subsequent config files may fail due to this problem. ",
"Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
- file, file, e);
+ e);
}
return Optional.absent();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import com.google.common.base.Optional;
import java.io.File;
import java.io.IOException;
*/
package org.opendaylight.controller.configpusherfeature.internal;
+import com.google.common.base.Preconditions;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-
import javax.xml.bind.JAXBException;
-
import org.apache.karaf.features.BundleInfo;
import org.apache.karaf.features.Conditional;
import org.apache.karaf.features.ConfigFileInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
/*
* Wrap a Feature for the purposes of extracting the FeatureConfigSnapshotHolders from
* its underlying ConfigFileInfo's
* Delegates the the contained feature and provides additional methods.
*/
public class AbstractFeatureWrapper implements Feature {
- private static final Logger LOGGER = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
protected Feature feature = null;
protected AbstractFeatureWrapper() {
try {
snapShotHolders.add(new FeatureConfigSnapshotHolder(c,this));
} catch (JAXBException e) {
- LOGGER.debug("{} is not a config subsystem config file",c.getFinalname());
+ LOG.debug("{} is not a config subsystem config file",c.getFinalname());
}
}
return snapShotHolders;
*/
package org.opendaylight.controller.configpusherfeature.internal;
+import com.google.common.base.Preconditions;
import java.util.LinkedHashSet;
import java.util.List;
-
import javax.xml.bind.JAXBException;
-
import org.apache.felix.utils.version.VersionRange;
import org.apache.felix.utils.version.VersionTable;
import org.apache.karaf.features.Dependency;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
/*
* Wrap a Feature for the purposes of extracting the FeatureConfigSnapshotHolders from
* its underlying ConfigFileInfo's and those of its children recursively
* Delegates the the contained feature and provides additional methods.
*/
public class ChildAwareFeatureWrapper extends AbstractFeatureWrapper implements Feature {
- private static final Logger LOGGER = LoggerFactory.getLogger(ChildAwareFeatureWrapper.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ChildAwareFeatureWrapper.class);
private FeaturesService featuresService= null;
protected ChildAwareFeatureWrapper(Feature f) {
f = new FeatureConfigSnapshotHolder(h,this);
snapShotHolders.add(f);
} catch (JAXBException e) {
- LOGGER.debug("{} is not a config subsystem config file",h.getFileInfo().getFinalname());
+ LOG.debug("{} is not a config subsystem config file",h.getFileInfo().getFinalname());
}
}
}
Version v = VersionTable.getVersion(f.getVersion());
if (range.contains(v) &&
(fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(v) < 0)) {
- fi = f;
- break;
+ fi = f;
+ break;
}
}
}
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-
import org.apache.karaf.features.FeatureEvent;
import org.apache.karaf.features.FeaturesListener;
import org.apache.karaf.features.FeaturesService;
import org.slf4j.LoggerFactory;
public class ConfigFeaturesListener implements FeaturesListener, AutoCloseable {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConfigFeaturesListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigFeaturesListener.class);
private static final int QUEUE_SIZE = 1000;
private BlockingQueue<FeatureEvent> queue = new LinkedBlockingQueue<FeatureEvent>(QUEUE_SIZE);
Thread pushingThread = null;
@Override
public void repositoryEvent(RepositoryEvent event) {
- LOGGER.debug("Repository: " + event.getType() + " " + event.getRepository());
+ LOG.debug("Repository: {} {}", event.getType(), event.getRepository());
}
@Override
*/
package org.opendaylight.controller.configpusherfeature.internal;
+import com.google.common.collect.LinkedHashMultimap;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
-
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeatureEvent;
import org.apache.karaf.features.FeatureEvent.EventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.LinkedHashMultimap;
-
public class ConfigPushingRunnable implements Runnable {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConfigPushingRunnable.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigPushingRunnable.class);
private static final int POLL_TIME = 1;
private BlockingQueue<FeatureEvent> queue;
private FeatureConfigPusher configPusher;
processFeatureEvent(event,toInstall);
}
} else if(toInstall.isEmpty()) {
- LOGGER.error("ConfigPushingRunnable - exiting");
+ LOG.error("ConfigPushingRunnable - exiting");
return;
}
} catch (InterruptedException e) {
- LOGGER.error("ConfigPushingRunnable - interupted");
+ LOG.error("ConfigPushingRunnable - interupted");
interuppted = true;
} catch (Exception e) {
- LOGGER.error("Exception while processing features {}", e);
+ LOG.error("Exception while processing features ", e);
}
}
}
protected void logPushResult(LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> results) {
for(Feature f:results.keySet()) {
- LOGGER.info("Pushed configs for feature {} {}",f,results.get(f));
+ LOG.info("Pushed configs for feature {} {}",f,results.get(f));
}
}
}
*/
package org.opendaylight.controller.configpusherfeature.internal;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-
import org.apache.karaf.features.ConfigFileInfo;
import org.apache.karaf.features.Feature;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
/*
* A ConfigSnapshotHolder that can track all the additional information
* relavent to the fact we are getting these from a Feature.
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.SortedSet;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.config.persist.api.PropertiesProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-
/**
* StorageAdapter that stores configuration in an xml file.
*/
public class XmlFileStorageAdapter implements StorageAdapter, Persister {
- private static final Logger LOGGER = LoggerFactory.getLogger(XmlFileStorageAdapter.class);
+ private static final Logger LOG = LoggerFactory.getLogger(XmlFileStorageAdapter.class);
public static final String FILE_STORAGE_PROP = "fileStorage";
public static final String NUMBER_OF_BACKUPS = "numberOfBackups";
@Override
public Persister instantiate(PropertiesProvider propertiesProvider) {
File storage = extractStorageFileFromProperties(propertiesProvider);
- LOGGER.debug("Using file {}", storage.getAbsolutePath());
+ LOG.debug("Using file {}", storage.getAbsolutePath());
// Create file if it does not exist
File parentFile = storage.getAbsoluteFile().getParentFile();
if (parentFile.exists() == false) {
- LOGGER.debug("Creating parent folders {}", parentFile);
+ LOG.debug("Creating parent folders {}", parentFile);
parentFile.mkdirs();
}
if (storage.exists() == false) {
- LOGGER.debug("Storage file does not exist, creating empty file");
+ LOG.debug("Storage file does not exist, creating empty file");
try {
boolean result = storage.createNewFile();
if (result == false)
} else {
numberOfStoredBackups = Integer.MAX_VALUE;
}
- LOGGER.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups);
+ LOG.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups);
return result;
}
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.io.Files;
-import org.apache.commons.lang3.StringUtils;
-
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
+import org.apache.commons.lang3.StringUtils;
@XmlRootElement(name = "persisted-snapshots")
public final class Config {
*/
package org.opendaylight.controller.config.persist.storage.file.xml.model;
+import java.util.SortedSet;
import java.util.TreeSet;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.SortedSet;
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
@XmlRootElement(name = ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME)
public class ConfigSnapshot {
*/
package org.opendaylight.controller.config.persist.storage.file.xml.model;
+import java.io.StringReader;
+import java.io.StringWriter;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.annotation.DomHandler;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import java.io.StringReader;
-import java.io.StringWriter;
class SnapshotHandler implements DomHandler<String, StreamResult> {
package org.opendaylight.controller.config.persist.storage.file.xml;
-import static org.junit.Assert.assertFalse;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+
import com.google.common.base.Charsets;
import java.io.File;
import java.io.FileNotFoundException;
package org.opendaylight.controller.netconf.client;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.util.Timer;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.Promise;
import java.io.Closeable;
-
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.opendaylight.protocol.framework.AbstractDispatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.util.Timer;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.Promise;
-
public class NetconfClientDispatcherImpl extends AbstractDispatcher<NetconfClientSession, NetconfClientSessionListener>
implements NetconfClientDispatcher, Closeable {
- private static final Logger logger = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class);
private final Timer timer;
@Override
public Future<Void> createReconnectingClient(final NetconfReconnectingClientConfiguration clientConfiguration) {
switch (clientConfiguration.getProtocol()) {
- case TCP: return createReconnectingTcpClient(clientConfiguration);
- case SSH: return createReconnectingSshClient(clientConfiguration);
- default: throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol());
+ case TCP:
+ return createReconnectingTcpClient(clientConfiguration);
+ case SSH:
+ return createReconnectingSshClient(clientConfiguration);
+ default:
+ throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol());
}
}
private Future<NetconfClientSession> createTcpClient(final NetconfClientConfiguration currentConfiguration) {
- logger.debug("Creating TCP client with configuration: {}", currentConfiguration);
+ LOG.debug("Creating TCP client with configuration: {}", currentConfiguration);
return super.createClient(currentConfiguration.getAddress(), currentConfiguration.getReconnectStrategy(),
new PipelineInitializer<NetconfClientSession>() {
}
private Future<Void> createReconnectingTcpClient(final NetconfReconnectingClientConfiguration currentConfiguration) {
- logger.debug("Creating reconnecting TCP client with configuration: {}", currentConfiguration);
+ LOG.debug("Creating reconnecting TCP client with configuration: {}", currentConfiguration);
final TcpClientChannelInitializer init = new TcpClientChannelInitializer(getNegotiatorFactory(currentConfiguration),
currentConfiguration.getSessionListener());
}
private Future<NetconfClientSession> createSshClient(final NetconfClientConfiguration currentConfiguration) {
- logger.debug("Creating SSH client with configuration: {}", currentConfiguration);
+ LOG.debug("Creating SSH client with configuration: {}", currentConfiguration);
return super.createClient(currentConfiguration.getAddress(), currentConfiguration.getReconnectStrategy(),
new PipelineInitializer<NetconfClientSession>() {
}
private Future<Void> createReconnectingSshClient(final NetconfReconnectingClientConfiguration currentConfiguration) {
- logger.debug("Creating reconnecting SSH client with configuration: {}", currentConfiguration);
+ LOG.debug("Creating reconnecting SSH client with configuration: {}", currentConfiguration);
final SshClientChannelInitializer init = new SshClientChannelInitializer(currentConfiguration.getAuthHandler(),
getNegotiatorFactory(currentConfiguration), currentConfiguration.getSessionListener());
package org.opendaylight.controller.netconf.client;
import io.netty.channel.Channel;
-
import java.util.Collection;
-
import org.opendaylight.controller.netconf.nettyutil.AbstractNetconfSession;
import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXICodec;
import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
public class NetconfClientSession extends AbstractNetconfSession<NetconfClientSession, NetconfClientSessionListener> {
- private static final Logger logger = LoggerFactory.getLogger(NetconfClientSession.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSession.class);
private final Collection<String> capabilities;
/**
final Collection<String> capabilities) {
super(sessionListener, channel, sessionId);
this.capabilities = capabilities;
- logger.debug("Client Session {} created", toString());
+ LOG.debug("Client Session {} created", toString());
}
public Collection<String> getServerCapabilities() {
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.Timer;
import io.netty.util.concurrent.Promise;
-
import java.util.Collection;
-
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
-
import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
public class NetconfClientSessionNegotiator extends
AbstractNetconfSessionNegotiator<NetconfClientSessionPreferences, NetconfClientSession, NetconfClientSessionListener>
{
- private static final Logger logger = LoggerFactory.getLogger(NetconfClientSessionNegotiator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiator.class);
private static final XPathExpression sessionIdXPath = XMLNetconfUtil
.compileXPath("/netconf:hello/netconf:session-id");
// If exi should be used, try to initiate exi communication
// Call negotiationSuccessFul after exi negotiation is finished successfully or not
if (shouldUseExi(netconfMessage)) {
- logger.debug("Netconf session {} should use exi.", session);
+ LOG.debug("Netconf session {} should use exi.", session);
NetconfStartExiMessage startExiMessage = (NetconfStartExiMessage) sessionPreferences.getStartExiMessage();
tryToInitiateExi(session, startExiMessage);
} else {
// Exi is not supported, release session immediately
- logger.debug("Netconf session {} isn't capable of using exi.", session);
+ LOG.debug("Netconf session {} isn't capable of using exi.", session);
negotiationSuccessful(session);
}
}
@Override
public void operationComplete(final ChannelFuture f) {
if (!f.isSuccess()) {
- logger.warn("Failed to send start-exi message {} on session {}", startExiMessage, this, f.cause());
+ LOG.warn("Failed to send start-exi message {} on session {}", startExiMessage, this, f.cause());
channel.pipeline().remove(ExiConfirmationInboundHandler.EXI_CONFIRMED_HANDLER);
} else {
- logger.trace("Start-exi message {} sent to socket on session {}", startExiMessage, this);
+ LOG.trace("Start-exi message {} sent to socket on session {}", startExiMessage, this);
}
}
});
// Ok response to start-exi, try to add exi handlers
if (NetconfMessageUtil.isOKMessage(netconfMessage)) {
- logger.trace("Positive response on start-exi call received on session {}", session);
+ LOG.trace("Positive response on start-exi call received on session {}", session);
try {
session.startExiCommunication(startExiMessage);
} catch (RuntimeException e) {
// Unable to add exi, continue without exi
- logger.warn("Unable to start exi communication, Communication will continue without exi on session {}", session, e);
+ LOG.warn("Unable to start exi communication, Communication will continue without exi on session {}", session, e);
}
// Error response
} else if(NetconfMessageUtil.isErrorMessage(netconfMessage)) {
- logger.warn(
+ LOG.warn(
"Error response to start-exi message {}, Communication will continue without exi on session {}",
XmlUtil.toString(netconfMessage.getDocument()), session);
// Unexpected response to start-exi, throwing message away, continue without exi
} else {
- logger.warn(
- "Unexpected response to start-exi message, should be ok, was {}, " +
- "Communication will continue without exi and response message will be thrown away on session {}",
- XmlUtil.toString(netconfMessage.getDocument()), session);
+ LOG.warn(
+ "Unexpected response to start-exi message, should be ok, was {}, ",XmlUtil.toString(netconfMessage.getDocument()),
+ "Communication will continue without exi and response message will be thrown away on session {}",
+ session);
}
negotiationSuccessful(session);
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
-
import io.netty.channel.Channel;
import io.netty.util.Timer;
import io.netty.util.concurrent.Promise;
-
import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
private final long connectionTimeoutMillis;
private final Timer timer;
private final EXIOptions options;
- private static final Logger logger = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class);
public NetconfClientSessionNegotiatorFactory(Timer timer,
Optional<NetconfHelloMessageAdditionalHeader> additionalHeader,
try {
helloMessage = NetconfHelloMessage.createClientHello(CLIENT_CAPABILITIES, additionalHeader);
} catch (NetconfDocumentedException e) {
- logger.error("Unable to create client hello message with capabilities {} and additional handler {}",CLIENT_CAPABILITIES,additionalHeader);
+ LOG.error("Unable to create client hello message with capabilities {} and additional handler {}",CLIENT_CAPABILITIES,additionalHeader);
throw new IllegalStateException(e);
}
package org.opendaylight.controller.netconf.client;
+import com.google.common.base.Preconditions;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.netty.util.concurrent.Promise;
-
import java.util.ArrayDeque;
import java.util.Queue;
-
import javax.annotation.concurrent.GuardedBy;
-
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
public class SimpleNetconfClientSessionListener implements NetconfClientSessionListener {
private static final class RequestEntry {
private final Promise<NetconfMessage> promise;
}
}
- private static final Logger logger = LoggerFactory.getLogger(SimpleNetconfClientSessionListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleNetconfClientSessionListener.class);
@GuardedBy("this")
private final Queue<RequestEntry> requests = new ArrayDeque<>();
while (!requests.isEmpty()) {
final RequestEntry e = requests.peek();
if (e.promise.setUncancellable()) {
- logger.debug("Sending message {}", e.request);
+ LOG.debug("Sending message {}", e.request);
clientSession.sendMessage(e.request);
break;
}
- logger.debug("Message {} has been cancelled, skipping it", e.request);
+ LOG.debug("Message {} has been cancelled, skipping it", e.request);
requests.poll();
}
}
@Override
public final synchronized void onSessionUp(NetconfClientSession clientSession) {
this.clientSession = Preconditions.checkNotNull(clientSession);
- logger.debug("Client session {} went up", clientSession);
+ LOG.debug("Client session {} went up", clientSession);
dispatchRequest();
}
@Override
public final void onSessionDown(NetconfClientSession clientSession, Exception e) {
- logger.debug("Client Session {} went down unexpectedly", clientSession, e);
+ LOG.debug("Client Session {} went down unexpectedly", clientSession, e);
tearDown(e);
}
@Override
public final void onSessionTerminated(NetconfClientSession clientSession,
NetconfTerminationReason netconfTerminationReason) {
- logger.debug("Client Session {} terminated, reason: {}", clientSession,
+ LOG.debug("Client Session {} terminated, reason: {}", clientSession,
netconfTerminationReason.getErrorMessage());
tearDown(new RuntimeException(netconfTerminationReason.getErrorMessage()));
}
@Override
public synchronized void onMessage(NetconfClientSession session, NetconfMessage message) {
- logger.debug("New message arrived: {}", message);
+ LOG.debug("New message arrived: {}", message);
final RequestEntry e = requests.poll();
if (e != null) {
e.promise.setSuccess(message);
dispatchRequest();
} else {
- logger.info("Ignoring unsolicited message {}", message);
+ LOG.info("Ignoring unsolicited message {}", message);
}
}
package org.opendaylight.controller.netconf.client;
import com.google.common.base.Optional;
+import java.net.InetSocketAddress;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
-import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.protocol.framework.ReconnectStrategy;
-import java.net.InetSocketAddress;
-
public class NetconfClientConfigurationTest {
@Test
public void testNetconfClientConfiguration() throws Exception {
package org.opendaylight.controller.netconf.client;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelPromise;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import io.netty.util.concurrent.GenericFutureListener;
+import java.net.InetSocketAddress;
+import java.util.concurrent.Future;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
-import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
-import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
-import java.net.InetSocketAddress;
-import java.util.concurrent.Future;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-
public class NetconfClientDispatcherImplTest {
@Test
public void testNetconfClientDispatcherImpl() throws Exception {
package org.opendaylight.controller.netconf.client;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
import io.netty.channel.Channel;
import io.netty.util.HashedWheelTimer;
import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
public class NetconfClientSessionNegotiatorFactoryTest {
@Test
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+
import com.google.common.base.Optional;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
pipeline = mockChannelPipeline();
future = mockChannelFuture();
channel = mockChannel();
- System.out.println("setup done");
}
private ChannelHandler mockChannelHandler() {
package org.opendaylight.controller.netconf.client;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+
import com.google.common.collect.Lists;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
+import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.netconf.client.NetconfClientSession;
-import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXICodec;
import org.openexi.proc.common.EXIOptions;
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-
public class NetconfClientSessionTest {
@Mock
package org.opendaylight.controller.netconf.client;
import com.google.common.base.Optional;
+import java.net.InetSocketAddress;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
-import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
-import java.net.InetSocketAddress;
-
public class NetconfReconnectingClientConfigurationTest {
@Test
public void testNetconfReconnectingClientConfiguration() throws Exception {
*/
package org.opendaylight.controller.netconf.client;
-import io.netty.channel.*;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.Future;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.internal.util.collections.Sets;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage;
-import java.util.Set;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.*;
-
public class SimpleNetconfClientSessionListenerTest {
private Channel channel;
package org.opendaylight.controller.netconf.client;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
-
public class SshClientChannelInitializerTest {
@Test
public void test() throws Exception {
package org.opendaylight.controller.netconf.client;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
-import static org.mockito.Mockito.*;
-
public class TcpClientChannelInitializerTest {
@Test
public void testInitializeSessionNegotiator() throws Exception {
NetconfClientDispatcherImpl netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, hashedWheelTimer);
LoginPassword authHandler = new LoginPassword("admin", "admin");
TestingNetconfClient client = new TestingNetconfClient("client", netconfClientDispatcher, getClientConfig("127.0.0.1", 1830, true, Optional.of(authHandler)));
- System.out.println(client.getCapabilities());
+ System.console().writer().println(client.getCapabilities());
}
private static NetconfClientConfiguration getClientConfig(String host ,int port, boolean ssh, Optional<? extends AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {