Do not use RpcService in LISPMAP components
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / LispMappingService.java
index b5bf8fc642d09f7665d7e5bb00520eb90b8c968a..45ecd3d73109850061da4ec26bed9ec2ffc383c6 100644 (file)
@@ -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;
@@ -89,7 +91,9 @@ 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;
@@ -103,7 +107,9 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
             @Reference final ClusterSingletonServiceProvider clusterSingletonService,
             @Reference final RpcConsumerRegistry rpcService, @Reference final NotificationService notificationService) {
         this.mapService = mappingService;
-        this.lispSB = rpcService.getRpcService(OdlLispSbService.class);
+        sendMapRequest = rpcService.getRpc(SendMapRequest.class);
+        sendMapReply = rpcService.getRpc(SendMapReply.class);
+        sendMapNotify = rpcService.getRpc(SendMapNotify.class);
         this.clusterSingletonService = clusterSingletonService;
         this.notificationService = notificationService;
 
@@ -116,7 +122,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 +164,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 +193,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 +224,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 +263,6 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
         }
     }
 
-    private OdlLispSbService getLispSB() {
-        return lispSB;
-    }
-
     @Override
     public void handleMapReply(MapReply reply) {
         tlsMapReply.set(reply);
@@ -283,8 +284,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