Search in sources :

Example 21 with ILispDAO

use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.

the class SimpleMapCache method removeData.

@Override
public void removeData(Eid eid, String subKey) {
    ILispDAO table = getVniTable(eid);
    if (table == null) {
        return;
    }
    Eid key = MaskUtil.normalize(eid);
    table.removeSpecific(key, subKey);
    if (table.isEmpty()) {
        removeVniTable(eid);
    }
}
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 22 with ILispDAO

use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.

the class SimpleMapCache method addMapping.

@Override
public void addMapping(Eid key, XtrId xtrId, Object value) {
    Eid eid = MaskUtil.normalize(key);
    ILispDAO table = getOrInstantiateVniTable(key);
    ILispDAO xtrIdDao = getOrInstantiateXtrIdTable(eid, table);
    xtrIdDao.put(xtrId, new MappingEntry<>(SubKeys.RECORD, value));
}
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 23 with ILispDAO

use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.

the class SimpleMapCache method getData.

@Override
public Object getData(Eid eid, String subKey) {
    ILispDAO table = getVniTable(eid);
    if (table == null) {
        return null;
    }
    Eid key = MaskUtil.normalize(eid);
    return table.getSpecific(key, subKey);
}
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 24 with ILispDAO

use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.

the class SimpleMapCache method removeXtrIdMappings.

@Override
public void removeXtrIdMappings(Eid eid, List<XtrId> xtrIds) {
    ILispDAO table = getVniTable(eid);
    if (table == null) {
        return;
    }
    Eid key = MaskUtil.normalize(eid);
    ILispDAO xtrIdTable = (ILispDAO) table.getSpecific(key, SubKeys.XTRID_RECORDS);
    if (xtrIdTable == null) {
        return;
    }
    for (XtrId xtrId : xtrIds) {
        xtrIdTable.removeSpecific(xtrId, SubKeys.RECORD);
    }
    if (xtrIdTable.isEmpty()) {
        table.removeSpecific(key, SubKeys.XTRID_RECORDS);
        if (table.isEmpty()) {
            removeVniTable(eid);
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 25 with ILispDAO

use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.

the class SimpleMapCacheTest method getAllXtrIdMappings_withMaskableAddress.

/**
 * Tests {@link SimpleMapCache#getAllXtrIdMappings} method with maskable address.
 */
@Test
@SuppressWarnings("unchecked")
public void getAllXtrIdMappings_withMaskableAddress() {
    final Eid normalizedKey = MaskUtil.normalize(EID_IPV4_PREFIX_1_VNI, MASK);
    final Map<String, Object> entryMock = Mockito.mock(Map.class);
    final ILispDAO xtrIdRecordsMock = Mockito.mock(ILispDAO.class);
    Mockito.when(daoMock.getSpecific(VNI_100, SubKeys.VNI)).thenReturn(tableMock);
    Mockito.when(tableMock.getBest(normalizedKey)).thenReturn(entryMock);
    Mockito.when(entryMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdRecordsMock);
    Mockito.when(xtrIdRecordsMock.getSpecific(EID_IPV4_PREFIX_1_VNI, SubKeys.RECORD)).thenReturn(xtrIdDaoMock);
    simpleMapCache.getAllXtrIdMappings(EID_IPV4_PREFIX_1_VNI);
    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

ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)27 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)19 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)7 Test (org.junit.Test)4 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)1 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)1