Search in sources :

Example 1 with PortUuidToPortDataMapper

use of org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper in project lispflowmapping by opendaylight.

the class PortUuidToPortDataMapperTest method transferAllProcessedPortDataToUnprocessedTest.

@Test
public void transferAllProcessedPortDataToUnprocessedTest() {
    PortUuidToPortDataMapper portUuidToPortDataMapper = new PortUuidToPortDataMapper();
    portUuidToPortDataMapper.addUnprocessedUuidToPortDataMapping(PORT_DATA_3.getPortUuid(), PORT_DATA_3);
    portUuidToPortDataMapper.addUnprocessedUuidToPortDataMapping(PORT_DATA_4.getPortUuid(), PORT_DATA_4);
    portUuidToPortDataMapper.addPortDataToProcessed(PORT_DATA_1);
    portUuidToPortDataMapper.addPortDataToProcessed(PORT_DATA_2);
    portUuidToPortDataMapper.transferAllProcessedPortDataToUnprocessed();
    processedAndUnprocessedDataAmountVerify(portUuidToPortDataMapper, 0, 4);
    HashMap<String, PortData> unprocessedPortData = extractUnprocessedDataMap(portUuidToPortDataMapper);
    Assert.assertEquals(PORT_DATA_1, unprocessedPortData.get(PORT_DATA_1.getPortUuid()));
    Assert.assertEquals(PORT_DATA_2, unprocessedPortData.get(PORT_DATA_2.getPortUuid()));
    Assert.assertEquals(PORT_DATA_3, unprocessedPortData.get(PORT_DATA_3.getPortUuid()));
    Assert.assertEquals(PORT_DATA_4, unprocessedPortData.get(PORT_DATA_4.getPortUuid()));
}
Also used : PortUuidToPortDataMapper(org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with PortUuidToPortDataMapper

use of org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper in project lispflowmapping by opendaylight.

the class PortUuidToPortDataMapperTest method unprocessedPortDataAddTest.

@Test
public void unprocessedPortDataAddTest() {
    PortUuidToPortDataMapper portUuidToPortDataMapper = new PortUuidToPortDataMapper();
    portUuidToPortDataMapper.addUnprocessedUuidToPortDataMapping(PORT_DATA_1.getPortUuid(), PORT_DATA_1);
    portUuidToPortDataMapper.addUnprocessedUuidToPortDataMapping(PORT_DATA_2.getPortUuid(), PORT_DATA_2);
    processedAndUnprocessedDataAmountVerify(portUuidToPortDataMapper, 0, 2);
}
Also used : PortUuidToPortDataMapper(org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with PortUuidToPortDataMapper

use of org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper in project lispflowmapping by opendaylight.

the class HostInformationManager method attemptToCreateMappingRecord.

private synchronized void attemptToCreateMappingRecord(String hostId) {
    List<Rloc> rlocForMappingRecord = hostIdToRlocMapper.getRlocs(hostId);
    PortUuidToPortDataMapper uuidToEidMapper = hostIdToPortDataMapper.getAllPortData(hostId);
    if (rlocForMappingRecord == null || rlocForMappingRecord.isEmpty() || uuidToEidMapper == null) {
        return;
    }
    Collection<PortData> allUnprocessedPorts = uuidToEidMapper.getAllUnprocessedPorts();
    List<LocatorRecord> locators = LispAddressUtil.asLocatorRecords(rlocForMappingRecord);
    allUnprocessedPorts.forEach(portData -> {
        lfmDbService.addMapping(LispUtil.buildAddMappingInput(portData.getPortEid(), locators));
        uuidToEidMapper.addPortDataToProcessed(portData);
    });
    uuidToEidMapper.clearAllUnprocessedData();
}
Also used : PortUuidToPortDataMapper(org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 4 with PortUuidToPortDataMapper

use of org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper in project lispflowmapping by opendaylight.

the class HostInformationManager method attemptToDeleteMappingRecord.

private synchronized void attemptToDeleteMappingRecord(String hostId, String portUuid) {
    PortUuidToPortDataMapper uuidToEidMapper = hostIdToPortDataMapper.getAllPortData(hostId);
    if (uuidToEidMapper == null) {
        return;
    }
    PortData oldPortData = uuidToEidMapper.getProcessedPortData(portUuid);
    if (oldPortData == null) {
        return;
    }
    RemoveMappingInput removeMappingInput = LispUtil.buildRemoveMappingInput(oldPortData.getPortEid());
    lfmDbService.removeMapping(removeMappingInput);
    uuidToEidMapper.deleteProcessedPortData(portUuid);
}
Also used : PortUuidToPortDataMapper(org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper) RemoveMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInput)

Example 5 with PortUuidToPortDataMapper

use of org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper in project lispflowmapping by opendaylight.

the class PortUuidToPortDataMapperTest method addPortDataToProcessedTest.

@Test
public void addPortDataToProcessedTest() {
    PortUuidToPortDataMapper portUuidToPortDataMapper = new PortUuidToPortDataMapper();
    portUuidToPortDataMapper.addPortDataToProcessed(PORT_DATA_1);
    portUuidToPortDataMapper.addPortDataToProcessed(PORT_DATA_2);
    processedAndUnprocessedDataAmountVerify(portUuidToPortDataMapper, 2, 0);
}
Also used : PortUuidToPortDataMapper(org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

PortUuidToPortDataMapper (org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers.PortUuidToPortDataMapper)5 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)1 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)1 RemoveMappingInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInput)1