Search in sources :

Example 36 with MappingData

use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method insertNBMappings.

private void insertNBMappings(long iid, String... prefixes) {
    LOG.debug("Adding Northbound mappings in VNI {} for prefixes: {}", iid, prefixes);
    final InstanceIdType iiType = new InstanceIdType(iid);
    for (String prefix : prefixes) {
        MappingRecord record = newMappingRecord(prefix, iiType);
        mapService.addMapping(MappingOrigin.Northbound, record.getEid(), null, new MappingData(record));
    }
    sleepForMilliseconds(100);
    MappingServiceIntegrationTestUtil.printMapCacheState(mapService);
}
Also used : InstanceIdType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 37 with MappingData

use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.

the class MultiSiteScenario method storeNorthMappingIpPrefix.

void storeNorthMappingIpPrefix(final Site... dstSite) {
    final MappingRecordBuilder mrb = prepareMappingRecord(EidType.EID_WITH_PREFIX, null, dstSite);
    mapService.addMapping(MappingOrigin.Northbound, mrb.getEid(), new SiteId(DEFAULT_SITE_ID), new MappingData(mrb.build()));
}
Also used : SiteId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 38 with MappingData

use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.

the class MultiSiteScenario method storeNorthMappingNegative.

void storeNorthMappingNegative(final Site dstSite, final MappingRecord.Action action) {
    final Eid eidAsIpv4Prefix = LispAddressUtil.asIpv4PrefixBinaryEid(dstSite.getEidPrefix() + "/" + DEFAULT_NETWORK_MASK, dstSite.getVNI());
    final MappingRecordBuilder mrbNegative = prepareMappingRecord(EidType.EID_WITH_PREFIX, null, dstSite);
    mrbNegative.setEid(eidAsIpv4Prefix);
    mrbNegative.setAction(action);
    mapService.addMapping(MappingOrigin.Northbound, eidAsIpv4Prefix, new SiteId(DEFAULT_SITE_ID), new MappingData(mrbNegative.build()));
}
Also used : SourceEid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEid) Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SiteId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 39 with MappingData

use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.

the class LispMapCacheStringifier method prettyPrintMTMCMappings.

@SuppressWarnings("unchecked")
public static String prettyPrintMTMCMappings(ILispDAO dao) {
    final StringBuilder sb = new StringBuilder();
    final IRowVisitor mappingVisitor = (new IRowVisitor() {

        public void visitRow(Object keyId, String valueKey, Object value) {
            switch(valueKey) {
                case SubKeys.RECORD:
                    MappingData md = (MappingData) value;
                    sb.append(Stringifier.getString(md.getRecord(), 2));
                    sb.append("\n");
                    break;
                case SubKeys.SUBSCRIBERS:
                    Set<Subscriber> subscribers = (Set<Subscriber>) value;
                    sb.append(prettyPrintSubscriberSet(subscribers, 4));
                    sb.append("\n");
                    break;
                case SubKeys.LCAF_SRCDST:
                    ((ILispDAO) value).getAll(this);
                    break;
                default:
                    break;
            }
        }
    });
    dao.getAll(new IRowVisitor() {

        String lastKey = "";

        public void visitRow(Object keyId, String valueKey, Object value) {
            String key = keyId.getClass().getSimpleName() + "#" + keyId;
            if (!lastKey.equals(key)) {
                sb.append("Instance ID " + keyId + "\n");
            }
            if (valueKey.equals(SubKeys.VNI)) {
                ((ILispDAO) value).getAll(mappingVisitor);
            }
            lastKey = key;
        }
    });
    return sb.toString();
}
Also used : IRowVisitor(org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor) Set(java.util.Set) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 40 with MappingData

use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.

the class SimpleMapCacheTest method getMappingLpmEidTest.

/**
 * Tests {@link SimpleMapCache#getMappingLpmEid} method.
 */
@Test
@SuppressWarnings("unchecked")
public void getMappingLpmEidTest() throws Exception {
    final Map<String, Object> mapMock = Mockito.mock(Map.class);
    final SimpleImmutableEntry<Eid, Map<String, ?>> mapPair = new SimpleImmutableEntry<>(NORMALIZED_EID_IPV4_PREFIX_DST, mapMock);
    final MappingData mappingData = new MappingData(getDefaultMappingRecordBuilder().build());
    Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
    Mockito.when(tableMock.getBestPair(NORMALIZED_EID_IPV4_PREFIX_DST)).thenReturn(mapPair);
    Mockito.when(mapMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
    // second invocation
    Mockito.when(xtrIdDaoMock.getSpecific(XTR_ID, SubKeys.RECORD)).thenReturn(mappingData);
    // with non-expired mapping record
    assertEquals(mappingData, simpleMapCache.getMapping(EID_IPV4_PREFIX_DST, XTR_ID));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Map(java.util.Map) Test(org.junit.Test)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)69 Test (org.junit.Test)40 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)30 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)14 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)11 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)9 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)9 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)7 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)7 ArrayList (java.util.ArrayList)5 Ignore (org.junit.Ignore)5 Date (java.util.Date)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)4 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)4 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)4 Set (java.util.Set)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 IRowVisitor (org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)3