use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValue in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method cacheRecordExpirationTest.
private void cacheRecordExpirationTest(boolean cacheRecordTimeouted) throws InterruptedException {
mapRegisterCache = Mockito.mock(MapRegisterCache.class);
Mockito.when(mockLispSouthboundPlugin.getMapRegisterCache()).thenReturn(mapRegisterCache);
final byte[] eidPrefixAfi = new byte[] { 0x00, 0x01 };
final byte[] eidPrefix = new byte[] { 0x0a, 0x0a, 0x0a, 0x0a };
MapRegisterCacheKeyBuilder cacheKeyBld = new MapRegisterCacheKeyBuilder();
cacheKeyBld.setXtrId(XTR_ID);
cacheKeyBld.setEidPrefix(eidPrefix);
cacheKeyBld.setSiteId(SITE_ID);
MapRegisterCacheMetadataBuilder cacheMetadataBld = new MapRegisterCacheMetadataBuilder();
cacheMetadataBld.setTimestamp(System.currentTimeMillis() - (cacheRecordTimeouted ? CACHE_RECORD_TIMEOUT : 0L));
cacheMetadataBld.setWantMapNotify(false);
MapRegisterCacheValueBuilder cacheValueBld = new MapRegisterCacheValueBuilder();
cacheValueBld.setMapRegisterCacheMetadata(cacheMetadataBld.build());
cacheValueBld.setPacketData(MapRegisterCacheTestUtil.joinArrays(DATA1, KEY_ID, DATA2, eidPrefixAfi, eidPrefix, DATA3, XTR_ID, SITE_ID));
final MapRegisterCacheKey cacheKey = cacheKeyBld.build();
final MapRegisterCacheValue cacheValue = cacheValueBld.build();
Mockito.when(mapRegisterCache.getEntry(Mockito.eq(cacheKey))).thenReturn(cacheRecordTimeouted ? null : cacheValue);
Mockito.when(mapRegisterCache.refreshEntry(Mockito.eq(cacheKey))).thenReturn(cacheValue);
mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
Mockito.verify(mockLispSouthboundPlugin, Mockito.atLeastOnce()).sendNotificationIfPossible(Mockito.any(AddMapping.class));
InOrder inOrder = Mockito.inOrder(mapRegisterCache);
inOrder.verify(mapRegisterCache).getEntry(Mockito.eq(cacheKey));
if (cacheRecordTimeouted) {
inOrder.verify(mapRegisterCache).addEntry(Mockito.eq(cacheKey), AdditionalMatchers.not(Mockito.eq(cacheValue)));
} else {
inOrder.verify(mapRegisterCache).refreshEntry(Mockito.eq(cacheKey));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValue in project lispflowmapping by opendaylight.
the class LispSouthboundHandler method refreshEntry.
private MapRegisterCacheValue refreshEntry(final MapRegisterCacheKey cacheKey) {
MapRegisterCacheValue mapRegisterCacheValue = lispSbPlugin.getMapRegisterCache().refreshEntry(cacheKey);
if (mapRegisterCacheValue != null) {
mapRegisterCacheValue = refreshAuthKeyIfNecessary(mapRegisterCacheValue);
lispSbPlugin.getMapRegisterCache().addEntry(cacheKey, mapRegisterCacheValue);
return mapRegisterCacheValue;
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValue in project lispflowmapping by opendaylight.
the class MapRegisterCache method refreshEntry.
public synchronized MapRegisterCacheValue refreshEntry(final MapRegisterCacheKey mapRegisterCacheKey) {
final MapRegisterCacheValue mapRegisterCacheValueOld = getEntry(mapRegisterCacheKey);
final MapRegisterCacheMetadata mapRegisterCacheMetadataOld = mapRegisterCacheValueOld.getMapRegisterCacheMetadata();
final MapRegisterCacheMetadataBuilder mapRegisterCacheMetadataBuilderNew = new MapRegisterCacheMetadataBuilder(mapRegisterCacheMetadataOld);
mapRegisterCacheMetadataBuilderNew.setTimestamp(System.currentTimeMillis());
final MapRegisterCacheValueBuilder mapRegisterCacheValueBuilderNew = new MapRegisterCacheValueBuilder();
mapRegisterCacheValueBuilderNew.setPacketData(mapRegisterCacheValueOld.getPacketData());
mapRegisterCacheValueBuilderNew.setMappingAuthkey(mapRegisterCacheValueOld.getMappingAuthkey());
mapRegisterCacheValueBuilderNew.setMapRegisterCacheMetadata(mapRegisterCacheMetadataBuilderNew.build());
return mapRegisterCacheValueBuilderNew.build();
}
Aggregations