Move southbound to the new notification service 18/27918/4
authorLorand Jakab <lojakab@cisco.com>
Mon, 5 Oct 2015 15:19:39 +0000 (18:19 +0300)
committerLorand Jakab <lojakab@cisco.com>
Thu, 8 Oct 2015 18:17:37 +0000 (21:17 +0300)
We still use the controller project for the dependency, but this should
make it easier to switch to the mdsal project when the time comes.

Change-Id: I007c9bd27c5e5c65d3a066ae55ae5ff15007e107
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
mappingservice/southbound/src/main/config/default-config.xml
mappingservice/southbound/src/main/java/org/opendaylight/controller/config/yang/config/lfm_mappingservice_sb/impl/LfmMappingServiceSbModule.java
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundService.java
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/LispXtrSouthboundService.java
mappingservice/southbound/src/main/yang/lfm-mappingservice-sb-impl.yang
mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundServiceTest.java

index 5b5eae52f69b5225450844ef17713b9d938cfc11..5acaee1ed2559bbba5c6f6e94d8c90a4f3ae0320 100644 (file)
@@ -2,6 +2,7 @@
 <snapshot>
   <required-capabilities>
     <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+    <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
     <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice-sb:impl?module=lfm-mappingservice-sb-impl&amp;revision=2015-05-17</capability>
   </required-capabilities>
   <configuration>
             <name>binding-osgi-broker</name>
           </broker>
 
-          <notification-service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-              binding:binding-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-broker</name>
-          </notification-service>
+            <name>binding-notification-publish-adapter</name>
+          </notification-publish-service>
         </module>
       </modules>
 
@@ -49,4 +50,4 @@
 
   </configuration>
 
-</snapshot>
\ No newline at end of file
+</snapshot>
index 771189b92ffea01604b6cbba0988dba37f7ce213..d00f3eafd1a2013473480bcaa9a4f35b36b06917 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.controller.config.yang.config.lfm_mappingservice_sb.imp
 
 import java.net.DatagramPacket;
 
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin;
 import org.opendaylight.lispflowmapping.southbound.LispSouthboundRPC;
 import org.opendaylight.lispflowmapping.southbound.lisp.ILispSouthboundService;
@@ -40,7 +40,7 @@ public class LfmMappingServiceSbModule extends org.opendaylight.controller.confi
         LOG.debug("LfmMappingServiceSb Module up!");
 
         sbPlugin = new LispSouthboundPlugin();
-        sbPlugin.setNotificationProviderService(getNotificationServiceDependency());
+        sbPlugin.setNotificationPublishService(getNotificationPublishServiceDependency());
         sbPlugin.setRpcRegistryDependency(getRpcRegistryDependency());
         sbPlugin.setBindingAwareBroker(getBrokerDependency());
         sbPlugin.init();
index dda3a1def372fe79948103952ed99500584d4223..48e8e0aa1162066b33f7ad4a213487ee73878a9f 100644 (file)
@@ -18,10 +18,10 @@ import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 
 import org.apache.commons.lang3.exception.ExceptionUtils;
+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.lispflowmapping.lisp.type.LispMessage;
 import org.opendaylight.lispflowmapping.southbound.lisp.ILispSouthboundService;
@@ -44,7 +44,7 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
     private LispIoThread xtrThread;
     private LispSouthboundService lispSouthboundService;
     private LispXtrSouthboundService lispXtrSouthboundService;
-    private NotificationProviderService notificationService;
+    private NotificationPublishService notificationPublishService;
     private RpcProviderRegistry rpcRegistry;
     private BindingAwareBroker broker;
     private volatile DatagramSocket socket = null;
@@ -65,8 +65,8 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
         synchronized (startLock) {
             lispSouthboundService = new LispSouthboundService(this);
             lispXtrSouthboundService = new LispXtrSouthboundService();
-            lispSouthboundService.setNotificationProvider(this.notificationService);
-            lispXtrSouthboundService.setNotificationProvider(this.notificationService);
+            lispSouthboundService.setNotificationProvider(this.notificationPublishService);
+            lispXtrSouthboundService.setNotificationProvider(this.notificationPublishService);
             if (bindingAddress == null) {
                 setLispAddress("0.0.0.0");
             }
@@ -74,8 +74,8 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
         }
     }
 
