use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class HostInformationManagerTest method testOnlyUnprocessedPortDataIsBeingProcessed.
@Test
public void testOnlyUnprocessedPortDataIsBeingProcessed() {
HostInformationManager hostInformationManager = getDefaultHostInformationManager();
addPortData1(hostInformationManager);
Mockito.verify(lfmDbService, Mockito.times(0)).addMapping(Mockito.any(AddMappingInput.class));
addRlocData(hostInformationManager);
addPortData2(hostInformationManager);
Mockito.verify(lfmDbService, Mockito.times(2)).addMapping(Mockito.any(AddMappingInput.class));
AddMappingInput desiredMappingRecord1 = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_1);
Mockito.verify(lfmDbService).addMapping(desiredMappingRecord1);
AddMappingInput desiredMappingRecord2 = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_2);
Mockito.verify(lfmDbService).addMapping(desiredMappingRecord2);
destroySingleton(hostInformationManager);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class HostInformationManagerTest method testScenarioMultiplePortDataAndThenRloc.
@Test
public void testScenarioMultiplePortDataAndThenRloc() {
HostInformationManager hostInformationManager = getDefaultHostInformationManager();
addPortData1(hostInformationManager);
addPortData2(hostInformationManager);
Mockito.verify(lfmDbService, Mockito.times(0)).addMapping(Mockito.any(AddMappingInput.class));
addRlocData(hostInformationManager);
AddMappingInput desiredMappingRecord1 = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_1);
Mockito.verify(lfmDbService).addMapping(desiredMappingRecord1);
AddMappingInput desiredMappingRecord2 = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_2);
Mockito.verify(lfmDbService).addMapping(desiredMappingRecord2);
destroySingleton(hostInformationManager);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class HostInformationManagerTest method testProperMappingRecordRemoval.
@Test
public void testProperMappingRecordRemoval() {
HostInformationManager hostInformationManager = getDefaultHostInformationManager();
addPortData1(hostInformationManager);
addRlocData(hostInformationManager);
addUpdatedPortData1(hostInformationManager);
RemoveMappingInput removeMappingInput = LispUtil.buildRemoveMappingInput(PORT_DATA_1.getPortEid());
Mockito.verify(lfmDbService).removeMapping(removeMappingInput);
AddMappingInput addMappingInput = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_3);
Mockito.verify(lfmDbService).addMapping(addMappingInput);
destroySingleton(hostInformationManager);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class MappingSystem method restoreDaoFromDatastore.
/**
* Restore all mappings and keys from mdsal datastore.
*/
private void restoreDaoFromDatastore() {
List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
List<Mapping> mappings = dsbe.getAllMappings(LogicalDatastoreType.CONFIGURATION);
/*
* XXX By default, the operational datastore is not persisted to disk, either at run-time, or on shutdown,
* so the following will have no effect (getLastUpdateTimestamp() will fail, since it's reading from
* the operational datastore, and even if it didn't getAllMappings() will fail anyway). According to rovarga it
* should be possible to turn on persistence for the operational datastore editing
* etc/opendaylight/karaf/05-clustering.xml, by setting <persistence>true</persistence>. At the time of writing
* the below code block that didn't seem to work though.
*/
Long lastUpdateTimestamp = dsbe.getLastUpdateTimestamp();
if (lastUpdateTimestamp != null && System.currentTimeMillis() - lastUpdateTimestamp > ConfigIni.getInstance().getRegistrationValiditySb()) {
LOG.warn("Restore threshold passed, not restoring operational datastore into DAO");
} else {
mappings.addAll(dsbe.getAllMappings(LogicalDatastoreType.OPERATIONAL));
}
dsbe.removeLastUpdateTimestamp();
LOG.info("Restoring {} mappings and {} keys from datastore into DAO", mappings.size(), authKeys.size());
for (Mapping mapping : mappings) {
addMapping(mapping.getOrigin(), mapping.getMappingRecord().getEid(), new MappingData(mapping.getMappingRecord()));
}
for (AuthenticationKey authKey : authKeys) {
addAuthenticationKey(authKey.getEid(), authKey.getMappingAuthkey());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping 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