// following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
- multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
+ //multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
multiSiteScenario.assertPingWorks(SITE_B_SB, 5, SITE_C_WP_50_2_SB, 4);
public MapReply handleMapRequest(MapRequest request) {
if (LOG.isDebugEnabled()) {
- LOG.debug("DAO: Retrieving mapping for {}",
+ LOG.debug("LISP: Retrieving mapping for {}",
LispAddressStringifier.getString(request.getEidItem().get(0).getEid()));
}
public Pair<MapNotify, List<TransportAddress>> handleMapRegister(MapRegister mapRegister) {
if (LOG.isDebugEnabled()) {
- LOG.debug("DAO: Adding mapping for {}",
+ LOG.debug("LISP: Adding mapping for {}",
LispAddressStringifier.getString(mapRegister.getMappingRecordItem().get(0)
.getMappingRecord().getEid()));
}
import org.opendaylight.lispflowmapping.lisp.type.MappingData;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
+import org.opendaylight.lispflowmapping.lisp.util.MappingRecordUtil;
import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
import org.opendaylight.lispflowmapping.lisp.util.SourceDestKeyHelper;
import org.opendaylight.lispflowmapping.mapcache.AuthKeyDb;
return;
}
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("DAO: Adding {} mapping for EID {}", origin, LispAddressStringifier.getString(key));
+ }
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("mappingData = {}", mappingData.getString());
+ }
+
+ // Save the old mapping for the key before we modify anything, so that we can detect changes later
+ final MappingRecord oldMapping = getMappingRecord(getMapping(key));
+
if (origin == MappingOrigin.Southbound) {
XtrId xtrId = mappingData.getXtrId();
if (xtrId == null && mappingMerge && mappingData.isMergeEnabled()) {
tableMap.get(origin).addMapping(key, mappingData);
- if (origin != MappingOrigin.Southbound) {
- // If a NB mapping is added, we need to check if it's covering negative mappings in SB, and remove those
+ // We need to check if the newly added mapping is covering negatives in SB, and remove those (with notification)
+ if (mappingData.isPositive().or(true)) {
handleSbNegativeMappings(key);
- // Notifications for SB changes are sent in the SB code itself, so this is called for non-SB additions only
- notifyChange(key, mappingData.getRecord(), changeType);
}
+
+ MappingRecord newMapping = getMappingRecord(getMapping(key));
+
+ handleAddMappingNotifications(origin, key, mappingData, oldMapping, newMapping, changeType);
+ }
+
+ private static MappingRecord getMappingRecord(MappingData mappingData) {
+ return (mappingData != null) ? mappingData.getRecord() : null;
}
@SuppressWarnings("unchecked")
private void handleSbNegativeMappings(Eid key) {
Set<Eid> childPrefixes = getSubtree(MappingOrigin.Southbound, key);
- // We don't want to remove a newly added negative mapping, so remove it from the child set
- childPrefixes.remove(key);
-
LOG.trace("handleSbNegativeMappings(): subtree prefix set for EID {} (excluding the EID itself): {}",
LispAddressStringifier.getString(key),
LispAddressStringifier.getString(childPrefixes));
}
}
+ private void handleAddMappingNotifications(MappingOrigin origin, Eid key, MappingData mappingData,
+ MappingRecord oldMapping, MappingRecord newMapping,
+ MappingChange changeType) {
+ // Non-southbound origins are MD-SAL first, so they only get to call addMapping() if there is a change
+ // Southbound is different, so we need to check if there is a change in the mapping. This check takes into
+ // account policy as well
+ if (origin != MappingOrigin.Southbound || MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
+ notifyChange(key, mappingData.getRecord(), changeType);
+
+ Eid dstKey = key;
+ // Since the above notifyChange() already notifies the dest part of source/dest addresses, we save the dest
+ // for the checks that we do afterwards
+ if (key.getAddress() instanceof SourceDestKey) {
+ dstKey = SourceDestKeyHelper.getDstBinary(key);
+ }
+ // If the old mapping had a different EID than what was just added, notify those subscribers too
+ if (oldMapping != null && !oldMapping.getEid().equals(key) && !oldMapping.getEid().equals(dstKey)) {
+ notifyChange(oldMapping.getEid(), oldMapping, changeType);
+ }
+ // If the new mapping has a different EID than what was just added (e.g., due to NB_AND_SB), notify those
+ // subscribers too
+ if (newMapping != null && !newMapping.getEid().equals(key) && !newMapping.getEid().equals(dstKey)) {
+ notifyChange(newMapping.getEid(), newMapping, changeType);
+ }
+ }
+
+ }
+
@Override
public MappingData addNegativeMapping(Eid key) {
MappingRecord mapping = buildNegativeMapping(key);
}
private MappingData handleMergedMapping(Eid key) {
+ LOG.trace("Merging mappings for EID {}", LispAddressStringifier.getString(key));
List<MappingData> expiredMappingDataList = new ArrayList<>();
Set<IpAddressBinary> sourceRlocs = new HashSet<>();
@Override
public MappingData getMapping(Eid src, Eid dst) {
// NOTE: Currently we have two lookup algorithms implemented, which are configurable
+ IMappingService.LookupPolicy policy = ConfigIni.getInstance().getLookupPolicy();
+ LOG.debug("DAO: Looking up mapping for {}, source EID {} with policy {}",
+ LispAddressStringifier.getString(dst),
+ LispAddressStringifier.getString(src),
+ policy);
- if (ConfigIni.getInstance().getLookupPolicy() == IMappingService.LookupPolicy.NB_AND_SB) {
+ if (policy == IMappingService.LookupPolicy.NB_AND_SB) {
return getMappingNbSbIntersection(src, dst);
} else {
return getMappingNbFirst(src, dst);
}
private void removeSbXtrIdSpecificMapping(Eid key, XtrId xtrId, MappingData mappingData) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("DAO: Removing southbound mapping for EID {}, xTR-ID {}",
+ LispAddressStringifier.getString(key),
+ LispAddressStringifier.getString(xtrId));
+ }
smc.removeMapping(key, xtrId);
dsbe.removeXtrIdMapping(DSBEInputUtil.toXtrIdMapping(mappingData));
}
}
removeFromSbTimeoutService(key);
- Set<Subscriber> subscribers = getSubscribers(key);
+ final Set<Subscriber> subscribers = getSubscribers(key);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("DAO: Removing southbound mapping for EID {}", LispAddressStringifier.getString(key));
+ }
smc.removeMapping(key);
dsbe.removeMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, key, mappingData));
publishNotification(mappingData.getRecord(), null, subscribers, null, MappingChange.Removed);
dstSubscribers = getSubscribers(dstAddr);
notifyChildren(dstAddr, mapping, mappingChange);
}
- publishNotification(mapping, eid, subscribers, dstSubscribers, mappingChange);
+
+ // No reason to send a notification when no subscribers exist
+ if (subscribers != null || dstSubscribers != null) {
+ publishNotification(mapping, eid, subscribers, dstSubscribers, mappingChange);
+ }
notifyChildren(eid, mapping, mappingChange);
}
childPrefixes.remove(eid);
for (Eid prefix : childPrefixes) {
Set<Subscriber> subscribers = getSubscribers(prefix);
- publishNotification(mapping, prefix, subscribers, null, mappingChange);
+ // No reason to send a notification when no subscribers exist
+ if (subscribers != null) {
+ publishNotification(mapping, prefix, subscribers, null, mappingChange);
+ }
}
}
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public void handleMapRegister(MapRegister mapRegister) {
boolean mappingUpdated = false;
boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
- Set<Subscriber> subscribers = Sets.newConcurrentHashSet();
MappingRecord oldMapping;
if (merge) {
oldMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
mapService.addMapping(MappingOrigin.Southbound, eid, getSiteId(mapRegister), mappingData);
- if (oldMapping != null
- && MappingRecordUtil.isNegativeMapping(oldMapping)
- && !oldMapping.getEid().equals(eid)) {
- if (subscriptionService) {
- // Here we save the subscribers of the OLD mapping before removing. We will add to this set the
- // subscribers of the NEW mapping below (since the EIDs are different, the result of
- // mappingChanged() will be true, and then send an SMR to all subscribers with the EID of the NEW
- // mapping only.
- Set<Subscriber> oldMappingSubscribers = mapService.getSubscribers(oldMapping.getEid());
- if (oldMappingSubscribers != null) {
- subscribers.addAll(oldMappingSubscribers);
- LoggingUtil.logSubscribers(LOG, oldMapping.getEid(), subscribers);
- }
- }
- mapService.removeMapping(MappingOrigin.Southbound, oldMapping.getEid());
- }
-
- if (subscriptionService) {
- MappingRecord newMapping = merge
- ? getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid)) : mapping;
-
- if (mappingChanged(oldMapping, newMapping)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Mapping update occured for {} SMRs will be sent for its subscribers.",
- LispAddressStringifier.getString(eid));
- }
- Set<Subscriber> newMappingSubscribers = mapService.getSubscribers(eid);
- if (oldMapping != null && !oldMapping.getEid().equals(eid)) {
- newMappingSubscribers = addParentSubscribers(eid, newMappingSubscribers);
- }
- if (newMappingSubscribers != null) {
- subscribers.addAll(newMappingSubscribers);
- LoggingUtil.logSubscribers(LOG, eid, subscribers);
- }
- handleSmr(eid, subscribers);
+ if (merge) {
+ MappingRecord newMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
+ if (MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
+ // If there is a SB mapping change with merge on, Map-Notify will be sent to ALL xTRs, not jus the
+ // one registering (merging is done in the MappingSystem code)
mappingUpdated = true;
}
}
@Override
public void onMappingChanged(MappingChanged notification) {
- LOG.trace("MappingChanged event of type: `{}'", notification.getChangeType());
if (subscriptionService) {
Eid eid = notification.getEid();
if (eid == null) {
eid = notification.getMappingRecord().getEid();
}
+ LOG.trace("MappingChanged event for {} of type: `{}'", LispAddressStringifier.getString(eid),
+ notification.getChangeType());
Set<Subscriber> subscribers = MSNotificationInputUtil.toSubscriberSet(notification.getSubscriberItem());
LoggingUtil.logSubscribers(LOG, eid, subscribers);
if (mapService.isMaster()) {
}
}
- private static boolean mappingChanged(MappingRecord oldMapping, MappingRecord newMapping) {
- // We only check for fields we care about
- // XXX: This code needs to be checked and updated when the YANG model for MappingRecord is modified
- Preconditions.checkNotNull(newMapping, "The new mapping should never be null");
- if (oldMapping == null) {
- LOG.trace("mappingChanged(): old mapping is null");
- return true;
- } else if (!Objects.equals(oldMapping.getEid(), newMapping.getEid())) {
- LOG.trace("mappingChanged(): EID");
- return true;
- } else if (!Objects.equals(oldMapping.getLocatorRecord(), newMapping.getLocatorRecord())) {
- LOG.trace("mappingChanged(): RLOC");
- return true;
- } else if (!Objects.equals(oldMapping.getAction(), newMapping.getAction())) {
- LOG.trace("mappingChanged(): action");
- return true;
- } else if (!Objects.equals(oldMapping.getRecordTtl(), newMapping.getRecordTtl())) {
- LOG.trace("mappingChanged(): TTL");
- return true;
- } else if (!Objects.equals(oldMapping.getMapVersion(), newMapping.getMapVersion())) {
- LOG.trace("mappingChanged(): mapping version");
- return true;
- }
- return false;
- }
-
private void handleSmr(Eid eid, Set<Subscriber> subscribers) {
sendSmrs(eid, subscribers);
scheduler.scheduleSmrs(mrb, subscribers.iterator());
}
- private Set<Subscriber> addParentSubscribers(Eid eid, Set<Subscriber> subscribers) {
- Eid parentPrefix = mapService.getParentPrefix(eid);
- if (parentPrefix == null) {
- return subscribers;
- }
-
- Set<Subscriber> parentSubscribers = mapService.getSubscribers(parentPrefix);
- if (parentSubscribers != null) {
- if (subscribers != null) {
- subscribers.addAll(parentSubscribers);
- } else {
- subscribers = parentSubscribers;
- }
- }
- return subscribers;
- }
-
private static InetAddress getLocalAddress() {
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
assertEquals(IPV4_SOURCE_EID_6, resultEid_3);
}
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentEid() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setEid(IPV4_EID_2);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentRLOC() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder();
- // apply the change
- mappingRecordBuilder_1.getLocatorRecord().add(new LocatorRecordBuilder().build());
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentAction() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setAction(MappingRecord.Action.NativelyForward);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentTTL() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setRecordTtl(10);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentMapVersion() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setMapVersion((short) 10);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withNullMap() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(null)
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
private static MapRegisterBuilder getDefaultMapRegisterBuilder() {
final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder()
.setProxyMapReply(true)
package org.opendaylight.lispflowmapping.lisp.util;
import java.util.List;
+import java.util.Objects;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
public static boolean isPositiveMapping(MappingRecord mapping) {
return !isNegativeMapping(mapping);
}
-}
+
+ public static boolean mappingChanged(MappingRecord oldMapping, MappingRecord newMapping) {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("mappingChanged():\noldMapping = {}\nnewMapping = {}", oldMapping, newMapping);
+ }
+ // We only check for fields we care about
+ // XXX: This code needs to be checked and updated when the YANG model for MappingRecord is modified
+ if (oldMapping == null && newMapping == null) {
+ LOG.trace("mappingChanged(): FALSE");
+ return false;
+ } else if (oldMapping == null) {
+ LOG.trace("mappingChanged(): old mapping is null");
+ return true;
+ } else if (!Objects.equals(oldMapping.getEid(), newMapping.getEid())) {
+ LOG.trace("mappingChanged(): EID");
+ return true;
+ } else if (!Objects.equals(oldMapping.getLocatorRecord(), newMapping.getLocatorRecord())) {
+ LOG.trace("mappingChanged(): RLOC");
+ return true;
+ } else if (!Objects.equals(oldMapping.getAction(), newMapping.getAction())) {
+ LOG.trace("mappingChanged(): action");
+ return true;
+ } else if (!Objects.equals(oldMapping.getRecordTtl(), newMapping.getRecordTtl())) {
+ LOG.trace("mappingChanged(): TTL");
+ return true;
+ } else if (!Objects.equals(oldMapping.getMapVersion(), newMapping.getMapVersion())) {
+ LOG.trace("mappingChanged(): mapping version");
+ return true;
+ }
+ LOG.trace("mappingChanged(): FALSE");
+ return false;
+ }
+}
\ No newline at end of file