Search in sources :

Example 21 with AddMapping

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);
}
Also used : AddMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with AddMapping

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);
}
Also used : AddMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with AddMapping

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);
}
Also used : RemoveMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInput) AddMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with AddMapping

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());
    }
}
Also used : AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)

Example 25 with AddMapping

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);
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Aggregations

Test (org.junit.Test)21 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)8 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)8 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 AddMappingInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput)6 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)4 Ignore (org.junit.Ignore)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)3 MappingChanged (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged)3 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)3 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)2 MapRegisterCacheKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.key.container.MapRegisterCacheKey)2 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)2 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)2 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)2 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)2