Remove overwrite configuration and convert it to mapping merge configuration 55/49455/1
authorShakib Ahmed <sheikahm@cisco.com>
Thu, 15 Dec 2016 21:35:18 +0000 (13:35 -0800)
committerShakib Ahmed <sheikahm@cisco.com>
Thu, 15 Dec 2016 22:38:55 +0000 (14:38 -0800)
Change-Id: I511ec249ff2f5e3c6fef2336bfc4455728a08535
Signed-off-by: Shakib Ahmed <sheikahm@cisco.com>
integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/mapcache/IMappingSystem.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/mappingservice/IMappingService.java
mappingservice/config/src/main/java/org/opendaylight/lispflowmapping/config/ConfigIni.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingSystem.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java

index 5023f7d0a08da27e51f36123cc7b3f5fc9a5261c..a706f25f1a397e1f62fe87561e3f3f292abeb205 100644 (file)
@@ -228,7 +228,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
     public void before() throws Exception {
         areWeReady();
         mapService.setLookupPolicy(IMappingService.LookupPolicy.NB_FIRST);
-        mapService.setMappingOverwrite(true);
+        mapService.setMappingMerge(false);
 
         locatorEid = LispAddressUtil.asIpv4Rloc("4.3.2.1");
         socket = initSocket(socket, LispMessage.PORT_NUM);
@@ -781,7 +781,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         final SocketReader socketReader = SocketReader.startReadingInStandaloneThread(socket);
 
         mapService.setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB);
