/**
* 1, Copy already committed modules to current transaction.
* 2, Diff: compute added and removed factories from last run, then create new modules using
- * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory)}
+ * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory, BundleContext)}
* and remove modules belonging to removed factories.
*/
void copyExistingModulesAndProcessFactoryDiff(Collection<ModuleInternalInfo> entries, List<ModuleFactory> lastListOfFactories);
return "initial";
}
};
- ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = new ServiceReferenceTransactionRegistratorFactory(){
+ ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = () -> new ServiceReferenceRegistrator() {
@Override
- public ServiceReferenceRegistrator create() {
- return new ServiceReferenceRegistrator() {
- @Override
- public String getNullableTransactionName() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ServiceReferenceJMXRegistration registerMBean(final ServiceReferenceMXBeanImpl object, final ObjectName on) throws InstanceAlreadyExistsException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void close() {
-
- }
- };
+ public String getNullableTransactionName() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ServiceReferenceJMXRegistration registerMBean(final ServiceReferenceMXBeanImpl object, final ObjectName on) throws InstanceAlreadyExistsException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void close() {
+
}
};
return new ServiceReferenceRegistryImpl(Collections.<String, ModuleFactory>emptyMap(), lookupRegistry,
public synchronized void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
String actualTransactionName = ObjectNameUtil.getTransactionName(objectName);
String expectedTransactionName = serviceReferenceRegistrator.getNullableTransactionName();
- if (writable && actualTransactionName == null || (writable && !actualTransactionName.equals(expectedTransactionName))) {
+ if (writable && actualTransactionName == null || writable && !actualTransactionName.equals(expectedTransactionName)) {
throw new IllegalArgumentException("Mismatched transaction name in " + objectName);
}
String serviceQName = ObjectNameUtil.getServiceQName(objectName);
if (writable) {
return ObjectNameUtil.createTransactionServiceON(serviceReferenceRegistrator.getNullableTransactionName(),
serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
- } else {
- return ObjectNameUtil.createReadOnlyServiceON(serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
}
+
+ return ObjectNameUtil.createReadOnlyServiceON(serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
}
@Override
return translatedDependentReadOnlyON;
}
- /**
- * {@inheritDoc}
- */
//TODO: check for cycles
@Override
public <T> T resolveInstance(final Class<T> expectedType, final ObjectName dependentReadOnlyON,
final AutoCloseable instance = module.getInstance();
if (instance == null) {
final String message = String.format(
- "Error while %s resolving instance %s. getInstance() returned null. "
- + "Expected type %s , attribute %s", this.name,
- module.getIdentifier(), expectedType, jmxAttribute
- );
+ "Error while %s resolving instance %s. getInstance() returned null. Expected type %s, attribute %s",
+ this.name, module.getIdentifier(), expectedType, jmxAttribute);
throw new JmxAttributeValidationException(message, jmxAttribute);
}
try {
return expectedType.cast(instance);
} catch (final ClassCastException e) {
final String message = String.format(
- "Instance cannot be cast to expected type. Instance class is %s , "
- + "expected type %s , attribute %s",
- instance.getClass(), expectedType, jmxAttribute
- );
+ "Instance cannot be cast to expected type. Instance class is %s, expected type %s , attribute %s",
+ instance.getClass(), expectedType, jmxAttribute);
throw new JmxAttributeValidationException(message, e, jmxAttribute);
}
}
final Module currentModule = resolveModuleInstance(objectName, jmxAttribute);
final ModuleIdentifier identifier = currentModule.getIdentifier();
- final ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = this.modulesHolder.findModuleInternalTransactionalInfo(identifier);
+ final ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = this.modulesHolder
+ .findModuleInternalTransactionalInfo(identifier);
- if(moduleInternalTransactionalInfo.hasOldModule()) {
+ if (moduleInternalTransactionalInfo.hasOldModule()) {
final Module oldModule = moduleInternalTransactionalInfo.getOldInternalInfo().getReadableModule().getModule();
return currentModule.canReuse(oldModule);
}
}
@Override
- public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final IdentityAttributeRef identityRef, final Class<T> expectedBaseClass) {
+ public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final IdentityAttributeRef identityRef,
+ final Class<T> expectedBaseClass) {
final QName qName = QName.create(identityRef.getqNameOfIdentity());
final Class<?> deserialized = this.bindingContextProvider.getBindingContext().getIdentityClass(qName);
if (deserialized == null) {
}
if (expectedBaseClass.isAssignableFrom(deserialized)) {
return (Class<T>) deserialized;
- } else {
- 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);
}
+ 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);
}
@Override
- public <T extends BaseIdentity> void validateIdentity(final IdentityAttributeRef identityRef, final Class<T> expectedBaseClass, final JmxAttribute jmxAttribute) {
+ public <T extends BaseIdentity> void validateIdentity(final IdentityAttributeRef identityRef,
+ final Class<T> expectedBaseClass, final JmxAttribute jmxAttribute) {
try {
resolveIdentity(identityRef, expectedBaseClass);
} catch (final Exception e) {
chainForDetectingCycles2);
dependentDRI.maxDependencyDepth = subDepth;
}
- if ((subDepth + 1) > maxDepth) {
+ if (subDepth + 1 > maxDepth) {
maxDepth = subDepth + 1;
}
}
String transactionName = ObjectNameUtil.getTransactionName(on);
if (transactionName != null) {
return ObjectNameUtil.withoutTransactionName(on);
- } else {
- return on;
}
+
+ return on;
}
@Override
/**
* Retrieves list of currently registered Module Factories using bundlecontext.
*/
-public class BundleContextBackedModuleFactoriesResolver implements
- ModuleFactoriesResolver {
- private static final Logger LOG = LoggerFactory
- .getLogger(BundleContextBackedModuleFactoriesResolver.class);
+public class BundleContextBackedModuleFactoriesResolver implements ModuleFactoriesResolver {
+ private static final Logger LOG = LoggerFactory.getLogger(BundleContextBackedModuleFactoriesResolver.class);
private final BundleContext bundleContext;
public BundleContextBackedModuleFactoriesResolver(
- BundleContext bundleContext) {
+ final BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
public Map<String, Map.Entry<ModuleFactory, BundleContext>> getAllFactories() {
Collection<ServiceReference<ModuleFactory>> serviceReferences;
try {
- serviceReferences = bundleContext.getServiceReferences(
- ModuleFactory.class, null);
+ serviceReferences = bundleContext.getServiceReferences(ModuleFactory.class, null);
} catch (InvalidSyntaxException e) {
throw new IllegalStateException(e);
}
// returned by a ServiceFactory does not
// implement the classes under which it was registered or the
// ServiceFactory threw an exception.
- if(factory == null) {
+ if (factory == null) {
throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found.");
}
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);
+ String error = String.format(
+ "Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
+ moduleName, conflicting.getKey(), factory);
LOG.error(error);
throw new IllegalArgumentException(error);
- } else {
- result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
- serviceReference.getBundle().getBundleContext()));
}
+
+ result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
+ serviceReference.getBundle().getBundleContext()));
}
return result;
}
final ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(
blankTransactionServiceTracker);
- final boolean scanResolvedBundlesForModuleInfo = true;
- BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker = null;
- ExtensibleBundleTracker<?> moduleFactoryBundleTracker;
- if(scanResolvedBundlesForModuleInfo) {
- moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING |
- Bundle.STOPPING | Bundle.ACTIVE, moduleInfoBundleTracker);
- moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, moduleFactoryTracker);
- } else {
- moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context,
- moduleFactoryTracker, moduleInfoBundleTracker);
- }
-
+ BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker =
+ new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE,
+ moduleInfoBundleTracker);
+ ExtensibleBundleTracker<?> moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context,
+ moduleFactoryTracker);
moduleInfoBundleTracker.open(moduleInfoResolvedBundleTracker);
// start extensible tracker
// If the system bundle (id 0) is stopping close the ConfigRegistry so it destroys all modules. On
// shutdown the system bundle is stopped first.
- if((event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID) && (event.getType() == BundleEvent.STOPPING)) {
+ if(event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID && event.getType() == BundleEvent.STOPPING) {
this.configRegistry.close();
}
}
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.io.File;
import java.io.IOException;
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;
doNothing().when(this.mockedServiceRegistration).unregister();
final RegisterServiceAnswer answer = new RegisterServiceAnswer();
doAnswer(answer).when(this.mockedContext).registerService(Matchers.<String>any(), any(), Matchers.<Dictionary<String, ?>>any());
- doAnswer(answer).when(this.mockedContext).registerService(Matchers.<Class>any(), any(), Matchers.<Dictionary<String, ?>>any());
+ doAnswer(answer).when(this.mockedContext).registerService(Matchers.<Class<?>>any(), any(), Matchers.<Dictionary<String, ?>>any());
}
@After
protected <T> T rethrowCause(final T innerObject) {
@SuppressWarnings("unchecked")
final T proxy = (T)Proxy.newProxyInstance(innerObject.getClass().getClassLoader(),
- innerObject.getClass().getInterfaces(), new InvocationHandler() {
- @Override
- public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
- try {
- return method.invoke(innerObject, args);
- } catch (final InvocationTargetException e) {
- try {
- throw e.getTargetException();
- } catch (final RuntimeMBeanException e2) {
- throw e2.getTargetException();
- }
- }
+ innerObject.getClass().getInterfaces(), (proxy1, method, args) -> {
+ try {
+ return method.invoke(innerObject, args);
+ } catch (final InvocationTargetException e) {
+ try {
+ throw e.getTargetException();
+ } catch (final RuntimeMBeanException e2) {
+ throw e2.getTargetException();
}
}
+ }
);
return proxy;
}
}
- private void registerModuleBean(TestingRuntimeBean testingRuntimeBean,
- BaseJMXRegistrator baseJMXRegistrator, ObjectName objectName)
+ private static void registerModuleBean(final TestingRuntimeBean testingRuntimeBean,
+ final BaseJMXRegistrator baseJMXRegistrator, final ObjectName objectName)
throws InstanceAlreadyExistsException {
baseJMXRegistrator.createModuleJMXRegistrator().registerMBean(
testingRuntimeBean, objectName);
}
- private void registerRuntimeBean(RuntimeBean object,
- BaseJMXRegistrator baseJMXRegistrator, ObjectName runtimeON)
- throws InstanceAlreadyExistsException {
+ private static void registerRuntimeBean(final RuntimeBean object, final BaseJMXRegistrator baseJMXRegistrator,
+ final ObjectName runtimeON) throws InstanceAlreadyExistsException {
String factoryName = ObjectNameUtil.getFactoryName(runtimeON);
String instanceName = ObjectNameUtil.getInstanceName(runtimeON);
Map<String, String> properties = ObjectNameUtil
transactionsMBeanServer = MBeanServerFactory.createMBeanServer();
Map<String, Map.Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories = new HashMap<>();
- ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(new TransactionIdentifier(transactionName123), new TransactionJMXRegistratorFactory() {
- @Override
- public TransactionJMXRegistrator create() {
- return baseJMXRegistrator.createTransactionJMXRegistrator(transactionName123);
- }
- }, currentlyRegisteredFactories);
+ ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(
+ new TransactionIdentifier(transactionName123), () ->
+ baseJMXRegistrator.createTransactionJMXRegistrator(transactionName123), currentlyRegisteredFactories);
SearchableServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
ServiceReferenceRegistryImpl.createInitialSRLookupRegistry(), txLookupRegistry, currentlyRegisteredFactories);
/**
* Tests if lookup method returns all beans with defined transaction name
- *
- * @throws Exception
*/
@Test
public void testLookupConfigBeans() {
assertEquals(1, registrations.size());
RegistrationHolder record = registrations.get(0);
assertEquals(TestingThreadPoolIfc.class, record.clazz);
- assertEquals(ImmutableMap.of("name","ref"), (Map<String, String>) record.props);
+ assertEquals(ImmutableMap.of("name","ref"), record.props);
// switch reference to scheduled
ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
assertTrue(serviceMapping.isEmpty());
}
- private void checkApspThreadCount(int fixedNrOfThreads) throws MBeanException, AttributeNotFoundException,
+ private void checkApspThreadCount(final int fixedNrOfThreads) throws MBeanException, AttributeNotFoundException,
InstanceNotFoundException, ReflectionException {
ObjectName apspON = ObjectNameUtil.createReadOnlyModuleON(TestingParallelAPSPModuleFactory.NAME, apsp1);
assertEquals(fixedNrOfThreads, platformMBeanServer.getAttribute(apspON, "MaxNumberOfThreads"));
* Simulate dependentResolver resolving its dependency identified by
* dependentName.
*/
- private void declareDependency(DependencyResolverImpl dependerResolver,
- ModuleIdentifier dependentName) {
+ private static void declareDependency(final DependencyResolverImpl dependerResolver,
+ final ModuleIdentifier dependentName) {
JmxAttribute dummyAttribute = new JmxAttribute("dummy");
dependerResolver.resolveInstance(Object.class,
ObjectNameUtil.createReadOnlyModuleON(dependentName),
dummyAttribute);
}
- private static void mockGetInstance(DependencyResolverManager tested,
- ModuleIdentifier moduleIdentifier) {
+ private static void mockGetInstance(final DependencyResolverManager tested,
+ final ModuleIdentifier moduleIdentifier) {
ModuleFactory moduleFactory = mock(ModuleFactory.class);
ModuleInternalInfo maybeOldInternalInfo = null;
private final String setSomethingString = "setSomething";
- private void assertRequireInterfaceAnnotationHasCorrectValue(
- Class<?> clazz, String methodName,
- Set<Class<?>> inspectedInterfaces,
- Class<? extends AbstractServiceInterface> expectedValue) {
+ private static void assertRequireInterfaceAnnotationHasCorrectValue(final Class<?> clazz, final String methodName,
+ final Set<Class<?>> inspectedInterfaces, final Class<? extends AbstractServiceInterface> expectedValue) {
Method setter = findMethod(clazz, methodName);
RequireInterface found = AttributeHolder
.findRequireInterfaceAnnotation(setter, inspectedInterfaces);
}
}
- private Method findMethod(Class<?> clazz, String methodName) {
+ private static Method findMethod(final Class<?> clazz, final String methodName) {
Method setter;
try {
- setter = clazz.getMethod(methodName,
- new Class[] { ObjectName.class });
+ setter = clazz.getMethod(methodName, new Class[] { ObjectName.class });
} catch (Exception e) {
throw Throwables.propagate(e);
}
return setter;
}
- private void assertDescription(Class<?> clazz, String methodName,
- Set<Class<?>> exportedInterfaces, String expectedValue) {
+ private static void assertDescription(final Class<?> clazz, final String methodName,
+ final Set<Class<?>> exportedInterfaces, final String expectedValue) {
Method setter = findMethod(clazz, methodName);
String found = AttributeHolder.findDescription(setter,
exportedInterfaces);
}
}
- private void assertDescriptionOnClass(Class<?> clazz,
- Set<Class<?>> jmxInterfaces, String expectedValue) {
- String found = AbstractDynamicWrapper.findDescription(clazz,
- jmxInterfaces);
+ private static void assertDescriptionOnClass(final Class<?> clazz, final Set<Class<?>> jmxInterfaces,
+ final String expectedValue) {
+ String found = AbstractDynamicWrapper.findDescription(clazz, jmxInterfaces);
if (expectedValue == null) {
assertNull(found);
} else {
}
}
- private void assertNoDescriptionOnClass(Class<?> clazz,
- Set<Class<?>> jmxInterfaces) {
- String found = AbstractDynamicWrapper.findDescription(clazz,
- jmxInterfaces);
+ private static void assertNoDescriptionOnClass(final Class<?> clazz, final Set<Class<?>> jmxInterfaces) {
+ String found = AbstractDynamicWrapper.findDescription(clazz, jmxInterfaces);
assertTrue(found.isEmpty());
}
public static class SuperClass {
@RequireInterface(SimpleSI.class)
@Description("descr")
- public void setSomething(ObjectName objectName) {
+ public void setSomething(final ObjectName objectName) {
}
}
public static class SubClassWithEmptyMethod extends SuperClass {
@Override
- public void setSomething(ObjectName objectName) {
+ public void setSomething(final ObjectName objectName) {
}
}
@Override
@RequireInterface(SubSI2.class)
@Description("descr2")
- public void setSomething(ObjectName objectName) {
+ public void setSomething(final ObjectName objectName) {
}
}
@Test
public void testFindAnnotation_SubClassWithAnnotation() throws Exception {
- assertDescription(SubClassWithAnnotation.class, setSomethingString,
- emptySetOfInterfaces(), "descr2\ndescr");
+ assertDescription(SubClassWithAnnotation.class, setSomethingString, emptySetOfInterfaces(), "descr2\ndescr");
try {
- assertRequireInterfaceAnnotationHasCorrectValue(
- SubClassWithAnnotation.class, setSomethingString,
- emptySetOfInterfaces(), SubSI2.class);
+ assertRequireInterfaceAnnotationHasCorrectValue(SubClassWithAnnotation.class, setSomethingString,
+ emptySetOfInterfaces(), SubSI2.class);
fail();
} catch (IllegalStateException e) {
- assertTrue(
- e.getMessage(),
- e.getMessage()
- .startsWith("Error finding @RequireInterface. More than one value specified"));
+ assertTrue(e.getMessage(),
+ e.getMessage().startsWith("Error finding @RequireInterface. More than one value specified"));
}
}
void setSomething(ObjectName objectName);
}
- public static class SubClassWithoutMethodWithInterface extends SuperClass
- implements HasSomeMethod {
+ public static class SubClassWithoutMethodWithInterface extends SuperClass implements HasSomeMethod {
}
@Override
@RequireInterface(SubSI2.class)
@Description("descr")
- public void setSomething(ObjectName objectName) {
+ public void setSomething(final ObjectName objectName) {
}
}
@Description("class")
- public static class SubClassOfSuperClassWithInterface extends
- SuperClassWithInterface {
+ public static class SubClassOfSuperClassWithInterface extends SuperClassWithInterface {
}
@Test
public void testFindAnnotation2() throws Exception {
- assertNoDescriptionOnClass(SuperClassWithInterface.class,
- emptySetOfInterfaces());
+ assertNoDescriptionOnClass(SuperClassWithInterface.class, emptySetOfInterfaces());
}
@Description("class")
interface HasSomeMethodWithAnnotations {
-
@RequireInterface(SubSI2.class)
@Description("descr")
void setSomething(ObjectName objectName);
}
- static class HasSomeMethodWithAnnotationsImpl implements
- HasSomeMethodWithAnnotations {
+ static class HasSomeMethodWithAnnotationsImpl implements HasSomeMethodWithAnnotations {
@Override
- public void setSomething(ObjectName objectName) {
+ public void setSomething(final ObjectName objectName) {
}
-
}
@Test
public void testHasSomeMethodWithAnnotationsImpl() {
HashSet<Class<?>> exportedInterfaces = Sets
.<Class<?>> newHashSet(HasSomeMethodWithAnnotations.class);
- assertRequireInterfaceAnnotationHasCorrectValue(
- HasSomeMethodWithAnnotationsImpl.class, setSomethingString,
+ assertRequireInterfaceAnnotationHasCorrectValue(HasSomeMethodWithAnnotationsImpl.class, setSomethingString,
exportedInterfaces, SubSI2.class);
- assertDescription(HasSomeMethodWithAnnotationsImpl.class,
- setSomethingString, exportedInterfaces, "descr");
+ assertDescription(HasSomeMethodWithAnnotationsImpl.class, setSomethingString, exportedInterfaces, "descr");
- assertDescriptionOnClass(
- HasSomeMethodWithAnnotationsImpl.class,
- new HashSet<>(Arrays
- .asList(HasSomeMethodWithAnnotations.class)), "class");
+ assertDescriptionOnClass(HasSomeMethodWithAnnotationsImpl.class,
+ new HashSet<>(Arrays.asList(HasSomeMethodWithAnnotations.class)), "class");
}
-
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Collections;
import javax.management.ObjectName;
verify(blankTx, times(maxAttempts)).hit();
}
- private ServiceReference<ModuleFactory> getMockServiceReference() {
+ private static ServiceReference<ModuleFactory> getMockServiceReference() {
return mock(ServiceReference.class);
}
}
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;
resolver = new BundleContextBackedModuleFactoriesResolver(bundleContext);
}
- private ModuleFactory getMockFactory(final String name) {
+ private static ModuleFactory getMockFactory(final String name) {
ModuleFactory mock = mock(ModuleFactory.class);
doReturn(name).when(mock).toString();
doReturn(name).when(mock).getImplementationName();
verify(sTracker).close();
}
- private ServiceRegistration<?> mockServiceRegistration() {
+ private static ServiceRegistration<?> mockServiceRegistration() {
ServiceRegistration<?> mock = mock(ServiceRegistration.class);
doNothing().when(mock).unregister();
return mock;
private void checkRuntimeBeans() throws Exception {
// check runtime bean - on 2 places
- for (ObjectName on : allObjectNames)
+ for (ObjectName on : allObjectNames) {
checkRuntimeBean(on);
+ }
}
- private void checkRuntimeBean(ObjectName on) throws Exception {
- assertEquals(0,
- platformMBeanServer.getAttribute(on, "ActualNumberOfThreads"));
+ private static void checkRuntimeBean(final ObjectName on) throws Exception {
+ assertEquals(0, platformMBeanServer.getAttribute(on, "ActualNumberOfThreads"));
}
- private void checkRuntimeBeanDoesNotExist(ObjectName on) throws Exception {
+ private static void checkRuntimeBeanDoesNotExist(final ObjectName on) throws Exception {
try {
checkRuntimeBean(on);
fail();
} catch (InstanceNotFoundException e) {
-
+ // No-op
}
}
configTransaction.destroyModule(ObjectNameUtil
.createTransactionModuleON(configTransaction.getTransactionName(), createdConfigBean));
configTransaction.commit();
- for (ObjectName on : allObjectNames)
+ for (ObjectName on : allObjectNames) {
checkRuntimeBeanDoesNotExist(on);
+ }
}
}
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPool;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
import org.opendaylight.controller.config.util.ConfigTransactionClient;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
}
static ObjectName createFixedThreadPool(
- ConfigTransactionJMXClient transaction)
+ final ConfigTransactionJMXClient transaction)
throws InstanceAlreadyExistsException, InstanceNotFoundException {
transaction.assertVersion(0, 1);
}
- private void testValidation(ConfigTransactionClient transaction)
+ private static void testValidation(final ConfigTransactionClient transaction)
throws InstanceAlreadyExistsException, ReflectionException,
InstanceNotFoundException, MBeanException, ConflictingVersionException {
ObjectName fixed1names = transaction.createModule(
checkThreadPools(1, numberOfThreads2);
}
- private void checkThreadPools(int expectedTotalNumberOfExecutors,
- int expectedNumberOfThreadsInLastExecutor) {
+ private static void checkThreadPools(final int expectedTotalNumberOfExecutors,
+ final int expectedNumberOfThreadsInLastExecutor) {
assertEquals(expectedTotalNumberOfExecutors,
TestingFixedThreadPool.allExecutors.size());
for (int i = 0; i < expectedTotalNumberOfExecutors - 1; i++) {
}
// return MBeanProxy for 'fixed1' and current transaction
- private TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(
- ConfigTransactionJMXClient transaction)
- throws InstanceNotFoundException {
+ private static TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(
+ final ConfigTransactionJMXClient transaction) throws InstanceNotFoundException {
ObjectName fixed1name = transaction.lookupConfigBean(
TestingFixedThreadPoolModuleFactory.NAME, fixed1);