-    public void setNotificationProviderService(NotificationProviderService notificationService) {
-        this.notificationService = notificationService;
+    public void setNotificationPublishService(NotificationPublishService notificationService) {
+        this.notificationPublishService = notificationService;
     }
 
     public void setRpcRegistryDependency(RpcProviderRegistry rpcRegistry) {
index e9a075d1f5b1f62f22824a79781f9a9cb273f402..6bab0314cb671a460fb4f1aca5d4ce03b4cf4c82 100644 (file)
@@ -12,7 +12,7 @@ import java.net.DatagramPacket;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin;
 import org.opendaylight.lispflowmapping.southbound.LispSouthboundStats;
 import org.opendaylight.lispflowmapping.southbound.util.LispNotificationHelper;
@@ -40,7 +40,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class LispSouthboundService implements ILispSouthboundService {
-    private NotificationProviderService notificationProvider;
+    private NotificationPublishService notificationPublishService;
     protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundService.class);
 
     private final LispSouthboundPlugin lispSbPlugin;
@@ -53,8 +53,8 @@ public class LispSouthboundService implements ILispSouthboundService {
         }
     }
 
-    public void setNotificationProvider(NotificationProviderService nps) {
-        this.notificationProvider = nps;
+    public void setNotificationProvider(NotificationPublishService nps) {
+        this.notificationPublishService = nps;
     }
 
     public void handlePacket(DatagramPacket packet) {
@@ -105,14 +105,16 @@ public class LispSouthboundService implements ILispSouthboundService {
             transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressFromInetAddress(finalSourceAddress));
             transportAddressBuilder.setPort(new PortNumber(port));
             requestMappingBuilder.setTransportAddress(transportAddressBuilder.build());
-            if (notificationProvider != null) {
-                notificationProvider.publish(requestMappingBuilder.build());
+            if (notificationPublishService != null) {
+                notificationPublishService.putNotification(requestMappingBuilder.build());
                 LOG.trace("MapRequest was published!");
             } else {
                 LOG.warn("Notification Provider is null!");
             }
         } catch (RuntimeException re) {
             throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len=" + inBuffer.capacity() + ")", re);
+        } catch (InterruptedException e) {
+            LOG.warn("Notification publication interrupted!");
         }
     }
 
@@ -145,14 +147,16 @@ public class LispSouthboundService implements ILispSouthboundService {
             transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressFromInetAddress(sourceAddress));
             transportAddressBuilder.setPort(new PortNumber(port));
             addMappingBuilder.setTransportAddress(transportAddressBuilder.build());
-            if (notificationProvider != null) {
-                notificationProvider.publish(addMappingBuilder.build());
+            if (notificationPublishService != null) {
+                notificationPublishService.putNotification(addMappingBuilder.build());
                 LOG.trace("MapRegister was published!");
             } else {
                 LOG.warn("Notification Provider is null!");
             }
         } catch (RuntimeException re) {
             throw new LispMalformedPacketException("Couldn't deserialize Map-Register (len=" + inBuffer.capacity() + ")", re);
+        } catch (InterruptedException e) {
+            LOG.warn("Notification publication interrupted!");
         }
     }
 
@@ -165,14 +169,16 @@ public class LispSouthboundService implements ILispSouthboundService {
             transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressFromInetAddress(sourceAddress));
             transportAddressBuilder.setPort(new PortNumber(port));
             gotMapNotifyBuilder.setTransportAddress(transportAddressBuilder.build());
-            if (notificationProvider != null) {
-                notificationProvider.publish(gotMapNotifyBuilder.build());
+            if (notificationPublishService != null) {
+                notificationPublishService.putNotification(gotMapNotifyBuilder.build());
                 LOG.trace("MapNotify was published!");
             } else {
                 LOG.warn("Notification Provider is null!");
             }
         } catch (RuntimeException re) {
             throw new LispMalformedPacketException("Couldn't deserialize Map-Notify (len=" + inBuffer.capacity() + ")", re);
+        } catch (InterruptedException e) {
+            LOG.warn("Notification publication interrupted!");
         }
     }
 
@@ -185,14 +191,16 @@ public class LispSouthboundService implements ILispSouthboundService {
             transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressFromInetAddress(sourceAddress));
             transportAddressBuilder.setPort(new PortNumber(port));
             gotMapReplyBuilder.setTransportAddress(transportAddressBuilder.build());
-            if (notificationProvider != null) {
-                notificationProvider.publish(gotMapReplyBuilder.build());
+            if (notificationPublishService != null) {
+                notificationPublishService.putNotification(gotMapReplyBuilder.build());
                 LOG.trace("MapReply was published!");
             } else {
                 LOG.warn("Notification Provider is null!");
             }
         } catch (RuntimeException re) {
             throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + inBuffer.capacity() + ")", re);
