<type xmlns:dao="urn:opendaylight:lfm:mappingservice-dao">dao:mappingservice-dao</type>
<name>mappingservice-dao-inmemorydb</name>
</dao>
- <notification-service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <name>binding-notification-broker</name>
- </notification-service>
+ <notification-publish-service>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-new-notification-publish-service</type>
+ <name>binding-notification-publish-adapter</name>
+ </notification-publish-service>
</module>
<module>
<type xmlns:shell="urn:opendaylight:params:xml:ns:yang:controller:config:lfm:mappingservice-shell:impl">shell:mappingservice-shell-impl</type>
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
<name>binding-osgi-broker</name>
</osgi-broker>
+ <notification-service>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-new-notification-service</type>
+ <name>binding-notification-adapter</name>
+ </notification-service>
<mappingservice>
<type xmlns:ms="urn:opendaylight:lfm:mappingservice">ms:mappingservice</type>
<name>mappingservice</name>
lmsService = new LispMappingService();
lmsService.setBindingAwareBroker(getOsgiBrokerDependency());
+ lmsService.setNotificationService(getNotificationServiceDependency());
lmsService.setMappingService(getMappingserviceDependency());
lmsService.initialize();
mappingService.setBindingAwareBroker(getBrokerDependency());
mappingService.setDataBroker(getDataBrokerDependency());
mappingService.setRpcProviderRegistry(getRpcRegistryDependency());
- mappingService.setNotificationService(getNotificationServiceDependency());
+ mappingService.setNotificationPublishService(getNotificationPublishServiceDependency());
mappingService.setDaoService(getDaoDependency());
mappingService.initialize();
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
import org.opendaylight.lispflowmapping.implementation.lisp.MapResolver;
import org.opendaylight.lispflowmapping.implementation.lisp.MapServer;
import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.AddMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.GotMapNotify;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.GotMapReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LispProtoListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapNotify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapRequest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.RequestMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.XtrReplyMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.XtrRequestMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.lispaddress.LispAddressContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.mapnotifymessage.MapNotifyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.mapreplymessage.MapReplyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LispMappingService implements IFlowMapping, BindingAwareProvider, IMapRequestResultHandler,
- IMapNotifyHandler, AutoCloseable {
+ IMapNotifyHandler, LispProtoListener, AutoCloseable {
protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
private volatile boolean shouldAuthenticate = true;
this.broker = broker;
}
+ public void setNotificationService(NotificationService ns) {
+ this.notificationService = ns;
+ }
+
public void setMappingService(IMappingService ms) {
LOG.trace("MappingService set in LispMappingService");
this.mapService = ms;
}
}
+ public NotificationService getNotificationService() {
+ return this.notificationService;
+ }
+
public void initialize() {
broker.registerProvider(this);
+ notificationService.registerNotificationListener(this);
mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
mapServer = new MapServer(mapService, shouldAuthenticate, smr, this, notificationService);
}
@Override
public void onSessionInitiated(ProviderContext session) {
LOG.info("Lisp Consumer session initialized!");
- notificationService = session.getSALService(NotificationService.class);
- registerNotificationListener(AddMapping.class, new MapRegisterNotificationHandler());
- registerNotificationListener(RequestMapping.class, new MapRequestNotificationHandler());
this.session = session;
LOG.info("LISP (RFC6830) Mapping Service init finished");
}
return shouldAuthenticate;
}
- public <T extends Notification> void registerNotificationListener(Class<T> notificationType,
- NotificationListener<T> listener) {
- notificationService.registerNotificationListener(notificationType, listener);
+ @Override
+ public void onAddMapping(AddMapping mapRegisterNotification) {
+ MapNotify mapNotify = handleMapRegister(mapRegisterNotification.getMapRegister());
+ if (mapNotify != null) {
+ TransportAddressBuilder tab = new TransportAddressBuilder();
+ tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
+ tab.setPort(new PortNumber(LispMessage.PORT_NUM));
+ SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
+ smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
+ smnib.setTransportAddress(tab.build());
+ getLispSB().sendMapNotify(smnib.build());
+ } else {
+ LOG.warn("got null map notify");
+ }
}
- private class MapRegisterNotificationHandler implements NotificationListener<AddMapping> {
-
- @Override
- public void onNotification(AddMapping mapRegisterNotification) {
- MapNotify mapNotify = handleMapRegister(mapRegisterNotification.getMapRegister());
- if (mapNotify != null) {
- TransportAddressBuilder tab = new TransportAddressBuilder();
- tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
- tab.setPort(new PortNumber(LispMessage.PORT_NUM));
- SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
- smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
- smnib.setTransportAddress(tab.build());
- getLispSB().sendMapNotify(smnib.build());
- } else {
- LOG.warn("got null map notify");
- }
+ @Override
+ public void onRequestMapping(RequestMapping mapRequestNotification) {
+ MapReply mapReply = handleMapRequest(mapRequestNotification.getMapRequest());
+ if (mapReply != null) {
+ SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder();
+ smrib.setMapReply((new MapReplyBuilder(mapReply).build()));
+ smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
+ getLispSB().sendMapReply(smrib.build());
+ } else {
+ LOG.warn("got null map reply");
}
}
- private class MapRequestNotificationHandler implements NotificationListener<RequestMapping> {
-
- @Override
- public void onNotification(RequestMapping mapRequestNotification) {
- MapReply mapReply = handleMapRequest(mapRequestNotification.getMapRequest());
- if (mapReply != null) {
- SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder();
- smrib.setMapReply((new MapReplyBuilder(mapReply).build()));
- smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
- getLispSB().sendMapReply(smrib.build());
- } else {
- LOG.warn("got null map reply");
- }
- }
+ @Override
+ public void onGotMapReply(GotMapReply notification) {
+ LOG.debug("Received GotMapReply notification, ignoring");
+ }
+
+ @Override
+ public void onGotMapNotify(GotMapNotify notification) {
+ LOG.debug("Received GotMapNotify notification, ignoring");
+ }
+
+ @Override
+ public void onXtrRequestMapping(XtrRequestMapping notification) {
+ LOG.debug("Received XtrRequestMapping notification, ignoring");
+ }
+
+ @Override
+ public void onXtrReplyMapping(XtrReplyMapping notification) {
+ LOG.debug("Received XtrReplyMapping notification, ignoring");
}
private LispSbService getLispSB() {
import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
private DataBroker dataBroker;
private RpcProviderRegistry rpcRegistry;
private BindingAwareBroker bindingAwareBroker;
- private NotificationProviderService notificationService;
+ private NotificationPublishService notificationPublishService;
private static final ConfigIni configIni = new ConfigIni();
private boolean overwritePolicy = configIni.mappingOverwriteIsSet();
this.bindingAwareBroker = broker;
}
- public void setNotificationService(NotificationProviderService notification) {
- this.notificationService = notification;
+ public void setNotificationPublishService(NotificationPublishService nps) {
+ this.notificationPublishService = nps;
}
public void setDaoService(ILispDAO dao) {
mappingSystem.initialize();
keyListener = new AuthenticationKeyDataListener(dataBroker, mappingSystem);
- mappingListener = new MappingDataListener(dataBroker, mappingSystem, notificationService);
+ mappingListener = new MappingDataListener(dataBroker, mappingSystem, notificationPublishService);
}
@Override
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.lispflowmapping.implementation.authentication.LispAuthenticationUtil;
import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
import org.opendaylight.lispflowmapping.interfaces.dao.SubscriberRLOC;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChange;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingserviceListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.SiteId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
-public class MapServer implements IMapServerAsync {
+public class MapServer implements IMapServerAsync, MappingserviceListener {
protected static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
private IMappingService mapService;
this.notifyHandler = notifyHandler;
this.notificationService = notificationService;
if (notificationService != null) {
- subscribeToMappingNotifications();
+ notificationService.registerNotificationListener(this);
}
}
return (mapRegister.getSiteId() != null) ? new SiteId(mapRegister.getSiteId()) : null;
}
- private class MappingChangedNotificationHandler implements NotificationListener<MappingChanged> {
- @Override
- public void onNotification(MappingChanged notification) {
- if (subscriptionService) {
- sendSmrs(new EidToLocatorRecordBuilder(notification.getMapping()).build(), getSubscribers(notification
- .getMapping().getLispAddressContainer()));
- if (notification.getChange().equals(MappingChange.Removed)) {
- removeSubscribers(notification.getMapping().getLispAddressContainer());
- }
+ @Override
+ public void onMappingChanged(MappingChanged notification) {
+ if (subscriptionService) {
+ sendSmrs(new EidToLocatorRecordBuilder(notification.getMapping()).build(), getSubscribers(notification
+ .getMapping().getLispAddressContainer()));
+ if (notification.getChange().equals(MappingChange.Removed)) {
+ removeSubscribers(notification.getMapping().getLispAddressContainer());
}
}
}
- private void subscribeToMappingNotifications() {
- notificationService.registerNotificationListener(MappingChanged.class, new MappingChangedNotificationHandler());
- }
-
private void sendSmrs(EidToLocatorRecord record, Set<SubscriberRLOC> subscribers) {
LispAddressContainer eid = record.getLispAddressContainer();
handleSmr(record, subscribers, notifyHandler);
import java.util.Set;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.lispflowmapping.implementation.util.MSNotificationInputUtil;
import org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.eidtolocatorrecords.EidToLocatorRecordBuilder;
public class MappingDataListener extends AbstractDataListener {
private static final Logger LOG = LoggerFactory.getLogger(MappingDataListener.class);
private IMappingSystem mapSystem;
- private NotificationProviderService notificationProvider;
+ private NotificationPublishService notificationPublishService;
- public MappingDataListener(DataBroker broker, IMappingSystem msmr, NotificationProviderService notificationProvider) {
+ public MappingDataListener(DataBroker broker, IMappingSystem msmr, NotificationPublishService nps) {
setBroker(broker);
setMappingSystem(msmr);
- setNotificationProviderService(notificationProvider);
+ setNotificationProviderService(nps);
setPath(InstanceIdentifier.create(MappingDatabase.class).child(InstanceId.class)
.child(Mapping.class));
LOG.trace("Registering Mapping listener.");
registerDataChangeListener();
}
- public void setNotificationProviderService(NotificationProviderService notificationProvider) {
- this.notificationProvider = notificationProvider;
+ public void setNotificationProviderService(NotificationPublishService nps) {
+ this.notificationPublishService = nps;
}
@Override
mapSystem.addMapping(mapping.getOrigin(), mapping.getLispAddressContainer(),
new EidToLocatorRecordBuilder(mapping).build());
- notificationProvider.publish(MSNotificationInputUtil.toMappingChanged(mapping, MappingChange.Updated));
+ try {
+ notificationPublishService.putNotification(MSNotificationInputUtil.toMappingChanged(mapping, MappingChange.Updated));
+ } catch (InterruptedException e) {
+ LOG.warn("Notification publication interrupted!");
+ }
}
}
LOG.trace("Value: {}", dataObject);
mapSystem.removeMapping(mapping.getOrigin(), mapping.getLispAddressContainer());
- notificationProvider.publish(MSNotificationInputUtil.toMappingChanged(mapping, MappingChange.Removed));
+ try {
+ notificationPublishService.putNotification(MSNotificationInputUtil.toMappingChanged(mapping, MappingChange.Removed));
+ } catch (InterruptedException e) {
+ LOG.warn("Notification publication interrupted!");
+ }
}
}
}
import config { prefix config; revision-date 2013-04-05; }
import rpc-context { prefix rpcx; revision-date 2013-06-17; }
import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+ import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
import mappingservice { prefix mappingservice; revision-date 2015-09-06; }
import mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
}
}
}
- container notification-service {
+ container notification-publish-service {
uses config:service-ref {
refine type {
mandatory true;
- config:required-identity mdsal:binding-notification-service;
+ config:required-identity sal-broker:binding-new-notification-publish-service;
}
}
}
}
}
}
+ container notification-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity sal-broker:binding-new-notification-service;
+ }
+ }
+ }
container mappingservice {
uses config:service-ref {
refine type {
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.lispflowmapping.implementation.LispMappingService;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapRequestSerializer;
import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.AddMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.EidToLocatorRecord.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.GotMapNotify;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.GotMapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LcafApplicationDataAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LcafListAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LcafSegmentAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LispAFIAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LispIpv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LispMacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LispProtoListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapNotify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.MapRequest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.ReencapHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.RequestMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.XtrReplyMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.XtrRequestMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.eidrecords.EidRecord;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.eidrecords.EidRecordBuilder;
}
+ private class XtrRequestMappingListener implements LispProtoListener {
+
+ @Override
+ public void onGotMapReply(GotMapReply notification) {
+ }
+
+ @Override
+ public void onAddMapping(AddMapping notification) {
+ }
+
+ @Override
+ public void onXtrReplyMapping(XtrReplyMapping notification) {
+ }
+
+ @Override
+ public void onRequestMapping(RequestMapping notification) {
+ }
+
+ @Override
+ public void onGotMapNotify(GotMapNotify notification) {
+ }
+
+ @Override
+ public void onXtrRequestMapping(XtrRequestMapping notification) {
+ }
+
+ }
+
public void testRecievingNonProxyOnXtrPort() throws SocketTimeoutException, SocketException, Throwable {
cleanUP();
configLispPlugin.shouldListenOnXtrPort(true);
new org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.lcafapplicationdataaddress.AddressBuilder().setPrimitiveAddress(
LispAFIConvertor.asPrimitiveIPAfiAddress(rloc)).build()).setLocalPortLow(new PortNumber(port)).build();
final MapRequest mapRequest = createNonProxyMapRequest(eid, adLcaf);
- ((LispMappingService) lms).registerNotificationListener(XtrRequestMapping.class, new NotificationListener<XtrRequestMapping>() {
+ ((LispMappingService) lms).getNotificationService().registerNotificationListener(new XtrRequestMappingListener() {
@Override
- public void onNotification(XtrRequestMapping notification) {
+ public void onXtrRequestMapping(XtrRequestMapping notification) {
assertEquals(((org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.lispaddress.lispaddresscontainer.address.Ipv4) mapRequest.getEidRecord().get(0).getLispAddressContainer().getAddress()).getIpv4Address().getIpv4Address().getValue(),
eid);
notificationCalled = true;