Bump upstreams
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / LispMappingService.java
index b5bf8fc642d09f7665d7e5bb00520eb90b8c968a..aeaa3f4d12beae6b19317168643ef5f2ac8e565a 100644 (file)
@@ -31,10 +31,10 @@ import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
 import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
 import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.binding.api.RpcService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
 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.lisp.proto.rev151105.AddMapping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify;
@@ -57,9 +57,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.ma
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.OdlLispSbService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotify;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReply;
 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.SendMapRequest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInputBuilder;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.osgi.service.component.annotations.Activate;
@@ -74,9 +76,8 @@ import org.slf4j.LoggerFactory;
         immediate = true, property = "type=default")
 public class LispMappingService implements IFlowMapping, IMapRequestResultHandler,
         IMapNotifyHandler, AutoCloseable, ClusterSingletonService {
-    private static final String LISPFLOWMAPPING_ENTITY_NAME = "lispflowmapping";
-    private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create(
-            LISPFLOWMAPPING_ENTITY_NAME);
+    private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER =
+        new ServiceGroupIdentifier("lispflowmapping");
 
     private static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
 
@@ -89,10 +90,11 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
     private ThreadLocal<Pair<MapRequest, TransportAddress>> tlsMapRequest = new ThreadLocal<>();
     private IMapResolverAsync mapResolver;
     private MapServer mapServer;
-    private OdlLispSbService lispSB;
+    private SendMapRequest sendMapRequest;
+    private SendMapReply sendMapReply;
+    private SendMapNotify sendMapNotify;
 
     private final IMappingService mapService;
-    private final ClusterSingletonServiceProvider clusterSingletonService;
     private final NotificationService notificationService;
     private final Registration listenerRegistration;
     private final Registration cssRegistration;
@@ -101,10 +103,11 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
     @Activate
     public LispMappingService(@Reference final IMappingService mappingService,
             @Reference final ClusterSingletonServiceProvider clusterSingletonService,
-            @Reference final RpcConsumerRegistry rpcService, @Reference final NotificationService notificationService) {
+            @Reference final RpcService rpcService, @Reference final NotificationService notificationService) {
         this.mapService = mappingService;
-        this.lispSB = rpcService.getRpcService(OdlLispSbService.class);
-        this.clusterSingletonService = clusterSingletonService;
+        sendMapRequest = rpcService.getRpc(SendMapRequest.class);
+        sendMapReply = rpcService.getRpc(SendMapReply.class);
+        sendMapNotify = rpcService.getRpc(SendMapNotify.class);
         this.notificationService = notificationService;
 
         // initialize
@@ -116,7 +119,6 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
                 new CompositeListener.Component<>(XtrRequestMapping.class, this::onXtrRequestMapping),
                 new CompositeListener.Component<>(XtrReplyMapping.class, this::onXtrReplyMapping),
                 new CompositeListener.Component<>(MappingKeepAlive.class, this::onMappingKeepAlive))));
-
         mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
         mapServer = new MapServer(mapService, smr, this, notificationService);
         cssRegistration = clusterSingletonService.registerClusterSingletonService(this);
@@ -159,7 +161,7 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
             SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
             smrib.setMapRequest(new MapRequestBuilder(tlsMapRequest.get().getLeft()).build());
             smrib.setTransportAddress(tlsMapRequest.get().getRight());
-            getLispSB().sendMapRequest(smrib.build());
+            sendMapRequest.invoke(smrib.build());
             return null;
         } else {
             return tlsMapReply.get();
@@ -188,7 +190,7 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
         SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
         smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
         smnib.setTransportAddress(address);
-        getLispSB().sendMapNotify(smnib.build());
+        sendMapNotify.invoke(smnib.build());
     }
 
     @VisibleForTesting
@@ -219,7 +221,7 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
             SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder();
             smrib.setMapReply(new MapReplyBuilder(mapReply).build());
             smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
-            getLispSB().sendMapReply(smrib.build());
+            sendMapReply.invoke(smrib.build());
         } else {
             LOG.debug("handleMapRequest: Got null MapReply");
         }
@@ -258,10 +260,6 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
         }
     }
 
-    private OdlLispSbService getLispSB() {
-        return lispSB;
-    }
-
     @Override
     public void handleMapReply(MapReply reply) {
         tlsMapReply.set(reply);
@@ -283,8 +281,7 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
         SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
         smrib.setMapRequest(new MapRequestBuilder(smrMapRequest).build());
         smrib.setTransportAddress(LispNotificationHelper.getTransportAddressFromRloc(subscriber));
-        getLispSB().sendMapRequest(smrib.build());
-
+        sendMapRequest.invoke(smrib.build());
     }
 
     @Override
@@ -307,7 +304,6 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
     public void close() throws Exception {
         destroy();
         cssRegistration.close();
-        clusterSingletonService.close();
         listenerRegistration.close();
     }