-        mapService.setMappingOverwrite(false);
+        mapService.setMappingMerge(true);
 
         //TEST CASE 1
         multiSiteScenario.storeSouthboundMappings(true, SITE_A_SB, SITE_B_SB, SITE_C_WP_100_1_SB, SITE_D_WP_100_1_SB,
@@ -984,7 +984,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
 
     public void testMapRegisterOverwritesNoSubkey() throws SocketTimeoutException {
         cleanUP();
-        mapService.setMappingOverwrite(true);
+        mapService.setMappingMerge(false);
         Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
         Rloc rloc1Value = LispAddressUtil.asIpv4Rloc("4.3.2.1");
         Rloc rloc2Value = LispAddressUtil.asIpv4Rloc("4.3.2.2");
@@ -996,7 +996,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
 
     public void testMapRegisterDoesntOverwritesNoSubkey() throws SocketTimeoutException {
         cleanUP();
-        mapService.setMappingOverwrite(false);
+        mapService.setMappingMerge(true);
         Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
         Rloc rloc1Value = LispAddressUtil.asIpv4Rloc("4.3.2.1");
         Rloc rloc2Value = LispAddressUtil.asIpv4Rloc("4.3.2.2");
@@ -2087,7 +2087,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
 
     private void timedOutMappingRecord() {
         cleanUP();
-        mapService.setMappingOverwrite(false);
+        mapService.setMappingMerge(true);
         // mapping expires after 1 second
         ConfigIni.getInstance().setRegistrationValiditySb(1000L);
 
index 19144c9ad0024f162c645946805f0bbdb8213ff3..cb04452e42153a96c3a7db3a4e1d0b687b052e03 100644 (file)
@@ -188,12 +188,12 @@ public interface IMappingSystem {
     void setIterateMask(boolean iterate);
 
     /**
-     * Configure overwrite policy. If set to true, mappings are overwritten.
+     * Configure merge policy. If set to true, mappings are merged.
      *
-     * @param overwrite
+     * @param mappingMerge
      *            Value to configure
      */
-    void setOverwritePolicy(boolean overwrite);
+    void setMappingMerge(boolean mappingMerge);
 
     /**
      * Print all mappings. Used for testing, debugging and the karaf shell.
index 573d7bcf2c837d13c271e7c82d56b0da29a35ca2..23634b36ee1324e57343656499185916c7c68cba 100644 (file)
@@ -172,13 +172,13 @@ public interface IMappingService {
     void removeData(MappingOrigin origin, Eid key, String subKey);
 
     /**
-     * Configures Mapping Service mapping overwrite option. If set to true, mappings with the same key are overwritten,
+     * Configures Mapping Service mapping merge option. If set to false, mappings with the same key are overwritten,
      * otherwise, mappings with the same key but from different xTR-IDs are all stored.
      *
-     * @param overwrite
-     *            enables or disables mapping overwrite
+     * @param mappingMerge
+     *            enables or disables mapping merge
      */
-    void setMappingOverwrite(boolean overwrite);
+    void setMappingMerge(boolean mappingMerge);
 
     /**
      * Configures Mapping Service mapping lookup policy option.
index e5a2e43dbcc7bb019313164077e3d2e46cd6481d..6c28d7059b3b43f1fd894106a4ddf503b37911a9 100644 (file)
@@ -18,7 +18,6 @@ public final class ConfigIni {
 
     protected static final Logger LOG = LoggerFactory.getLogger(ConfigIni.class);
     private boolean mappingMerge;
-    private boolean mappingOverwrite;
     private boolean smr;
     private String elpPolicy;
     private IMappingService.LookupPolicy lookupPolicy;
@@ -26,14 +25,8 @@ public final class ConfigIni {
     private long smrTimeout;
     private int smrRetryCount;
 
-    // 'lisp.mappingMerge' and 'lisp.mappingOverWrite' are not independent, and they can't be both 'true'
-    // when there is a conflict, the setting in 'lisp.mappingMerge' takes precendence
-    // 'lisp.mappingOverwrite' defines the database behavior while 'lisp.mappingMerge' affects the result
-    // returned in Map-Replies
-
     private static final String LISP_LOOKUP_POLICY = "lisp.lookupPolicy";
     private static final String LISP_MAPPING_MERGE = "lisp.mappingMerge";
-    private static final String LISP_MAPPING_OVERWRITE = "lisp.mappingOverwrite";
     private static final String LISP_SMR = "lisp.smr";
     private static final String LISP_ELP_POLICY = "lisp.elpPolicy";
     private static final String LISP_REGISTER_VALIDITY_SB = "lisp.registerValiditySb";
@@ -54,9 +47,7 @@ public final class ConfigIni {
             context = bundle.getBundleContext();
         }
 
-        // Initialize mappingMerge first, since mappingOverwrite depends on it
         initMappingMerge(context);
-        initMappingOverwrite(context);
         initSmr(context);
         initElpPolicy(context);
         initLookupPolicy(context);
@@ -150,48 +141,6 @@ public final class ConfigIni {
         }
     }
 
-    private void initMappingOverwrite(BundleContext context) {
-        // set the default value first
-        this.mappingOverwrite = true;
-
-        String str = null;
-
-        if (context != null) {
-            str = context.getProperty(LISP_MAPPING_OVERWRITE);
-        }
-
-        if (str == null) {
-            str = System.getProperty(LISP_MAPPING_OVERWRITE);
-            if (str == null) {
-                if (this.mappingMerge) {
-                    // If merge is enabled and overwriting configuration is not set, disable it
-                    LOG.debug("Configuration variable '{}' is unset. Since '{}'=true setting to 'false'",
-                            LISP_MAPPING_OVERWRITE, LISP_MAPPING_MERGE);
-                    this.mappingOverwrite = false;
-                } else {
-                    LOG.debug("Configuration variable '{}' is unset. Setting to default value: 'true'",
-                            LISP_MAPPING_OVERWRITE);
-                }
-                return;
-            }
-        }
-
-        if (str.trim().equalsIgnoreCase("false")) {
-            this.mappingOverwrite = false;
-            LOG.debug("Setting configuration variable '{}' to 'false'", LISP_MAPPING_OVERWRITE);
-        } else {
-            if (this.mappingMerge) {
-                LOG.warn("Can't set configuration variable '{}' to 'true' since '{}' is enabled",
-                        LISP_MAPPING_OVERWRITE, LISP_MAPPING_MERGE);
-                LOG.warn("If you really need to enable overwriting, please disable merging.");
-                LOG.debug("Setting configuration variable '{}' to 'false'", LISP_MAPPING_OVERWRITE);
-                this.mappingOverwrite = false;
-            } else {
-                LOG.debug("Setting configuration variable '{}' to 'true'", LISP_MAPPING_OVERWRITE);
-            }
-        }
-    }
-
     private void initSmr(BundleContext context) {
         // set the default value first
         this.smr = true;
@@ -308,15 +257,9 @@ public final class ConfigIni {
         return mappingMerge;
     }
 
-    public boolean mappingOverwriteIsSet() {
-        return mappingOverwrite;
-    }
-
-    public void setMappingOverwrite(boolean mappingOverwrite) {
-        LOG.debug("Setting configuration variable '{}' to '{}'", LISP_MAPPING_OVERWRITE, mappingOverwrite);
-        this.mappingOverwrite = mappingOverwrite;
-        LOG.debug("Setting configuration variable '{}' to '{}'", LISP_MAPPING_MERGE, !(mappingOverwrite));
-        this.mappingMerge = !(mappingOverwrite);
+    public void setMappingMerge(boolean mappingMerge) {
+        LOG.debug("Setting configuration variable '{}' to '{}'", LISP_MAPPING_MERGE, (mappingMerge));
+        this.mappingMerge = (mappingMerge);
     }
 
     public boolean smrIsSet() {
index 90e0d44bd0a54ec29bc647f542e479945e64ae27..fdc60d8771032d6d03c0bb6e9ffeee0883550b6a 100644 (file)
@@ -92,7 +92,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService
     private final DataBroker dataBroker;
     private final NotificationPublishService notificationPublishService;
 
-    private boolean overwritePolicy = ConfigIni.getInstance().mappingOverwriteIsSet();
+    private boolean mappingMergePolicy = ConfigIni.getInstance().mappingMergeIsSet();
     private boolean notificationPolicy = ConfigIni.getInstance().smrIsSet();
     private boolean iterateMask = true;
     private boolean isMaster = false;
@@ -109,11 +109,11 @@ public class MappingService implements OdlMappingserviceService, IMappingService
 
 
     @Override
-    public void setMappingOverwrite(boolean overwrite) {
-        this.overwritePolicy = overwrite;
+    public void setMappingMerge(boolean mergeMapping) {
+        this.mappingMergePolicy = mergeMapping;
         if (mappingSystem != null) {
-            mappingSystem.setOverwritePolicy(overwrite);
-            ConfigIni.getInstance().setMappingOverwrite(overwrite);
+            mappingSystem.setMappingMerge(mergeMapping);
+            ConfigIni.getInstance().setMappingMerge(mappingMergePolicy);
         }
     }
 
@@ -126,7 +126,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService
         LOG.info("Mapping Service initializing...");
         dsbe = new DataStoreBackEnd(dataBroker);
 
-        mappingSystem = new MappingSystem(dao, iterateMask, notificationPolicy, overwritePolicy);
+        mappingSystem = new MappingSystem(dao, iterateMask, notificationPolicy, mappingMergePolicy);
         mappingSystem.setDataStoreBackEnd(dsbe);
         mappingSystem.initialize();
 
index 4f52cc8224f36dc15a8f17f6b0004e2fccfe35dc..32e5d53de59a2601a0f5049758150e28db9e2d1b 100644 (file)
@@ -60,7 +60,7 @@ import org.slf4j.LoggerFactory;
 public class MappingSystem implements IMappingSystem {
     private static final Logger LOG = LoggerFactory.getLogger(MappingSystem.class);
     private boolean notificationService;
-    private boolean overwrite;
+    private boolean mappingMerge;
     private ILispDAO dao;
     private ILispMapCache smc;
     private IMapCache pmc;
@@ -68,10 +68,10 @@ public class MappingSystem implements IMappingSystem {
     private DataStoreBackEnd dsbe;
     private boolean isMaster = false;
 
-    public MappingSystem(ILispDAO dao, boolean iterateMask, boolean notifications, boolean overwrite) {
+    public MappingSystem(ILispDAO dao, boolean iterateMask, boolean notifications, boolean mappingMerge) {
         this.dao = dao;
         this.notificationService = notifications;
-        this.overwrite = overwrite;
+        this.mappingMerge = mappingMerge;
         buildMapCaches();
     }
 
@@ -80,8 +80,8 @@ public class MappingSystem implements IMappingSystem {
     }
 
     @Override
-    public void setOverwritePolicy(boolean overwrite) {
-        this.overwrite = overwrite;
+    public void setMappingMerge(boolean mappingMerge) {
+        this.mappingMerge = mappingMerge;
     }
 
     @Override
@@ -120,7 +120,7 @@ public class MappingSystem implements IMappingSystem {
                 LOG.warn("addMapping() called will null xTR-ID in MappingRecord, while merge is set, ignoring");
                 return;
             }
-            if (xtrId != null && !overwrite) {
+            if (xtrId != null && mappingMerge) {
                 smc.addMapping(key, xtrId, mappingData);
             }
             if (xtrId != null && mappingData.isMergeEnabled()) {
index 10f5cb716ff3114ddbf5d2fc0352cf853f1d880a..da4533fe7934c8a2359231e69005016c5122e79a 100644 (file)
@@ -564,7 +564,7 @@ public class MappingSystemTest {
         mappingSystem.destroy();
         mappingSystem = new MappingSystem(daoMock, true, true, true);
         mappingSystem.setDataStoreBackEnd(dsbeMock);
-        mappingSystem.setOverwritePolicy(true);
+        mappingSystem.setMappingMerge(false);
         mappingSystem.setIterateMask(true);
     }