use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO 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));
}
}
use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO 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));
}
use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO 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));
}
use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.
the class HashMapDb method putTable.
@Override
public ILispDAO putTable(String key) {
ILispDAO table = (ILispDAO) getSpecific(TABLES, key);
if (table != null) {
LOG.warn("Trying to add table that already exists. Aborting!");
return table;
}
table = new HashMapDb();
put(TABLES, new MappingEntry<>(key, table));
return table;
}
use of org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO in project lispflowmapping by opendaylight.
the class HashMapDbTest method testPutTable_entryExists.
@Test
public void testPutTable_entryExists() throws Exception {
Object dbEntryKey = "tables";
String mapKey1 = "mapKey1";
ILispDAO mapValue1 = new HashMapDb();
map.put(dbEntryKey, new MappingEntry<>(mapKey1, mapValue1));
Assert.assertEquals(mapValue1, map.putTable(mapKey1));
Assert.assertEquals(mapValue1, map.getSpecific(dbEntryKey, mapKey1));
}
Aggregations