import java.util.Collections;
import java.util.Set;
import javax.annotation.Nonnull;
+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.DataTreeModification;
import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* Listens on capabilities changes in data store and publishes them to base
* netconf notification stream listener.
*/
-final class CapabilityChangeNotificationProducer extends OperationalDatastoreListener<Capabilities> {
+public final class CapabilityChangeNotificationProducer extends OperationalDatastoreListener<Capabilities> {
private static final InstanceIdentifier<Capabilities> CAPABILITIES_INSTANCE_IDENTIFIER =
InstanceIdentifier.create(NetconfState.class).child(Capabilities.class);
+
private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
+ private final ListenerRegistration capabilityChangeListenerRegistration;
- public CapabilityChangeNotificationProducer(BaseNotificationPublisherRegistration baseNotificationPublisherRegistration) {
+ public CapabilityChangeNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
+ final DataBroker dataBroker) {
super(CAPABILITIES_INSTANCE_IDENTIFIER);
- this.baseNotificationPublisherRegistration = baseNotificationPublisherRegistration;
+ this.baseNotificationPublisherRegistration = netconfNotificationCollector.registerBaseNotificationPublisher();
+ this.capabilityChangeListenerRegistration = registerOnChanges(dataBroker);
}
@Override
netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
baseNotificationPublisherRegistration.onCapabilityChanged(netconfCapabilityChangeBuilder.build());
}
+
+ /**
+ * Invoke by blueprint
+ */
+ public void close() {
+ if (baseNotificationPublisherRegistration != null) {
+ baseNotificationPublisherRegistration.close();
+ }
+ if (capabilityChangeListenerRegistration != null) {
+ capabilityChangeListenerRegistration.close();
+ }
+ }
}
package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory;
-import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfMdsalNotificationMapperModule extends AbstractNetconfMdsalNotificationMapperModule {
+
+ private BundleContext bundleContext;
-public class NetconfMdsalNotificationMapperModule extends org.opendaylight.controller.config.yang.netconf.mdsal.notification.AbstractNetconfMdsalNotificationMapperModule {
public NetconfMdsalNotificationMapperModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
@Override
public java.lang.AutoCloseable createInstance() {
- final NetconfNotificationCollector notificationCollector = getNotificationCollectorDependency();
-
- final NotificationToMdsalWriter notificationToMdsalWriter = new NotificationToMdsalWriter(notificationCollector);
- getBindingAwareBrokerDependency().registerProvider(notificationToMdsalWriter);
- final DataBroker dataBroker = getDataBrokerDependency();
-
- final OperationalDatastoreListener capabilityNotificationProducer =
- new CapabilityChangeNotificationProducer(notificationCollector.registerBaseNotificationPublisher());
- final ListenerRegistration capabilityChangeListenerRegistration = capabilityNotificationProducer.registerOnChanges(dataBroker);
-
- final OperationalDatastoreListener sessionNotificationProducer =
- new SessionNotificationProducer(notificationCollector.registerBaseNotificationPublisher());
- final ListenerRegistration sessionListenerRegistration = sessionNotificationProducer.registerOnChanges(dataBroker);
-
- final NetconfNotificationOperationServiceFactory netconfNotificationOperationServiceFactory =
- new NetconfNotificationOperationServiceFactory(getNotificationRegistryDependency()) {
- @Override
- public void close() {
- super.close();
- notificationToMdsalWriter.close();
- capabilityChangeListenerRegistration.close();
- sessionListenerRegistration.close();
- getAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
+ final WaitingServiceTracker<NetconfOperationServiceFactory> tracker =
+ WaitingServiceTracker.create(NetconfOperationServiceFactory.class, bundleContext, "(type=mdsal-netconf-notification)");
+ final NetconfOperationServiceFactory service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+ return Reflection.newProxy(AutoCloseableNetconfOperationServiceFactory.class, new AbstractInvocationHandler() {
+ @Override
+ protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("close")) {
+ tracker.close();
+ return null;
+ } else {
+ return method.invoke(service, args);
}
- };
+ }
+ });
+ }
- getAggregatorDependency().onAddNetconfOperationServiceFactory(netconfNotificationOperationServiceFactory);
+ void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
- return netconfNotificationOperationServiceFactory;
+ private static interface AutoCloseableNetconfOperationServiceFactory extends NetconfOperationServiceFactory, AutoCloseable {
}
}
*/
package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
-public class NetconfMdsalNotificationMapperModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.notification.AbstractNetconfMdsalNotificationMapperModuleFactory {
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfMdsalNotificationMapperModuleFactory extends AbstractNetconfMdsalNotificationMapperModuleFactory {
+
+ @Override
+ public NetconfMdsalNotificationMapperModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ NetconfMdsalNotificationMapperModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+ NetconfMdsalNotificationMapperModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+ oldInstance, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+
+ @Override
+ public NetconfMdsalNotificationMapperModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ NetconfMdsalNotificationMapperModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
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.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.netconf.notifications.NotificationRegistration;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
* Listens on changes in netconf notification stream availability and writes
* changes to the data store.
*/
-final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener, BindingAwareProvider {
+public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener {
private static final Logger LOG = LoggerFactory.getLogger(NotificationToMdsalWriter.class);
private final NetconfNotificationCollector netconfNotificationCollector;
+ private final DataBroker dataBroker;
private NotificationRegistration notificationRegistration;
- private DataBroker dataBroker;
- public NotificationToMdsalWriter(NetconfNotificationCollector netconfNotificationCollector) {
+ public NotificationToMdsalWriter(final NetconfNotificationCollector netconfNotificationCollector,
+ final DataBroker dataBroker) {
this.netconfNotificationCollector = netconfNotificationCollector;
+ this.dataBroker = dataBroker;
}
@Override
notificationRegistration.close();
}
- @Override
- public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
- dataBroker = session.getSALService(DataBroker.class);
+ /**
+ * Invoke by blueprint
+ */
+ public void start() {
notificationRegistration = netconfNotificationCollector.registerStreamListener(this);
}
import com.google.common.base.Preconditions;
import java.util.Collection;
import javax.annotation.Nonnull;
+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.DataTreeModification;
import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdOrZeroType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEndBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStartBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private static final InstanceIdentifier<Session> SESSION_INSTANCE_IDENTIFIER =
InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class);
+
private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
+ private final ListenerRegistration sessionListenerRegistration;
- public SessionNotificationProducer(BaseNotificationPublisherRegistration baseNotificationPublisherRegistration) {
+ public SessionNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
+ final DataBroker dataBroker) {
super(SESSION_INSTANCE_IDENTIFIER);
- this.baseNotificationPublisherRegistration = baseNotificationPublisherRegistration;
+
+ this.baseNotificationPublisherRegistration = netconfNotificationCollector.registerBaseNotificationPublisher();
+ this.sessionListenerRegistration = registerOnChanges(dataBroker);
}
@Override
baseNotificationPublisherRegistration.onSessionEnded(sessionEnd);
}
+
+ /**
+ * Invoke by blueprint
+ */
+ public void close() {
+ if (baseNotificationPublisherRegistration != null) {
+ baseNotificationPublisherRegistration.close();
+ }
+ if (sessionListenerRegistration != null) {
+ sessionListenerRegistration.close();
+ }
+ }
}
import java.util.Collections;
import java.util.Set;
import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
import org.opendaylight.netconf.api.monitoring.CapabilityListener;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
public class NetconfNotificationOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
private final NetconfNotificationRegistry netconfNotificationRegistry;
+ private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
- private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
- @Override
- public void close() throws Exception {
- // NOOP
- }
- };
-
- public NetconfNotificationOperationServiceFactory(NetconfNotificationRegistry netconfNotificationRegistry) {
+ public NetconfNotificationOperationServiceFactory(final NetconfNotificationRegistry netconfNotificationRegistry,
+ final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener) {
this.netconfNotificationRegistry = netconfNotificationRegistry;
+ this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
+
+ this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
}
@Override
@Override
public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- return AUTO_CLOSEABLE;
+ return NoopAutoCloseable.INSTANCE;
}
@Override
public void close() {
+ this.netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:restart-dependents-on-updates="true">
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default"/>
+ <reference id="netconfOperationServiceFactoryListener"
+ interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
+ odl:type="mapper-aggregator-registry"/>
+
+ <!--This is the MD-SAL netconf server notification blueprint xml file-->
+
+ <bean id="netconfNotificationManager"
+ class="org.opendaylight.netconf.notifications.impl.NetconfNotificationManager"
+ destroy-method="close">
+ </bean>
+ <service ref="netconfNotificationManager"
+ interface="org.opendaylight.netconf.notifications.NetconfNotificationRegistry"
+ odl:type="netconf-notification-manager">
+ </service>
+ <service ref="netconfNotificationManager"
+ interface="org.opendaylight.netconf.notifications.NetconfNotificationCollector"
+ odl:type="netconf-notification-manager">
+ </service>
+
+ <bean id="notificationToMdsalWriter"
+ class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter"
+ init-method="start"
+ destroy-method="close">
+ <argument ref="netconfNotificationManager"/>
+ <argument ref="dataBroker"/>
+ </bean>
+
+ <bean id="capabilityChangeNotificationProducer"
+ class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer"
+ destroy-method="close">
+ <argument ref="netconfNotificationManager"/>
+ <argument ref="dataBroker"/>
+ </bean>
+
+ <bean id="sessionNotificationProducer"
+ class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.SessionNotificationProducer"
+ destroy-method="close">
+ <argument ref="netconfNotificationManager"/>
+ <argument ref="dataBroker"/>
+ </bean>
+
+ <bean id="netconfNotificationOperationServiceFactory"
+ class="org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory"
+ destroy-method="close">
+ <argument ref="netconfNotificationManager"/>
+ <argument ref="netconfOperationServiceFactoryListener"/>
+ </bean>
+ <service ref="netconfNotificationOperationServiceFactory"
+ interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory"
+ odl:type="mdsal-netconf-notification"/>
+</blueprint>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2016 Inocybe Technologies 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:restart-dependents-on-updates="true">
-
- <!--This is the MD-SAL netconf server notification mapper blueprint xml file-->
-
- <bean id="netconfNotificationManager"
- class="org.opendaylight.netconf.notifications.impl.NetconfNotificationManager"
- destroy-method="close">
- </bean>
- <service ref="netconfNotificationManager"
- interface="org.opendaylight.netconf.notifications.NetconfNotificationRegistry"
- odl:type="netconf-notification-manager">
- <service-properties>
- <entry key="config-module-namespace" value="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"/>
- <entry key="config-module-name" value="netconf-notification-registry"/>
- <entry key="config-instance-name" value="netconf-notification-manager"/>
- </service-properties>
- </service>
- <service ref="netconfNotificationManager"
- interface="org.opendaylight.netconf.notifications.NetconfNotificationCollector"
- odl:type="netconf-notification-manager">
- <service-properties>
- <entry key="config-module-namespace" value="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"/>
- <entry key="config-module-name" value="netconf-notification-collector"/>
- <entry key="config-instance-name" value="netconf-notification-manager"/>
- </service-properties>
- </service>
-</blueprint>
case netconf-mdsal-notification-mapper {
when "/config:modules/config:module/config:type = 'netconf-mdsal-notification-mapper'";
- container aggregator {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity nnm:netconf-mapper-registry;
- }
- }
- }
-
- container binding-aware-broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity md-sal-binding:binding-broker-osgi-registry;
- }
- }
- }
-
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity md-sal-binding:binding-async-data-broker;
- }
- }
- }
-
- container notification-collector {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity nnn:netconf-notification-collector;
- }
- }
- }
-
- container notification-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity nnn:netconf-notification-registry;
- }
- }
- }
}
}
}
\ No newline at end of file
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+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.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class CapabilityChangeNotificationProducerTest {
+ private CapabilityChangeNotificationProducer capabilityChangeNotificationProducer;
+
@Mock
private BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
- private CapabilityChangeNotificationProducer capabilityChangeNotificationProducer;
+ @Mock
+ private ListenerRegistration listenerRegistration;
+
+ @Mock
+ private NetconfNotificationCollector netconfNotificationCollector;
+ @Mock
+ private DataBroker dataBroker;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+
+ doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+
doNothing().when(baseNotificationPublisherRegistration).onCapabilityChanged(any(NetconfCapabilityChange.class));
- capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(baseNotificationPublisherRegistration);
+
+ doReturn(baseNotificationPublisherRegistration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+
+ capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(netconfNotificationCollector, dataBroker);
}
@Test
doReturn(Futures.immediateCheckedFuture(null)).when(tx).submit();
doReturn(tx).when(dataBroker).newWriteOnlyTransaction();
- writer = new NotificationToMdsalWriter(notificationCollector);
- writer.onSessionInitiated(session);
+ writer = new NotificationToMdsalWriter(notificationCollector, dataBroker);
+ writer.start();
}
@Test
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+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.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.SessionBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
public class SessionNotificationProducerTest {
private SessionNotificationProducer publisher;
+
@Mock
private BaseNotificationPublisherRegistration registration;
+ @Mock
+ private ListenerRegistration listenerRegistration;
+
+ @Mock
+ private NetconfNotificationCollector netconfNotificationCollector;
+ @Mock
+ private DataBroker dataBroker;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- publisher = new SessionNotificationProducer(registration);
+
+ doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+
+ doNothing().when(registration).onCapabilityChanged(any(NetconfCapabilityChange.class));
doNothing().when(registration).onSessionStarted(any());
doNothing().when(registration).onSessionEnded(any());
+
+ doReturn(registration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+
+ publisher = new SessionNotificationProducer(netconfNotificationCollector, dataBroker);
}
@Test
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">prefix:netconf-mdsal-notification-mapper</type>
<name>netconf-mdsal-notification-mapper</name>
- <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
- <name>binding-data-broker</name>
- </data-broker>
- <binding-aware-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
- <name>binding-osgi-broker</name>
- </binding-aware-broker>
- <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-mapper-registry</type>
- <name>mapper-aggregator-registry</name>
- </aggregator>
- <notification-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-registry</type>
- <name>netconf-notification-manager</name>
- </notification-registry>
- <notification-collector>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-collector</type>
- <name>netconf-notification-manager</name>
- </notification-collector>
</module>
<module>
<provider>/modules/module[type='netconf-server-dispatcher-impl'][name='netconf-mdsal-server-dispatcher']</provider>
</instance>
</service>
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-northbound-mapper</type>
- <instance>
- <name>netconf-mdsal-notification-mapper</name>
- <provider>/modules/module[type='netconf-mdsal-notification-mapper'][name='netconf-mdsal-notification-mapper']</provider>
- </instance>
- </service>
<service>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-collector</type>
<instance>