}
}
- private void mergeMappings(Eid key) {
+ private MappingData mergeMappings(Eid key) {
List<XtrId> expiredMappings = new ArrayList<>();
Set<IpAddressBinary> sourceRlocs = new HashSet<>();
MappingData mergedMappingData = MappingMergeUtil.mergeXtrIdMappings(smc.getAllXtrIdMappings(key),
expiredMappings, sourceRlocs);
smc.removeXtrIdMappings(key, expiredMappings);
+ for (XtrId xtrId : expiredMappings) {
+ dsbe.removeXtrIdMapping(DSBEInputUtil.toXtrIdMapping(xtrId));
+ }
if (mergedMappingData != null) {
smc.addMapping(key, mergedMappingData, sourceRlocs);
+ dsbe.addMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, key,
+ mergedMappingData.getRecord().getSiteId(), mergedMappingData));
+ } else {
+ smc.removeMapping(key);
+ dsbe.removeMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, key));
}
+ return mergedMappingData;
}
@Override
private MappingData getSbMappingWithExpiration(Eid src, Eid dst, XtrId xtrId) {
MappingData mappingData = (MappingData) smc.getMapping(dst, xtrId);
if (mappingData != null && MappingMergeUtil.mappingIsExpired(mappingData)) {
- removeExpiredMapping(dst, xtrId, mappingData);
- return null;
+ return removeExpiredMapping(dst, xtrId, mappingData);
} else {
return mappingData;
}
* This private method either removes the main mapping ONLY, or the xTR-ID mapping ONLY, based on xtrId being
* null or non-null. Caller functions should take care of removing both when necessary.
*/
- private void removeExpiredMapping(Eid key, XtrId xtrId, MappingData mappingData) {
+ private MappingData removeExpiredMapping(Eid key, XtrId xtrId, MappingData mappingData) {
+ if (mappingMerge && mappingData.isMergeEnabled()) {
+ return mergeMappings(key);
+ }
if (xtrId == null) {
smc.removeMapping(key);
dsbe.removeMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, mappingData.getRecord().getEid(),
} else {
smc.removeMapping(key, xtrId);
dsbe.removeXtrIdMapping(DSBEInputUtil.toXtrIdMapping(mappingData));
- if (mappingMerge && mappingData.isMergeEnabled()) {
- mergeMappings(key);
- }
}
+ return null;
}
@Override
import org.opendaylight.lispflowmapping.lisp.type.MappingData;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId;
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.mapping.authkey.container.MappingAuthkey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
new XtrIdUri(LispAddressStringifier.getURIString(record.getXtrId()))).setMappingRecord(record).build();
}
+ public static XtrIdMapping toXtrIdMapping(XtrId xtrId) {
+ return new XtrIdMappingBuilder().setXtrIdUri(new XtrIdUri(LispAddressStringifier.getURIString(xtrId))).build();
+ }
+
public static AuthenticationKey toAuthenticationKey(Eid key, MappingAuthkey authKey) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));