Merge "Cleanup: remove unused and commented out methods"
authorFlorin Coras <florin.coras+odl@gmail.com>
Fri, 12 Aug 2016 15:48:52 +0000 (15:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 12 Aug 2016 15:48:52 +0000 (15:48 +0000)
mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/MultiTableMapCache.java
mappingservice/mapcache/src/main/java/org/opendaylight/lispflowmapping/mapcache/SimpleMapCache.java
mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/MultiTableMapCacheTest.java

index 1dfbf8e03bfed9716ee9fe4aca436fe5ecd82259..281f1a775ce994bfef32a7f6b1900bb1e19af3a7 100644 (file)
@@ -77,20 +77,6 @@ public class MultiTableMapCache implements IMapCache {
         }
     }
 
-    private Object getMappingExactSD(Eid srcEid, Eid dstEid, ILispDAO mappingsDb) {
-        Map<String, ?> daoEntry = mappingsDb.get(dstEid);
-        if (daoEntry != null) {
-            // try SrcDst eid lookup
-            ILispDAO srcDstDao = (ILispDAO) daoEntry.get(SubKeys.LCAF_SRCDST);
-            if (srcEid != null && srcDstDao != null) {
-                return srcDstDao.getSpecific(srcEid, SubKeys.RECORD);
-            }
-            // if lookup fails, return whatever is found for dst eid
-            return daoEntry.get(SubKeys.RECORD);
-        }
-        return null;
-    }
-
     // Returns the mapping corresponding to the longest prefix match for eid.
     // eid must be a simple (maskable or not) address
     private Object getMappingLpmEid(Eid eid, ILispDAO mappingsDb) {
index 5a90b918e4c7560e5c3fb01caa2e0a144f617f4d..c599095488dee74a4d355c19bae32bbf320222eb 100644 (file)
@@ -116,8 +116,8 @@ public class SimpleMapCache implements IMapCache {
         }
 
         if (shouldMerge) {
-            List<XtrId> expiredMappings = new ArrayList<XtrId>();
-            Set<IpAddressBinary> sourceRlocs = new HashSet<IpAddressBinary>();
+            List<XtrId> expiredMappings = new ArrayList<>();
+            Set<IpAddressBinary> sourceRlocs = new HashSet<>();
             MappingRecord mergedEntry = MappingMergeUtil.mergeXtrIdMappings(getXtrIdMappingList(xtrIdDao),
                     expiredMappings, sourceRlocs);
             removeExpiredXtrIdTableEntries(xtrIdDao, expiredMappings);
@@ -137,7 +137,7 @@ public class SimpleMapCache implements IMapCache {
     // Returns the list of mappings stored in an xTR-ID DAO
     private List<Object> getXtrIdMappingList(ILispDAO dao) {
         if (dao != null) {
-            final List<Object> records = new ArrayList<Object>();
+            final List<Object> records = new ArrayList<>();
             dao.getAll(new IRowVisitor() {
                 public void visitRow(Object keyId, String valueKey, Object value) {
                     if (valueKey.equals(SubKeys.RECORD)) {
@@ -149,42 +149,7 @@ public class SimpleMapCache implements IMapCache {
         }
         return null;
     }
-/*
-    private SimpleImmutableEntry<byte[], Long> getXtrIdMinTimeStamp(ILispDAO dao) {
-        if (dao != null) {
-            // We don't actually need a list here, but the external variable we modify inside the IRowVisitor
-            // implementation has to be final. So we use a List, and it's methods, to modify contents
-            final List<SimpleImmutableEntry<byte[], Long>> entries =
-                    new ArrayList<SimpleImmutableEntry<byte[], Long>>();
-            entries.set(0, new SimpleImmutableEntry<byte[], Long>(null, System.currentTimeMillis()));
 
-            dao.getAll(new IRowVisitor() {
-                public void visitRow(Object keyId, String valueKey, Object value) {
-                    if (valueKey.equals(SubKeys.RECORD)) {
-                        byte[] currentXtrId = ((MappingRecord) value).getXtrId();
-                        long currentTimestamp = ((MappingRecord) value).getTimestamp();
-                        // If one of the timestamps is expired, we signal it to the caller by setting the returned
-                        // timestamp to null. The caller will then have to remove that xTR-ID, and do a full merge
-                        // (or decrement)
-                        if (MappingMergeUtil.timestampIsExpired(currentTimestamp)) {
-                            SimpleImmutableEntry<byte[], Long> entry =
-                                    new SimpleImmutableEntry<byte[], Long>(currentXtrId, null);
-                            entries.set(0, entry);
-                            return;
-                        }
-                        if (entries.get(0).getValue() > currentTimestamp) {
-                            SimpleImmutableEntry<byte[], Long> entry =
-                                    new SimpleImmutableEntry<byte[], Long>(currentXtrId, currentTimestamp);
-                            entries.set(0, entry);
-                        }
-                    }
-                }
-            });
-            return entries.get(0);
-        }
-        return null;
-    }
-*/
     // Returns the mapping corresponding to the longest prefix match for eid. eid must be a simple (maskable or not)
     // address
     private Object getMappingLpmEid(Eid eid, byte[] xtrId, ILispDAO dao) {
index fbb4e272d1a3a681d32d39ae68b95427a9e60561..505bb6711943359dbc9cffeb6d8ca90cad193d02 100644 (file)
@@ -18,8 +18,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Maps;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.Date;
 import java.util.Map;
 import org.junit.Before;
@@ -450,58 +448,6 @@ public class MultiTableMapCacheTest {
         Mockito.verifyZeroInteractions(tableDaoMock);
     }
 
-    /**
-     * Tests {@link MultiTableMapCache#getMappingExactSD} method.
-     */
-    @Test
-    public void getMappingExactSDTest() throws NoSuchMethodException, InvocationTargetException,
-            IllegalAccessException {
-        Method getMappingExactSD = MultiTableMapCache.class.getDeclaredMethod("getMappingExactSD", Eid.class, Eid.class,
-                ILispDAO.class);
-        getMappingExactSD.setAccessible(true);
-
-        when(tableDaoMock.get(EID_IPV4_PREFIX_DST)).thenReturn(getEntry1());
-        when(srcDstDaoMock.getSpecific(EID_IPV4_PREFIX_SRC, SubKeys.RECORD)).thenReturn(DUMMY_OBJECT);
-
-        Object result = getMappingExactSD.invoke(
-                multiTableMapCache, EID_IPV4_PREFIX_SRC, EID_IPV4_PREFIX_DST, tableDaoMock);
-        assertEquals(DUMMY_OBJECT, result);
-    }
-
-    /**
-     * Tests {@link MultiTableMapCache#getMappingExactSD} method with null src eid.
-     */
-    @Test
-    public void getMappingExactSDTest_withNullSrcEid() throws NoSuchMethodException, InvocationTargetException,
-            IllegalAccessException {
-        Method getMappingExactSD = MultiTableMapCache.class.getDeclaredMethod("getMappingExactSD", Eid.class, Eid.class,
-                ILispDAO.class);
-        getMappingExactSD.setAccessible(true);
-
-        when(tableDaoMock.get(EID_IPV4_PREFIX_DST)).thenReturn(getEntry1());
-
-        Object result = getMappingExactSD.invoke(
-                multiTableMapCache, null, EID_IPV4_PREFIX_DST, tableDaoMock);
-        assertEquals(DUMMY_OBJECT, result);
-    }
-
-    /**
-     * Tests {@link MultiTableMapCache#getMappingExactSD} method with null entry.
-     */
-    @Test
-    public void getMappingExactSDTest_withNullEntry() throws NoSuchMethodException, InvocationTargetException,
-            IllegalAccessException {
-        Method getMappingExactSD = MultiTableMapCache.class.getDeclaredMethod("getMappingExactSD", Eid.class, Eid.class,
-                ILispDAO.class);
-        getMappingExactSD.setAccessible(true);
-
-        when(tableDaoMock.get(EID_IPV4_PREFIX_DST)).thenReturn(null);
-
-        Object result = getMappingExactSD.invoke(
-                multiTableMapCache, null, EID_IPV4_PREFIX_DST, tableDaoMock);
-        assertNull(result);
-    }
-
     /**
      * The following test is for coverage-increase purpose only.
      */