+        } catch (InterruptedException e) {
+            LOG.warn("Notification publication interrupted!");
         }
     }
 
index ce40e902f71ae8935b48670b040b2f3de1440941..4cda9aaedbe6e35247c6197d6be86a7c5ac18c54 100644 (file)
@@ -12,7 +12,7 @@ import java.net.DatagramPacket;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.lispflowmapping.southbound.util.LispNotificationHelper;
 import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
 import org.opendaylight.lispflowmapping.lisp.type.LispMessageEnum;
@@ -31,11 +31,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class LispXtrSouthboundService implements ILispSouthboundService {
-    private NotificationProviderService notificationProvider;
+    private NotificationPublishService notificationPublishService;
     protected static final Logger LOG = LoggerFactory.getLogger(LispXtrSouthboundService.class);
 
-    public void setNotificationProvider(NotificationProviderService nps) {
-        this.notificationProvider = nps;
+    public void setNotificationProvider(NotificationPublishService nps) {
+        this.notificationPublishService = nps;
     }
 
     public void handlePacket(DatagramPacket packet) {
@@ -66,14 +66,16 @@ public class LispXtrSouthboundService implements ILispSouthboundService {
             transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressFromInetAddress(finalSourceAddress));
             transportAddressBuilder.setPort(new PortNumber(LispMessage.PORT_NUM));
             requestMappingBuilder.setTransportAddress(transportAddressBuilder.build());
-            if (notificationProvider != null) {
-                notificationProvider.publish(requestMappingBuilder.build());
+            if (notificationPublishService != null) {
+                notificationPublishService.putNotification(requestMappingBuilder.build());
                 LOG.trace("MapRequest was published!");
             } else {
                 LOG.warn("Notification Provider is null!");
             }
         } catch (RuntimeException re) {
             throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len=" + inBuffer.capacity() + ")", re);
+        } catch (InterruptedException e) {
+            LOG.warn("Notification publication interrupted!");
         }
     }
 
@@ -84,15 +86,16 @@ public class LispXtrSouthboundService implements ILispSouthboundService {
             XtrReplyMappingBuilder replyMappingBuilder = new XtrReplyMappingBuilder();
             replyMappingBuilder.setMapReply(LispNotificationHelper.convertMapReply(reply));
 
-            if (notificationProvider != null) {
-                notificationProvider.publish(replyMappingBuilder.build());
+            if (notificationPublishService != null) {
+                notificationPublishService.putNotification(replyMappingBuilder.build());
                 LOG.trace("MapReply was published!");
             } else {
                 LOG.warn("Notification Provider is null!");
             }
         } catch (RuntimeException re) {
             throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + buffer.capacity() + ")", re);
+        } catch (InterruptedException e) {
+            LOG.warn("Notification publication interrupted!");
         }
-
     }
 }
index 4b23ae0599b6bd04926b280dc0e97b7b5b1a44fe..f0098ec81803a0892eeb11b6187b85e0cb74cd18 100644 (file)
@@ -7,6 +7,7 @@ module lfm-mappingservice-sb-impl {
   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 lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
 
   description
@@ -39,11 +40,11 @@ module lfm-mappingservice-sb-impl {
           }
       }
 
-      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;
               }
           }
       }
index 7efa1b02469c1b684ead9038a1e34463a9c03530..d10c1b96cbf76376699e85c81ceb397949cc2b9c 100644 (file)
@@ -26,7 +26,7 @@ import org.jmock.api.Invocation;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.lispflowmapping.lisp.type.AddressFamilyNumberEnum;
 import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
 import org.opendaylight.lispflowmapping.lisp.type.LispMessageEnum;
@@ -60,7 +60,7 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 public class LispSouthboundServiceTest extends BaseTestCase {
 
     private LispSouthboundService testedLispService;
-    private NotificationProviderService nps;
+    private NotificationPublishService nps;
     private byte[] mapRequestPacket;
     private byte[] mapRegisterPacket;
     private ValueSaverAction<Notification> lispNotificationSaver;
@@ -96,7 +96,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
         // mapResolver = context.mock(IMapResolver.class);
         // mapServer = context.mock(IMapServer.class);
         testedLispService = new LispSouthboundService(null);
-        nps = context.mock(NotificationProviderService.class);
+        nps = context.mock(NotificationPublishService.class);
         testedLispService.setNotificationProvider(nps);
         lispNotificationSaver = new ValueSaverAction<Notification>();
         // mapRegisterSaver = new ValueSaverAction<MapRegister>();
@@ -227,7 +227,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
                 + "0060   ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 " //
                 + "0070   00 01 c0 a8 88 33"));
 
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
 
         handleMapRegisterPacket(mapRegisterPacket);
 
