Make Map-Register cache configurable 10/39510/4
authorLorand Jakab <lojakab@cisco.com>
Mon, 30 May 2016 09:42:26 +0000 (12:42 +0300)
committerLorand Jakab <lojakab@cisco.com>
Wed, 1 Jun 2016 11:33:38 +0000 (14:33 +0300)
Change-Id: Ic86a23d257e329490bf84d49b6cfc183a1b34c47
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/lisp_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/LispSouthboundHandler.java
mappingservice/southbound/src/main/yang/odl-lisp-sb-impl.yang

index 2c9cc25207881242316029e11f17b5f0f481082e..37d6c0c15d118877a511b53e36dd567410df7df3 100644 (file)
@@ -15,6 +15,7 @@
           </type>
           <name>lisp-sb-impl-default</name>
           <bind-address>0.0.0.0</bind-address>
+          <map-register-cache>true</map-register-cache>
 
           <rpc-registry>
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
index e7ac3d1fd0809ed2d1e913a00a08f0064d8c7b8d..340c25f248b0d47c0104e58dbd9cabbeed097523 100644 (file)
@@ -38,6 +38,7 @@ public class LfmMappingServiceSbModule extends org.opendaylight.controller.confi
         sbPlugin.setRpcRegistryDependency(getRpcRegistryDependency());
         sbPlugin.setDataBroker(getDataBrokerDependency());
         sbPlugin.setLispAddress(getBindAddress());
+        sbPlugin.setMapRegisterCacheEnabled(getMapRegisterCache());
         sbPlugin.init();
 
         return sbPlugin;
index 0251bf4ad693682b27a69f4288a2272e12571e35..8a381c2e9590ba8fd13b46d9029069d1e729d6c6 100644 (file)
@@ -56,6 +56,7 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
     private volatile String bindingAddress = "0.0.0.0";
     private volatile int xtrPort = LispMessage.XTR_PORT_NUM;
     private volatile boolean listenOnXtrPort = false;
+    private boolean mapRegisterCacheEnabled = true;
     private RpcRegistration<OdlLispSbService> sbRpcRegistration;
     private NioDatagramChannel xtrChannel;
     private LispSouthboundStats statistics = new LispSouthboundStats();
@@ -76,6 +77,7 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
             lispSouthboundHandler = new LispSouthboundHandler(this);
             lispSouthboundHandler.setDataBroker(dataBroker);
             lispSouthboundHandler.setNotificationProvider(this.notificationPublishService);
+            lispSouthboundHandler.setMapRegisterCacheEnabled(mapRegisterCacheEnabled);
             lispSouthboundHandler.init();
 
             lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
@@ -259,6 +261,15 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
         this.dataBroker = dataBroker;
     }
 
+    public void setMapRegisterCacheEnabled(final boolean mapRegisterCacheEnabled) {
+        this.mapRegisterCacheEnabled = mapRegisterCacheEnabled;
+        if (mapRegisterCacheEnabled) {
+            LOG.info("Enabling Map-Register cache");
+        } else {
+            LOG.info("Disabling Map-Register cache");
+        }
+    }
+
     @Override
     public void close() throws Exception {
         unloadActions();
index 49182246a1093802249307393be05765479386c0..2d1d267d37bbbf834d085921d4d64585d7cd68a9 100644 (file)
@@ -74,6 +74,7 @@ import org.slf4j.LoggerFactory;
 public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramPacket>
         implements ILispSouthboundService, AutoCloseable {
     private MapRegisterCache mapRegisterCache;
+    private boolean mapRegisterCacheEnabled = true;
 
     /**
      * How long is record supposed to be relevant. After this time record isn't valid.
@@ -190,11 +191,14 @@ public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramP
 
     private void handleMapRegister(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
         try {
-            final Map.Entry<MapRegisterCacheKey, byte[]> artificialEntry = MapRegisterPartialDeserializer
-                    .deserializePartially(inBuffer, sourceAddress);
-            final MapRegisterCacheKey cacheKey = artificialEntry == null ? null : artificialEntry.getKey();
-
-            final MapRegisterCacheValue cacheValue = resolveCacheValue(artificialEntry);
+            Map.Entry<MapRegisterCacheKey, byte[]> artificialEntry = null;
+            MapRegisterCacheKey cacheKey = null;
+            MapRegisterCacheValue cacheValue = null;
+            if (mapRegisterCacheEnabled) {
+                artificialEntry = MapRegisterPartialDeserializer.deserializePartially(inBuffer, sourceAddress);
+                cacheKey = artificialEntry == null ? null : artificialEntry.getKey();
+                cacheValue = resolveCacheValue(artificialEntry);
+            }
             if (cacheValue != null) {
                 final MapRegisterCacheMetadata mapRegisterValue = cacheValue.getMapRegisterCacheMetadata();
                 LOG.debug("Map register message site-ID: {} xTR-ID: {} from cache.", mapRegisterValue.getSiteId(),
@@ -484,6 +488,9 @@ public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramP
         this.mapRegisterCache = mapRegisterCache;
     }
 
+    public void setMapRegisterCacheEnabled(final boolean mapRegisterCacheEnabled) {
+        this.mapRegisterCacheEnabled = mapRegisterCacheEnabled;
+    }
 
     public void init() {
         Preconditions.checkNotNull(dataBroker);
index bcffac366adea6d3f085998413e85afb800e2e39..dbaf306da158c2fee14eb1c07ba4d214856be1f1 100644 (file)
@@ -64,6 +64,11 @@ module odl-lisp-sb-impl {
                 mandatory true;
             }
 
+            leaf map-register-cache {
+                type boolean;
+                mandatory true;
+            }
+
         }
     }
 }