Search in sources :

Example 81 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.

the class SimpleMapCache method addMapping.

@Override
public void addMapping(Eid key, Object value, Set<IpAddressBinary> sourceRlocs) {
    Eid eid = MaskUtil.normalize(key);
    ILispDAO table = getOrInstantiateVniTable(key);
    table.put(eid, new MappingEntry<>(SubKeys.RECORD, value));
    if (sourceRlocs != null) {
        table.put(eid, new MappingEntry<>(SubKeys.SRC_RLOCS, sourceRlocs));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)

Example 82 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.

the class SimpleMapCache method addData.

@Override
public void addData(Eid eid, String subKey, Object data) {
    ILispDAO table = getOrInstantiateVniTable(eid);
    Eid key = MaskUtil.normalize(eid);
    table.put(key, new MappingEntry<>(subKey, data));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)

Example 83 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.

the class MultiTableMapCacheTest method getMappingTest_withSourceDestKey.

/**
 * Tests {@link MultiTableMapCache#getMapping} with SourceDestKey address type.
 */
@Test
public void getMappingTest_withSourceDestKey() {
    when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
    final Eid dstAddr = SourceDestKeyHelper.getDstBinary(EID_SOURCE_DEST_KEY_TYPE);
    final Eid normalizedDstAddr = MaskUtil.normalize(dstAddr);
    final Eid srcAddr = SourceDestKeyHelper.getSrcBinary(EID_SOURCE_DEST_KEY_TYPE);
    final Eid normalizedSrcAddr = MaskUtil.normalize(srcAddr);
    final Map<String, Object> entry = getEntry1();
    final Map<String, Object> entry2 = getEntry2();
    when(tableDaoMock.getBest(normalizedDstAddr)).thenReturn(entry);
    when(srcDstDaoMock.getBest(normalizedSrcAddr)).thenReturn(entry2);
    assertEquals(DUMMY_OBJECT_2, multiTableMapCache.getMapping(null, EID_SOURCE_DEST_KEY_TYPE));
    assertNull(multiTableMapCache.getMapping(null, null));
    assertNull(multiTableMapCache.getMapping(EID_TEST, null));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Test(org.junit.Test)

Example 84 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.

the class MultiTableMapCacheTest method getMappingTest_withIpv4Prefix.

/**
 * Tests {@link MultiTableMapCache#getMapping} with Ipv4Prefix address type.
 */
@Test
public void getMappingTest_withIpv4Prefix() {
    final Eid key = MaskUtil.normalize(EID_IPV4_PREFIX_DST, (short) 24);
    final Eid key2 = MaskUtil.normalize(MaskUtil.normalize(EID_IPV4_PREFIX_SRC), (short) 24);
    final Map<String, Object> entry = getEntry1();
    final Map<String, Object> entry2 = getEntry2();
    when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
    when(tableDaoMock.getBest(key)).thenReturn(entry);
    when(srcDstDaoMock.getBest(LispAddressUtil.asIpPrefixBinaryEid(key2))).thenReturn(entry2);
    assertEquals(DUMMY_OBJECT_2, multiTableMapCache.getMapping(EID_IPV4_PREFIX_SRC, EID_IPV4_PREFIX_DST));
    assertEquals(DUMMY_OBJECT, multiTableMapCache.getMapping(null, EID_IPV4_PREFIX_DST));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Test(org.junit.Test)

Example 85 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.

the class SimpleMapCacheTest method getAllXtrIdMappings_withNonMaskableAddress.

/**
 * Tests {@link SimpleMapCache#getAllXtrIdMappings} method with non maskable address.
 */
@Test
@SuppressWarnings("unchecked")
public void getAllXtrIdMappings_withNonMaskableAddress() {
    final Map<String, Object> entryMock = Mockito.mock(Map.class);
    final ILispDAO xtrIdRecordsMock = Mockito.mock(ILispDAO.class);
    Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
    Mockito.when(tableMock.getBest(NORMALIZED_EID_IPV4)).thenReturn(entryMock);
    Mockito.when(entryMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdRecordsMock);
    Mockito.when(xtrIdRecordsMock.getSpecific(EID_IPV4, SubKeys.RECORD)).thenReturn(xtrIdDaoMock);
    simpleMapCache.getAllXtrIdMappings(EID_IPV4);
    Mockito.verify(tableMock).getBest(Mockito.any(Eid.class));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)94 ByteBuf (io.netty.buffer.ByteBuf)82 Test (org.junit.Test)62 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)34 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)33 ExecutionException (java.util.concurrent.ExecutionException)30 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 List (java.util.List)21 HashMap (java.util.HashMap)19 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17 Nullable (org.eclipse.jdt.annotation.Nullable)16 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)16 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)15 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)15 FutureCallback (com.google.common.util.concurrent.FutureCallback)14 BigInteger (java.math.BigInteger)14