@@ -262,7 +262,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
                 + "0060   01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 " //
                 + "0070   00 01 0a 00 3a 9c"));
 
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
 
         handleMapRegisterPacket(mapRegisterPacket);
 
@@ -276,7 +276,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
 
     @Test
     public void mapRegister__VerifyBasicFields() throws Exception {
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         handleMapRegisterPacket(mapRegisterPacket);
 
         EidToLocatorRecord eidToLocator = lastMapRegister().getEidToLocatorRecord().get(0);
@@ -289,7 +289,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
     @Test
     @Ignore
     public void mapRegister__NoResponseFromMapServerShouldReturnNullPacket() throws Exception {
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         mapNotifyBuilder = null;
 
         assertNull(handleMapRegisterPacket(mapRegisterPacket));
@@ -412,7 +412,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
 
     @Test
     public void mapRequest__VerifyBasicFields() throws Exception {
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         handleMapRequestAsByteArray(mapRequestPacket);
         List<EidRecord> eids = lastMapRequest().getEidRecord();
         assertEquals(1, eids.size());
@@ -452,7 +452,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
                 + "00a0   00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 " //
                 + "00b0   00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
 
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         // ret(mapReply);
 
         handleMapRequestAsByteArray(mapRequestPacket);
@@ -480,7 +480,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
                 + "0090   00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 " //
                 + "00a0   00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 " //
                 + "00b0   00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         // ret(mapReply);
 
         DatagramPacket replyPacket = handleMapRequestPacket(mapRequestPacket);
@@ -502,7 +502,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
                 + "0070   10 00 00 00 00 01 99 10 fe 01 01 64 ff 00 00 05 " //
                 + "0080   00 01 0a 00 01 26"));
 
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         // ret(mapReply);
 
         handleMapRequestAsByteArray(mapRequestPacket);
@@ -677,13 +677,16 @@ public class LispSouthboundServiceTest extends BaseTestCase {
                 + "0080   01 64 ff 00 00 05 00 01 0a 01 00 6f 06 64 ff 00 " //
                 + "0090   00 05 00 01 c0 a8 88 33"));
 
-        oneOf(nps).publish(with(lispNotificationSaver));
+        oneOf(nps).putNotification(with(lispNotificationSaver));
         handleMapRequestAsByteArray(mapRequestPacket);
 
     }
 
     private void stubMapRegister(final boolean setNotifyFromRegister) {
-        allowing(nps).publish(with(lispNotificationSaver));
+        try {
+            allowing(nps).putNotification(with(lispNotificationSaver));
+        } catch (InterruptedException e) {
+        }
         will(new SimpleAction() {
 
             @Override
@@ -697,7 +700,10 @@ public class LispSouthboundServiceTest extends BaseTestCase {
     }
 
     private void stubHandleRequest() {
-        allowing(nps).publish(wany(Notification.class));
+        try {
+            allowing(nps).putNotification(wany(Notification.class));
+        } catch (InterruptedException e) {
+        }
     }
 
     private byte[] handleMapRequestAsByteArray(byte[] inPacket) {
@@ -777,7 +783,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
     // + "40 05 c0 a8 88 0a 01 02 " // MAC (ITR-RLOC #1 of 2)
     // + "00 01 01 02 03 04 " // IP (ITR-RLOC #2 of 2)
     // + "00 20 00 01 01 02 03 04").array();
-    // oneOf(nps).publish(with(lispNotificationSaver));
+    // oneOf(nps).putNotification(with(lispNotificationSaver));
     // // ret(mapReply);
     // DatagramPacket packet = handleMapRequestPacket(mapRequestPacket);
     // assertEquals(2, lastMapRequest().getItrRlocs().size());
@@ -794,7 +800,7 @@ public class LispSouthboundServiceTest extends BaseTestCase {
     // + "00 01 01 02 03 04 " // IP (ITR-RLOC #1 of 2)
     // + "00 01 c0 a8 88 0a " // MAC (ITR-RLOC #2 of 2)
     // + "00 20 00 01 01 02 03 04").array();
-    // oneOf(nps).publish(with(lispNotificationSaver));
+    // oneOf(nps).putNotification(with(lispNotificationSaver));
     // // ret(mapReply);
     // DatagramPacket packet = handleMapRequestPacket(mapRequestPacket);
     // assertEquals(2, lastMapRequest().getItrRloc().size());