Search in sources :

Example 21 with LocatorRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder in project lispflowmapping by opendaylight.

the class MapResolverTest method handleMapRequest__withSingleLocator.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
public void handleMapRequest__withSingleLocator() {
    // input mapping
    final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
    final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
    // result
    final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
    mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
    mapResolver.handleMapRequest(mapRequestBuilder.build());
    Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) Test(org.junit.Test)

Example 22 with LocatorRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder in project lispflowmapping by opendaylight.

the class MappingMergeUtilTest method getCommonLocatorRecords_priorityCheck.

/**
 * Tests {@link MappingMergeUtil#getCommonLocatorRecords} method, verifies that NB common locator's priority is set
 * to correct value (based on SB locator's priority).
 */
@Test
public void getCommonLocatorRecords_priorityCheck() {
    LocatorRecordBuilder nbLocatorRecordBuilder1 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_1).setPriority((short) 1).setLocatorId("NB-locator-id");
    LocatorRecordBuilder sbLocatorRecordBuilder1 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_1).setPriority((short) 255).setLocatorId("SB-locator-id");
    LocatorRecordBuilder nbLocatorRecordBuilder2 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_2).setPriority((short) 1).setLocatorId("NB-locator-id");
    LocatorRecordBuilder sbLocatorRecordBuilder2 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_2).setPriority((short) 254).setLocatorId("SB-locator-id");
    final MappingRecordBuilder nbMappingRecordBuilder = getDefaultMappingRecordBuilder();
    nbMappingRecordBuilder.getLocatorRecord().add(nbLocatorRecordBuilder1.build());
    nbMappingRecordBuilder.getLocatorRecord().add(nbLocatorRecordBuilder2.build());
    final MappingRecordBuilder sbMappingRecordBuilder = getDefaultMappingRecordBuilder();
    sbMappingRecordBuilder.getLocatorRecord().add(sbLocatorRecordBuilder1.build());
    sbMappingRecordBuilder.getLocatorRecord().add(sbLocatorRecordBuilder2.build());
    MappingData nbMappingData = getDefaultMappingData(nbMappingRecordBuilder.build());
    MappingData sbMappingData = getDefaultMappingData(sbMappingRecordBuilder.build());
    // result
    final MappingData result = MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
    final Iterator<LocatorRecord> iterator = result.getRecord().getLocatorRecord().iterator();
    final LocatorRecord resultLocator_1 = iterator.next();
    final LocatorRecord resultLocator_2 = iterator.next();
    assertEquals(2, result.getRecord().getLocatorRecord().size());
    assertEquals("NB-locator-id", resultLocator_1.getLocatorId());
    // priority changed to 255
    assertEquals(255, (short) resultLocator_1.getPriority());
    assertEquals("NB-locator-id", resultLocator_2.getLocatorId());
    // priority remains original
    assertEquals(1, (short) resultLocator_2.getPriority());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Example 23 with LocatorRecordBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder in project lispflowmapping by opendaylight.

the class LispAddressUtil method asLocatorRecords.

public static List<LocatorRecord> asLocatorRecords(List<Rloc> locators) {
    List<LocatorRecord> locatorRecords = new ArrayList<LocatorRecord>();
    for (Rloc locator : locators) {
        LocatorRecordBuilder locatorBuilder = new LocatorRecordBuilder();
        locatorBuilder.setLocalLocator(false).setRlocProbed(false).setWeight((short) 1).setPriority((short) 1).setMulticastWeight((short) 1).setMulticastPriority((short) 1).setRouted(true).setRloc(locator).setLocatorId("SFC_LISP").build();
        locatorRecords.add(locatorBuilder.build());
    }
    return locatorRecords;
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) ArrayList(java.util.ArrayList) 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)

Aggregations

LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)13 Test (org.junit.Test)11 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)11 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)9 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)8 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)7 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)7 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)6 ArrayList (java.util.ArrayList)5 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)4 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)4 Ignore (org.junit.Ignore)3 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)3 ByteBuffer (java.nio.ByteBuffer)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)2 ExplicitLocatorPath (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)2 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2