Revert "Clustering - adding to LispMappingService." 55/43255/1
authorLorand Jakab <lojakab@cisco.com>
Fri, 5 Aug 2016 18:58:03 +0000 (13:58 -0500)
committerLorand Jakab <lojakab@cisco.com>
Fri, 5 Aug 2016 19:08:55 +0000 (14:08 -0500)
This reverts commit b83997d4c3379b5f112bb6374f0c9480c9c9f0e1.

Change-Id: I6bfe71ae0eb03ba6711b2a7d62f51f88a47e1ff2
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java
mappingservice/implementation/src/main/resources/org/opendaylight/blueprint/mappingservice.xml
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/LispMappingServiceTest.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java

index a704f21f05f5329a33bf46fe02be6f4cd52679b6..e2014a0f08cd2ea2997bcf767723ef76b86a8a48 100644 (file)
@@ -12,7 +12,6 @@ import java.util.List;
 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.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
 import org.opendaylight.lispflowmapping.implementation.lisp.MapResolver;
 import org.opendaylight.lispflowmapping.implementation.lisp.MapServer;
@@ -52,14 +51,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendM
 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.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
-import org.opendaylight.lispflowmapping.clustering.ClusterNodeModulSwitcherImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class LispMappingService implements IFlowMapping, IMapRequestResultHandler,
         IMapNotifyHandler, OdlLispProtoListener, AutoCloseable {
     protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
-    private final ClusterNodeModulSwitcherImpl clusterNodeModulSwitcher;
 
     private volatile boolean smr = ConfigIni.getInstance().smrIsSet();
     private volatile String elpPolicy = ConfigIni.getInstance().getElpPolicy();
@@ -79,12 +76,11 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
 
     public LispMappingService(final NotificationService notificationService,
             final IMappingService mappingService,
-            final OdlLispSbService odlLispService, final EntityOwnershipService entityOnwershipService) {
+            final OdlLispSbService odlLispService) {
 
         this.notificationService = notificationService;
         this.mapService = mappingService;
         this.lispSB = odlLispService;
-        clusterNodeModulSwitcher = new ClusterNodeModulSwitcherImpl(entityOnwershipService);
         LOG.debug("LispMappingService Module constructed!");
     }
 
@@ -109,13 +105,13 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
 
     public void initialize() {
         mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
-        mapServer = new MapServer(mapService, smr, this, notificationService, clusterNodeModulSwitcher);
+        mapServer = new MapServer(mapService, smr, this, notificationService);
         LOG.info("LISP (RFC6830) Mapping Service init finished");
     }
 
     public void basicInit() {
         mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
-        mapServer = new MapServer(mapService, smr, this, notificationService, clusterNodeModulSwitcher);
+        mapServer = new MapServer(mapService, smr, this, notificationService);
     }
 
     public MapReply handleMapRequest(MapRequest request) {
index 61e5b8a871d45a1f4ea23d693e209895e187597f..5faea8bf8f1813c5e09f757dfe96d58c9f8b91d6 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Set;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.lispflowmapping.clustering.ClusterNodeModulSwitcherImpl;
 import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
 import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
 import org.opendaylight.lispflowmapping.interfaces.dao.SubscriberRLOC;
@@ -57,7 +56,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev15090
 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.OdlMappingserviceListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.google.common.base.Preconditions;
@@ -66,25 +64,21 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener {
 
     protected static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
     private static final byte[] ALL_ZEROES_XTR_ID = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
-    private final ClusterNodeModulSwitcherImpl clusterNodeModulSwitcher;
     private IMappingService mapService;
     private boolean subscriptionService;
     private IMapNotifyHandler notifyHandler;
     private NotificationService notificationService;
-    private ListenerRegistration<MapServer> mapServerListenerRegistration;
 
     public MapServer(IMappingService mapService, boolean subscriptionService,
-                     IMapNotifyHandler notifyHandler, NotificationService notificationService,
-                     final ClusterNodeModulSwitcherImpl clusterNodeModulSwitcher) {
+            IMapNotifyHandler notifyHandler, NotificationService notificationService) {
         Preconditions.checkNotNull(mapService);
         this.mapService = mapService;
         this.subscriptionService = subscriptionService;
         this.notifyHandler = notifyHandler;
         this.notificationService = notificationService;
         if (notificationService != null) {
-            mapServerListenerRegistration = notificationService.registerNotificationListener(this);
+            notificationService.registerNotificationListener(this);
         }
-        this.clusterNodeModulSwitcher = clusterNodeModulSwitcher;
     }
 
     @Override
@@ -186,9 +180,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener {
     @Override
     public void onMappingChanged(MappingChanged notification) {
         if (subscriptionService) {
-            if (clusterNodeModulSwitcher.isMaster()) {
-                sendSmrs(notification.getMappingRecord(), getSubscribers(notification.getMappingRecord().getEid()));
-            }
+            sendSmrs(notification.getMappingRecord(), getSubscribers(notification.getMappingRecord().getEid()));
             if (notification.getChangeType().equals(MappingChange.Removed)) {
                 removeSubscribers(notification.getMappingRecord().getEid());
             }
index bde613ffff7b5fd1cdd6227d7155a67a8e011ed3..0f6b5a753539ac44737261f54170c612db49c36f 100644 (file)
@@ -12,8 +12,6 @@
     interface="org.opendaylight.controller.md.sal.binding.api.NotificationService" />
   <reference id="lispDAO"
     interface="org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO" />
-  <reference id="entityOwnershipService"
-     interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService" />
 
   <odl:rpc-service id="odlLispSbService"
     interface="org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.OdlLispSbService" />
@@ -44,7 +42,6 @@
     <argument ref="notificationService" />
     <argument ref="mappingService" />
     <argument ref="odlLispSbService" />
-    <argument ref="entityOwnershipService" />
   </bean>
   <service ref="lispMappingService"
     interface="org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping"
@@ -56,4 +53,4 @@
     interface="org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler"
     odl:type="default" />
   <odl:notification-listener ref="lispMappingService" />
-</blueprint>
+</blueprint>
\ No newline at end of file
index 4bdc6d439567685ada0be83b9f119b4ab4e50be8..3c53ebbea6f73f6c4e736615a221ed03905b7b64 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.lispflowmapping.implementation;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 
 import java.lang.reflect.Field;
@@ -28,9 +27,6 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
@@ -90,13 +86,12 @@ public class LispMappingServiceTest {
     private final NotificationService notificationService = Mockito.mock(NotificationService.class);
     private final IMappingService mappingService = Mockito.mock(IMappingService.class);
     private final OdlLispSbService odlLispSbService = Mockito.mock(OdlLispSbService.class);
-    private final EntityOwnershipService entityOwnershipSrvice = Mockito.mock(EntityOwnershipService.class);
 
     @InjectMocks
     private LispMappingService lispMappingService = new LispMappingService(
             notificationService,
             mappingService,
-            odlLispSbService, entityOwnershipSrvice);
+            odlLispSbService);
 
     private static final byte[] IPV4_BYTES_1 =       new byte[] {1, 2, 3, 0};
     private static final byte[] IPV4_BYTES_2 =       new byte[] {1, 2, 4, 0};
@@ -198,8 +193,6 @@ public class LispMappingServiceTest {
         Mockito.when(mapRegister.getMappingRecordItem())
                 .thenReturn(Lists.newArrayList(MAPPING_RECORD_ITEM_BUILDER.build()));
         Mockito.when(tlsMapNotifyMock.get()).thenReturn(getDefaultMapNotifyPair());
-        Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
-                (new EntityOwnershipState(true, true)));
 
         lispMappingService.onAddMapping(addMapping);
         Mockito.verify(odlLispSbService, Mockito.times(2)).sendMapNotify(Mockito.argThat(new TransportAddressMatch()));
@@ -227,8 +220,6 @@ public class LispMappingServiceTest {
                 .setMapNotify(new org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105
                         .mapnotifymessage.MapNotifyBuilder().setKeyId((short) 1).build())
                 .setTransportAddress(TRANSPORT_ADDRESS);
-        Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
-                (new EntityOwnershipState(true, true)));
 
         lispMappingService.onAddMapping(addMapping);
         Mockito.verify(odlLispSbService).sendMapNotify(smnib.build());
@@ -249,8 +240,6 @@ public class LispMappingServiceTest {
         Mockito.when(requestMapping.getTransportAddress()).thenReturn(TRANSPORT_ADDRESS_1);
         Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
         Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
-        Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
-                (new EntityOwnershipState(true, true)));
 
         // result
         final SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder()
@@ -275,8 +264,6 @@ public class LispMappingServiceTest {
         Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
         Mockito.when(tlsMapReplyMock.get()).thenReturn(null);
 
-        Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
-                (new EntityOwnershipState(true, true)));
         lispMappingService.onRequestMapping(requestMapping);
         Mockito.verifyZeroInteractions(odlLispSbService);
     }
index 939a0c22b7684ba669cbe7a236ee1ebff00d145c..a20034517cf430c3c63164af259166a1ff8606af 100644 (file)
@@ -26,7 +26,6 @@ import org.mockito.Mockito;
 import org.mockito.Spy;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.lispflowmapping.clustering.ClusterNodeModulSwitcherImpl;
 import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
 import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
 import org.opendaylight.lispflowmapping.interfaces.dao.SubscriberRLOC;
@@ -66,8 +65,6 @@ public class MapServerTest {
     @Mock private static IMappingService mapService;
     @Mock private static IMapNotifyHandler notifyHandler;
     @Mock private static NotificationService notificationService;
-    @Mock private static ClusterNodeModulSwitcherImpl clusterNodeModulSwitcher;
-
     @Spy private static Set<SubscriberRLOC> subscriberSetMock_1 = new HashSet<>();
     @Spy private static Set<SubscriberRLOC> subscriberSetMock_2 = new HashSet<>();
     @Spy private static Set<SubscriberRLOC> subscriberSetMock_3 = new HashSet<>();
@@ -142,7 +139,7 @@ public class MapServerTest {
 
     @Before
     public void init() throws NoSuchFieldException, IllegalAccessException  {
-        mapServer = new MapServer(mapService, true, notifyHandler, notificationService, clusterNodeModulSwitcher);
+        mapServer = new MapServer(mapService, true, notifyHandler, notificationService);
         subscriberSetMock_1.add(SUBSCRIBER_RLOC_1);
         subscriberSetMock_1.add(SUBSCRIBER_RLOC_2);
         subscriberSetMock_2.add(SUBSCRIBER_RLOC_3);