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);
}
}
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));
}
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);
}
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);
}
}
}
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));
}
Aggregations