use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin in project lispflowmapping by opendaylight.
the class DSBEInputUtil method toMapping.
public static Mapping toMapping(MappingOrigin origin, Eid key) {
MappingBuilder mb = new MappingBuilder();
mb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
mb.setOrigin(origin);
mb.setMappingRecord(new MappingRecordBuilder().setEid(key).build());
return mb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin in project lispflowmapping by opendaylight.
the class MappingServiceTest method addMappingTest_fromNorthbound.
/**
* Tests {@link MappingService#addMapping} method from northbound.
*/
@Test
public void addMappingTest_fromNorthbound() throws ExecutionException, InterruptedException {
// input
final MappingOrigin origin = MappingOrigin.Northbound;
final MappingRecord record = getDefaultMappingRecordBuilder().setXtrId(XTR_ID).build();
final MappingData data = getDefaultMappingData(record);
mappingService.addMapping(origin, IPV4_EID, SITE_ID, data);
Mockito.verify(dsbe).addMapping(DSBEInputUtil.toMapping(origin, IPV4_EID, SITE_ID, data));
Mockito.verifyZeroInteractions(mappingSystem);
Mockito.verifyNoMoreInteractions(dsbe);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin in project lispflowmapping by opendaylight.
the class InstanceIdentifierUtil method createMappingIid.
public static InstanceIdentifier<Mapping> createMappingIid(Eid eid, MappingOrigin orig) {
Preconditions.checkNotNull(eid, "Mapping needs an EID entry!");
VirtualNetworkIdentifierKey vniKey = new VirtualNetworkIdentifierKey(new VniUri(Long.toString(getLispInstanceId(eid))));
MappingKey eidKey = new MappingKey(new EidUri(LispAddressStringifier.getURIString(eid)), orig);
return InstanceIdentifier.create(MappingDatabase.class).child(VirtualNetworkIdentifier.class, vniKey).child(Mapping.class, eidKey);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin in project lispflowmapping by opendaylight.
the class InstanceIdentifierUtil method createXtrIdMappingIid.
public static InstanceIdentifier<XtrIdMapping> createXtrIdMappingIid(Eid eid, MappingOrigin orig, XtrId xtrId) {
Preconditions.checkNotNull(eid, "Mapping needs an EID entry!");
Preconditions.checkNotNull(xtrId, "Mapping needs an xTR-ID entry!");
VirtualNetworkIdentifierKey vniKey = new VirtualNetworkIdentifierKey(new VniUri(Long.toString(getLispInstanceId(eid))));
MappingKey eidKey = new MappingKey(new EidUri(LispAddressStringifier.getURIString(eid)), orig);
XtrIdMappingKey xtrIdKey = new XtrIdMappingKey(new XtrIdUri(LispAddressStringifier.getURIString(xtrId)));
return InstanceIdentifier.create(MappingDatabase.class).child(VirtualNetworkIdentifier.class, vniKey).child(Mapping.class, eidKey).child(XtrIdMapping.class, xtrIdKey);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin 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);
}
Aggregations