use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbSbIntersection_withServicePathDestinationAddress.
/**
* Tests {@link MappingSystem#getMapping} method, northbound and southbound intersection with ServicePath type dst
* address and single Ipv4 type locator record. Returns the original mapping.
*/
@Test
public void getMappingTest_NbSbIntersection_withServicePathDestinationAddress() throws NoSuchFieldException, IllegalAccessException {
setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB);
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(// Ipv4 type Rloc
getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst.
/**
* Tests {@link MappingSystem#getMapping} method with Ipv4 type dst address.
*/
@Test
public void getMappingTest_NbFirst() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_IPV4_DST)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest__withSubscribersToRemove.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
@Ignore
public void handleMapRequest__withSubscribersToRemove() {
// input mapping
final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
Mockito.when(mapServiceMock.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock);
Subscriber subscriberMock = new Subscriber(mapRequestBuilder.getItrRloc().get(0).getRloc(), mapRequestBuilder.getSourceEid().getEid(), Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT);
subscriberMock.setSubscriberTtlByRecordTtl(mappingRecordBuilder.getRecordTtl());
Mockito.when(subscriberSetMock.contains(subscriberMock)).thenReturn(true);
// result
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
// check if a subscriber is re-instantiating when there already is one in the subscriber set
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(subscriberSetMock).remove(subscriberMock);
Mockito.verify(subscriberSetMock).add(subscriberMock);
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
Mockito.verify(mapServiceMock).addData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS, subscriberSetMock);
// verify that itrRloc is subscribed to dst address
mappingRecordBuilder.setEid(SOURCE_DEST_KEY_EID);
mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(IPV4_PREFIX_EID_2).build());
mappingData = getDefaultMappingData(mappingRecordBuilder.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_2)).thenReturn(mappingData);
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(mapServiceMock).getData(MappingOrigin.Southbound, SourceDestKeyHelper.getDstBinary(SOURCE_DEST_KEY_EID), SubKeys.SUBSCRIBERS);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.
the class MappingSystem method getMappingNbSbIntersection.
private MappingData getMappingNbSbIntersection(Eid src, Eid dst) {
// lookupPolicy == NB_AND_SB, we return intersection
// of NB and SB mappings, or NB mapping if intersection is empty.
MappingData nbMappingData = (MappingData) pmc.getMapping(src, dst);
if (nbMappingData == null) {
return nbMappingData;
}
// no intersection for Service Path mappings
if (dst.getAddress() instanceof ServicePath) {
return updateServicePathMappingRecord(nbMappingData, dst);
}
MappingData sbMappingData = getSbMappingWithExpiration(src, dst, null);
if (sbMappingData == null) {
return nbMappingData;
}
// both NB and SB mappings exist. Compute intersection of the mappings
return MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.
the class MapResolver method updateSubscribers.
private void updateSubscribers(Rloc itrRloc, Eid reqEid, Eid mapEid, Eid srcEid, Integer recordTtl) {
Subscriber subscriber = new Subscriber(itrRloc, srcEid, Subscriber.recordTtlToSubscriberTime(recordTtl));
Eid subscribedEid = mapEid;
// mapping will be pushed to dst as well (see sendSMRs in MapServer)
if (mapEid.getAddressType().equals(SourceDestKeyLcaf.class) && !reqEid.getAddressType().equals(SourceDestKeyLcaf.class)) {
subscribedEid = SourceDestKeyHelper.getDstBinary(mapEid);
}
mapService.subscribe(subscriber, subscribedEid);
}
Aggregations