package org.opendaylight.controller.config.yang.bgpcep.data.change.counter;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.protocol.data.change.counter.TopologyDataChangeCounter;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.protocol.data.change.counter.TopologyDataChangeCounterDeployer;
+import org.osgi.framework.BundleContext;
+/**
+ * @deprecated Replaced by blueprint wiring but remains for backwards compatibility until downstream users
+ * of the provided config system service are converted to blueprint.
+ */
public class DataChangeCounterImplModule extends org.opendaylight.controller.config.yang.bgpcep.data.change.counter.AbstractDataChangeCounterImplModule {
+ private BundleContext bundleContext;
+
public DataChangeCounterImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
@Override
public java.lang.AutoCloseable createInstance() {
- final TopologyDataChangeCounter counter = new TopologyDataChangeCounter(getDataProviderDependency(), getCounterId());
- final InstanceIdentifier<Topology> topoIId = InstanceIdentifier.builder(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId(getTopologyName()))).build();
- final ListenerRegistration<TopologyDataChangeCounter> registration = getDataProviderDependency().registerDataTreeChangeListener(
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, topoIId), counter);
- return new DataChangeCounterCloseable(counter, registration);
+ final WaitingServiceTracker<TopologyDataChangeCounterDeployer> deployerTracker =
+ WaitingServiceTracker.create(TopologyDataChangeCounterDeployer.class, this.bundleContext);
+ final TopologyDataChangeCounterDeployer deployer = deployerTracker
+ .waitForService(WaitingServiceTracker.FIVE_MINUTES);
+ final String counterId = getCounterId();
+ deployer.chandleCounterChange(counterId, getTopologyName());
+ return ()->{
+ deployer.deleteCounterChange(counterId);
+ deployerTracker.close();
+ };
}
- private static final class DataChangeCounterCloseable implements AutoCloseable {
-
- private final TopologyDataChangeCounter inner;
- private final ListenerRegistration<TopologyDataChangeCounter> registration;
-
- public DataChangeCounterCloseable(final TopologyDataChangeCounter inner,
- final ListenerRegistration<TopologyDataChangeCounter> registration) {
- this.inner = inner;
- this.registration = registration;
- }
-
- @Override
- public void close() {
- this.registration.close();
- this.inner.close();
- }
+ public void setBundleContext(final BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
}
-
}
*
* Do not modify this file unless it is present under src/main directory
*/
+/**
+ * @deprecated Replaced by blueprint wiring but remains for backwards compatibility until downstream users
+ * of the provided config system service are converted to blueprint.
+ */
package org.opendaylight.controller.config.yang.bgpcep.data.change.counter;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
public class DataChangeCounterImplModuleFactory extends org.opendaylight.controller.config.yang.bgpcep.data.change.counter.AbstractDataChangeCounterImplModuleFactory {
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
+ final DataChangeCounterImplModule module = (DataChangeCounterImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
+ final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
+ final DataChangeCounterImplModule module = (DataChangeCounterImplModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;
+
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.CounterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.CounterKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TopologyDataChangeCounter implements ClusteredDataTreeChangeListener<Topology>, TransactionChainListener {
+final class TopologyDataChangeCounter implements ClusteredDataTreeChangeListener<Topology>, TransactionChainListener, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(TopologyDataChangeCounter.class);
private final InstanceIdentifier<Counter> counterInstanceId;
private final BindingTransactionChain chain;
private final AtomicLong count;
+ private final ListenerRegistration<TopologyDataChangeCounter> registration;
+ private final String topologyName;
- public TopologyDataChangeCounter(final DataBroker dataBroker, final String counterId) {
+ public TopologyDataChangeCounter(final DataBroker dataBroker, final String counterId, final String topologyName) {
this.dataBroker = dataBroker;
+ this.topologyName = topologyName;
this.chain = this.dataBroker.createTransactionChain(this);
this.counterId = counterId;
this.counterInstanceId = InstanceIdentifier.builder(DataChangeCounter.class)
- .child(Counter.class, new CounterKey(this.counterId)).build();
+ .child(Counter.class, new CounterKey(this.counterId)).build();
this.count = new AtomicLong(0);
putCount(this.count.get());
+ final InstanceIdentifier<Topology> topoIId = InstanceIdentifier.builder(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(new TopologyId(topologyName))).build();
+ this.registration = this.dataBroker.registerDataTreeChangeListener(
+ new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, topoIId), this);
LOG.debug("Data change counter {} initiated", this.counterId);
}
LOG.debug("Data change #{} for counter {}", this.count.get(), this.counterId);
}
+ @Override
public void close() {
+ this.registration.close();
final WriteTransaction wTx = this.dataBroker.newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.counterInstanceId);
try {
wTx.submit().checkedGet();
- } catch (TransactionCommitFailedException except) {
+ } catch (final TransactionCommitFailedException except) {
LOG.warn("Error on remove data change counter {}", this.counterId, except);
}
this.chain.close();
private void putCount(final long count) {
final WriteTransaction wTx = this.chain.newWriteOnlyTransaction();
- Counter counter = new CounterBuilder().setId(this.counterId).setCount(count).build();
+ final Counter counter = new CounterBuilder().setId(this.counterId).setCount(count).build();
wTx.put(LogicalDatastoreType.OPERATIONAL, this.counterInstanceId, counter);
wTx.submit();
}
@Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+ public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
+ final Throwable cause) {
chain.close();
LOG.warn("Transaction chain failure. Transaction: {}", transaction, cause);
}
LOG.debug("Transaction chain successful. {}", chain);
}
+ public String getTopologyName() {
+ return this.topologyName;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.data.change.counter;
+
+import com.google.common.base.Preconditions;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgpcep.data.change.counter.config.rev170424.DataChangeCounterConfig;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TopologyDataChangeCounterDeployer implements DataTreeChangeListener<DataChangeCounterConfig>,
+ AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(TopologyDataChangeCounterDeployer.class);
+ private final static InstanceIdentifier<DataChangeCounterConfig> DATA_CHANGE_COUNTER_IID =
+ InstanceIdentifier.builder(DataChangeCounterConfig.class).build();
+ private final DataBroker dataBroker;
+ @GuardedBy("this")
+ private final Map<String, TopologyDataChangeCounter> counters = new HashMap<>();
+ private ListenerRegistration<TopologyDataChangeCounterDeployer> registration;
+
+ public TopologyDataChangeCounterDeployer(final DataBroker dataBroker) {
+ this.dataBroker = Preconditions.checkNotNull(dataBroker);
+ }
+
+ public synchronized void register() {
+ this.registration = this.dataBroker.registerDataTreeChangeListener(
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, DATA_CHANGE_COUNTER_IID), this);
+ LOG.info("Data change counter Deployer initiated");
+ }
+
+
+ @Override
+ public synchronized void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<DataChangeCounterConfig>> changes) {
+ for (final DataTreeModification<DataChangeCounterConfig> dataTreeModification : changes) {
+ final DataObjectModification<DataChangeCounterConfig> rootNode = dataTreeModification.getRootNode();
+ switch (dataTreeModification.getRootNode().getModificationType()) {
+ case DELETE:
+ deleteCounterChange(rootNode.getDataBefore().getCounterId());
+ break;
+ case SUBTREE_MODIFIED:
+ case WRITE:
+ final DataChangeCounterConfig change = rootNode.getDataAfter();
+ chandleCounterChange(change.getCounterId(), change.getTopologyName());
+ break;
+ }
+ }
+ }
+
+ public synchronized void deleteCounterChange(final String counterId) {
+ final TopologyDataChangeCounter oldCounter = this.counters.remove(counterId);
+ if (oldCounter != null) {
+ LOG.info("Data change counter Deployer deleted: {}", counterId);
+ oldCounter.close();
+ }
+ }
+
+ public synchronized void chandleCounterChange(final String counterId, final String topologyName) {
+ deleteCounterChange(counterId);
+ LOG.info("Data change counter Deployer created: {} / {}", counterId, topologyName);
+
+ final TopologyDataChangeCounter counter = new TopologyDataChangeCounter(this.dataBroker, counterId, topologyName);
+ this.counters.put(counterId, counter);
+ }
+
+ @Override
+ public synchronized void close() throws Exception {
+ LOG.info("Closing Data change counter Deployer");
+
+ if (this.registration != null) {
+ this.registration.close();
+ this.registration = null;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+ <bean id="data-change-counter-deployer" class="org.opendaylight.protocol.data.change.counter.TopologyDataChangeCounterDeployer"
+ init-method="register"
+ destroy-method="close">
+ <argument ref="dataBroker"/>
+ </bean>
+ <service ref="data-change-counter-deployer" interface="org.opendaylight.protocol.data.change.counter.TopologyDataChangeCounterDeployer"/>
+</blueprint>
\ No newline at end of file
--- /dev/null
+// vi: set smarttab et sw=4 tabstop=4:
+module odl-data-change-counter-config {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:bgpcep:data-change-counter-config";
+ prefix "dcc-cfg";
+
+ description
+ "This module contains the base YANG definitions for
+ topology data-change counter configuration.
+
+ This program and the accompanying materials are made available
+ under the terms of the Eclipse Public License v1.0 which
+ accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html";
+
+ revision "2017-04-24" {
+ description
+ "Initial revision";
+ }
+
+ list data-change-counter-config {
+ key "counter-id";
+ leaf counter-id {
+ type string;
+ mandatory true;
+ }
+ leaf topology-name {
+ type string;
+ mandatory true;
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.config.yang.bgpcep.data.change.counter;
-
-import java.util.Collections;
-import java.util.Set;
-import javax.management.ObjectName;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-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.ModuleIdentifier;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.spi.Module;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.DataChangeCounter;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.osgi.framework.BundleContext;
-
-public class DataChangeCounterImplModuleTest extends AbstractConfigTest {
-
- private static final String FACTORY_NAME = DataChangeCounterImplModuleFactory.NAME;
- private static final String INSTANCE_NAME = "data-change-counter";
- private static final String DATA_BROKER_INSTANCE_NAME = "data-broker-instance";
-
- private static final String COUNTER_ID = "counter";
- private static final String NEW_COUNTER_ID = "new-counter";
- private static final String TOPOLOGY_NAME = "test";
- private static final String NEW_TOPOLOGY_NAME = "new-test";
-
- @Mock
- private CloseableDataBroker dataBroker;
- @Mock
- private BindingTransactionChain chain;
- @Mock
- private WriteTransaction wTx;
- @Mock
- private ListenerRegistration<DataTreeChangeListener<?>> registration;
-
- @Before
- public void setUp() throws Exception {
- Mockito.doNothing().when(this.registration).close();
- Mockito.doReturn(null).when(this.wTx).submit();
- Mockito.doNothing().when(this.wTx).put(Mockito.any(LogicalDatastoreType.class), Mockito.any(), Mockito.any(DataChangeCounter.class));
- Mockito.doReturn(this.registration).when(this.dataBroker).registerDataTreeChangeListener(Mockito.any(DataTreeIdentifier.class), Mockito.any(ClusteredDataTreeChangeListener.class));
- Mockito.doNothing().when(this.wTx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any());
- Mockito.doReturn(this.chain).when(this.dataBroker).createTransactionChain(Mockito.any(TransactionChainListener.class));
- Mockito.doReturn(this.wTx).when(this.chain).newWriteOnlyTransaction();
- Mockito.doReturn(this.wTx).when(this.dataBroker).newWriteOnlyTransaction();
- Mockito.doNothing().when(this.chain).close();
- Mockito.doNothing().when(this.dataBroker).close();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new DataChangeCounterImplModuleFactory(), new MockDataBrokerModuleFct()));
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createInstance(COUNTER_ID, TOPOLOGY_NAME);
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 2, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createInstance(COUNTER_ID, TOPOLOGY_NAME);
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 2);
- }
-
- @Test
- public void testReconfigureBean() throws Exception {
- createInstance(COUNTER_ID, TOPOLOGY_NAME);
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- final DataChangeCounterImplModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
- DataChangeCounterImplModuleMXBean.class);
- mxBean.setCounterId(NEW_COUNTER_ID);
- mxBean.setTopologyName(NEW_TOPOLOGY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 1, 1);
-
- final ConfigTransactionJMXClient transaction2 = this.configRegistryClient.createTransaction();
- final DataChangeCounterImplModuleMXBean mxBean2 = transaction2.newMXBeanProxy(transaction2.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
- DataChangeCounterImplModuleMXBean.class);
- Assert.assertEquals(NEW_COUNTER_ID, mxBean2.getCounterId());
- Assert.assertEquals(NEW_TOPOLOGY_NAME, mxBean2.getTopologyName());
- }
-
- private CommitStatus createInstance(final String counterId, final String topologyName) throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- final ObjectName on = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final ObjectName dbOn = transaction.createModule(MockDataBrokerModuleFct.INSTANCE_NAME, DATA_BROKER_INSTANCE_NAME);
- final DataChangeCounterImplModuleMXBean mxBean = transaction.newMXBeanProxy(on, DataChangeCounterImplModuleMXBean.class);
- mxBean.setCounterId(counterId);
- mxBean.setTopologyName(topologyName);
- mxBean.setDataProvider(dbOn);
- return transaction.commit();
- }
-
- private final class MockDataBrokerModuleFct implements org.opendaylight.controller.config.spi.ModuleFactory {
-
- private static final String INSTANCE_NAME = "data-broker-fct";
-
- @Override
- public String getImplementationName() {
- return INSTANCE_NAME;
- }
-
- @Override
- public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
- final BundleContext bundleContext) {
- return new MockDataBrokerModule();
- }
-
- @Override
- public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
- final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
- return new MockDataBrokerModule();
- }
-
- @Override
- public boolean isModuleImplementingServiceInterface(final Class<? extends AbstractServiceInterface> serviceInterface) {
- return true;
- }
-
- @Override
- public Set<Class<? extends AbstractServiceInterface>> getImplementedServiceIntefaces() {
- final java.util.Set<Class<? extends org.opendaylight.controller.config.api.annotations.AbstractServiceInterface>> serviceIfcs2 = new java.util.HashSet<>();
- return java.util.Collections.unmodifiableSet(serviceIfcs2);
- }
-
- @Override
- public Set<? extends Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory,
- final BundleContext bundleContext) {
- return Collections.emptySet();
- }
-
- }
-
- private final class MockDataBrokerModule implements org.opendaylight.controller.config.spi.Module,org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingAsyncDataBrokerImplModuleMXBean,org.opendaylight.controller.config.yang.md.sal.binding.DataBrokerServiceInterface {
-
- @Override
- public ModuleIdentifier getIdentifier() {
- return new ModuleIdentifier(MockDataBrokerModuleFct.INSTANCE_NAME, DATA_BROKER_INSTANCE_NAME);
- }
-
- @Override
- public ObjectName getBindingMappingService() {
- return null;
- }
-
- @Override
- public void setBindingMappingService(final ObjectName bindingMappingService) {
- return;
- }
-
- @Override
- public ObjectName getDomAsyncBroker() {
- return null;
- }
-
- @Override
- public void setDomAsyncBroker(final ObjectName domAsyncBroker) {
- return;
- }
-
- @Override
- public void validate() {
- return;
- }
-
- @Override
- public AutoCloseable getInstance() {
- return DataChangeCounterImplModuleTest.this.dataBroker;
- }
-
- @Override
- public ObjectName getSchemaService() {
- return null;
- }
-
- @Override
- public void setSchemaService(final ObjectName schemaService) {
- return;
- }
-
- @Override
- public boolean canReuse(final Module arg0) {
- return true;
- }
-
- }
-
- private interface CloseableDataBroker extends DataBroker, AutoCloseable {
- }
-
-}
private static final String COUNTER_ID1 = "counter1";
private static final String COUNTER_ID2 = "counter2";
+ private static final String TOPOLOGY_NAME = "example-linkstate-topology";
private final InstanceIdentifier<Counter> counterInstanceId_1 = InstanceIdentifier.builder(DataChangeCounter.class)
.child(Counter.class, new CounterKey(COUNTER_ID1)).build();
private final InstanceIdentifier<Counter> counterInstanceId_2 = InstanceIdentifier.builder(DataChangeCounter.class)
@Test
public void testDataChangeCounter() throws Exception {
- final TopologyDataChangeCounter counter = new TopologyDataChangeCounter(getDataBroker(), COUNTER_ID1);
+ final TopologyDataChangeCounter counter = new TopologyDataChangeCounter(getDataBroker(), COUNTER_ID1, TOPOLOGY_NAME);
readDataOperational(getDataBroker(), this.counterInstanceId_1, count -> {
assertEquals(0, count.getCount().longValue());
return count;
@Test
public void testDataChangeCounterTwoInstances() throws Exception {
- final TopologyDataChangeCounter counter1 = new TopologyDataChangeCounter(getDataBroker(), COUNTER_ID1);
+ final TopologyDataChangeCounter counter1 = new TopologyDataChangeCounter(getDataBroker(), COUNTER_ID1, TOPOLOGY_NAME);
readDataOperational(getDataBroker(), this.counterInstanceId_1, count -> {
assertEquals(0, count.getCount().longValue());
return count;
});
- final TopologyDataChangeCounter counter2 = new TopologyDataChangeCounter(getDataBroker(), COUNTER_ID2);
+ final TopologyDataChangeCounter counter2 = new TopologyDataChangeCounter(getDataBroker(), COUNTER_ID2, TOPOLOGY_NAME);
readDataOperational(getDataBroker(), this.counterInstanceId_2, count -> {
assertEquals(0, count.getCount().longValue());
return count;