use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MultiSiteScenario method checkActionAndRloc.
boolean checkActionAndRloc(final Site dstSite, boolean expectedPingWorks, MapReply mapReplyFromSrcToDst, final Site... additionalSitesFromMapping) {
final MappingRecord mappingRecord = verifyMappingRecord(mapReplyFromSrcToDst);
final boolean isNotDroppendSrcDst = !MappingRecord.Action.Drop.equals(mappingRecord.getAction());
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isNotDroppendSrcDst, "Drop action has appeared " + "during ping")) {
return true;
}
final List<LocatorRecord> locatorRecords = verifyLocatorRecordExists(mappingRecord);
for (Site expectedTargetSite : concatenateSites(dstSite, additionalSitesFromMapping)) {
boolean expectedTargetFound = false;
for (LocatorRecord locatorRecord : locatorRecords) {
if (expectedTargetSite.getRloc().equals(rlocToString(locatorRecord))) {
final byte[] ipv4AddressSrcDst = verifyIpv4Address(locatorRecord).getValue();
final byte[] rloc = InetAddresses.forString((expectedTargetSite.getRloc())).getAddress();
final boolean isRlocSrcDstEqual = Arrays.equals(ipv4AddressSrcDst, rloc);
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isRlocSrcDstEqual, "Unexpected RLOC." + "Expected value " + rloc + ". Real value " + ipv4AddressSrcDst + ".")) {
return true;
}
final boolean isWeightEquals = expectedTargetSite.getWeight() == locatorRecord.getWeight();
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isWeightEquals, "Weight isn't equal." + "Expected value " + expectedTargetSite.getWeight() + ". Value from mapping" + locatorRecord.getWeight() + ".")) {
return true;
}
final boolean isPriorityEquals = expectedTargetSite.getPriority() == locatorRecord.getPriority();
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isPriorityEquals, "Priority isn't " + "equal. Expected value " + expectedTargetSite.getPriority() + ". Value from mapping" + locatorRecord.getPriority() + ".")) {
return true;
}
expectedTargetFound = true;
break;
}
}
if (isPossibleAssertPingResultImmediately(expectedPingWorks, expectedTargetFound, "Mapping for " + expectedTargetSite.getRloc() + " was expected but wasn't returned from mapping service." + expectedTargetFound)) {
return true;
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingSystem method addMapping.
private void addMapping(MappingOrigin origin, Eid key, MappingData mappingData, MappingChange changeType) {
sbMappingTimeoutService.removeExpiredMappings();
if (mappingData == null) {
LOG.warn("addMapping() called with null mapping, ignoring");
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()) {
LOG.warn("addMapping() called will null xTR-ID in MappingRecord, while merge is set, ignoring");
return;
}
if (xtrId != null && mappingMerge) {
if (mappingData.isMergeEnabled()) {
smc.addMapping(key, xtrId, mappingData);
handleMergedMapping(key);
return;
} else {
clearPresentXtrIdMappings(key);
smc.addMapping(key, xtrId, mappingData);
}
}
addOrRefreshMappingInTimeoutService(key, mappingData);
}
tableMap.get(origin).addMapping(key, mappingData);
// 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);
}
MappingRecord newMapping = getMappingRecord(getMapping(key));
handleAddMappingNotifications(origin, key, mappingData, oldMapping, newMapping, changeType);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingSystem method notifyChange.
public void notifyChange(Eid eid, MappingRecord mapping, MappingChange mappingChange) {
Set<Subscriber> subscribers = getSubscribers(eid);
Set<Subscriber> dstSubscribers = null;
// For SrcDst LCAF also send SMRs to Dst prefix
if (eid.getAddress() instanceof SourceDestKey) {
Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
dstSubscribers = getSubscribers(dstAddr);
notifyChildren(dstAddr, mapping, 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingSystem method addNegativeMapping.
@Override
public MappingData addNegativeMapping(Eid key) {
MappingRecord mapping = buildNegativeMapping(key);
MappingData mappingData = new MappingData(mapping);
LOG.debug("Adding negative mapping for EID {}", LispAddressStringifier.getString(mapping.getEid()));
LOG.trace(mappingData.getString());
smc.addMapping(mapping.getEid(), mappingData);
dsbe.addMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, mapping.getEid(), null, mappingData));
return mappingData;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingSystem method handleAddMappingNotifications.
private void handleAddMappingNotifications(MappingOrigin origin, Eid key, MappingData mappingData, MappingRecord oldMapping, MappingRecord newMapping, MappingChange changeType) {
// account policy as well
if (origin != MappingOrigin.Southbound || MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
notifyChange(key, mappingData.getRecord(), changeType);
Eid dstKey = key;
// 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);
}
// subscribers too
if (newMapping != null && !newMapping.getEid().equals(key) && !newMapping.getEid().equals(dstKey)) {
notifyChange(newMapping.getEid(), newMapping, changeType);
}
}
}
Aggregations