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);
}
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()));
}
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()));
}
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();
}
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));
}
Aggregations