Search in sources :

Example 46 with MappingRecord

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;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 47 with MappingRecord

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);
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 48 with MappingRecord

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);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Example 49 with MappingRecord

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;
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 50 with MappingRecord

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);
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Aggregations

MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)56 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)31 Test (org.junit.Test)28 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)11 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)10 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)10 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)6 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)6 ArrayList (java.util.ArrayList)5 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)5 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)4 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)3