import java.util.concurrent.ThreadFactory;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.lispflowmapping.dsbackend.DataStoreBackEnd;
+import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
+import org.opendaylight.lispflowmapping.mapcache.SimpleMapCache;
+import org.opendaylight.lispflowmapping.southbound.lisp.AuthenticationKeyDataListener;
import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundHandler;
import org.opendaylight.lispflowmapping.southbound.lisp.LispXtrSouthboundHandler;
+import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
LISPFLOWMAPPING_ENTITY_NAME);
private volatile String bindingAddress;
+ private SimpleMapCache smc;
+ private MapRegisterCache mapRegisterCache = new MapRegisterCache();
private boolean mapRegisterCacheEnabled;
private long mapRegisterCacheTimeout;
private ThreadFactory threadFactory = new DefaultThreadFactory("lisp-sb");
private EventLoopGroup eventLoopGroup;
private DataBroker dataBroker;
+ private AuthenticationKeyDataListener authenticationKeyDataListener;
+ private DataStoreBackEnd dsbe;
public LispSouthboundPlugin(final DataBroker dataBroker,
final NotificationPublishService notificationPublishService,
public void init() {
LOG.info("LISP (RFC6830) Southbound Plugin is initializing...");
synchronized (startLock) {
+ this.smc = new SimpleMapCache(new HashMapDb());
+ this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, smc);
+ this.dsbe = new DataStoreBackEnd(dataBroker);
+
lispSouthboundHandler = new LispSouthboundHandler(this);
lispSouthboundHandler.setDataBroker(dataBroker);
- lispSouthboundHandler.setNotificationProvider(this.notificationPublishService);
- lispSouthboundHandler.setMapRegisterCacheEnabled(mapRegisterCacheEnabled);
+ lispSouthboundHandler.setNotificationProvider(notificationPublishService);
+ lispSouthboundHandler.setSimpleMapCache(smc);
+ lispSouthboundHandler.setMapRegisterCache(mapRegisterCache);
lispSouthboundHandler.setMapRegisterCacheTimeout(mapRegisterCacheTimeout);
- lispSouthboundHandler.init();
+ lispSouthboundHandler.setAuthenticationKeyDataListener(authenticationKeyDataListener);
+ lispSouthboundHandler.setDataStoreBackEnd(dsbe);
+ lispSouthboundHandler.setStats(statistics);
lispSouthboundHandler.restoreDaoFromDatastore();
lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
- lispXtrSouthboundHandler.setNotificationProvider(this.notificationPublishService);
+ lispXtrSouthboundHandler.setNotificationProvider(notificationPublishService);
if (Epoll.isAvailable()) {
eventLoopGroup = new EpollEventLoopGroup(0, threadFactory);
return SERVICE_GROUP_IDENTIFIER;
}
+ public MapRegisterCache getMapRegisterCache() {
+ return mapRegisterCache;
+ }
+
+ public boolean isMapRegisterCacheEnabled() {
+ return mapRegisterCacheEnabled;
+ }
+
+ public long getMapRegisterCacheTimeout() {
+ return mapRegisterCacheTimeout;
+ }
}
package org.opendaylight.lispflowmapping.southbound.lisp;
-import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.lispflowmapping.dsbackend.DataStoreBackEnd;
-import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
import org.opendaylight.lispflowmapping.lisp.authentication.ILispAuthentication;
import org.opendaylight.lispflowmapping.lisp.authentication.LispAuthenticationUtil;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramPacket>
implements ILispSouthboundService, AutoCloseable {
private MapRegisterCache mapRegisterCache;
- private boolean mapRegisterCacheEnabled = true;
private long mapRegisterCacheTimeout;
private DataBroker dataBroker;
public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin) {
this.lispSbPlugin = lispSbPlugin;
- if (lispSbPlugin != null) {
- this.lispSbStats = lispSbPlugin.getStats();
- }
- this.mapRegisterCache = new MapRegisterCache();
- this.smc = new SimpleMapCache(new HashMapDb());
}
public void handlePacket(DatagramPacket msg) {
Map.Entry<MapRegisterCacheKey, byte[]> artificialEntry = null;
MapRegisterCacheKey cacheKey = null;
MapRegisterCacheValue cacheValue = null;
- if (mapRegisterCacheEnabled) {
+ if (lispSbPlugin.isMapRegisterCacheEnabled()) {
artificialEntry = MapRegisterPartialDeserializer.deserializePartially(inBuffer, sourceAddress);
cacheKey = artificialEntry == null ? null : artificialEntry.getKey();
cacheValue = resolveCacheValue(artificialEntry);
@Override
public void close() throws Exception {
- authenticationKeyDataListener.closeDataChangeListener();
}
public void setSimpleMapCache(final SimpleMapCache smc) {
this.mapRegisterCache = mapRegisterCache;
}
- public void setMapRegisterCacheEnabled(final boolean mapRegisterCacheEnabled) {
- this.mapRegisterCacheEnabled = mapRegisterCacheEnabled;
+ public void setAuthenticationKeyDataListener(AuthenticationKeyDataListener authenticationKeyDataListener) {
+ this.authenticationKeyDataListener = authenticationKeyDataListener;
+ }
+
+ public void setDataStoreBackEnd(DataStoreBackEnd dsbe) {
+ this.dsbe = dsbe;
+ }
+
+ public void setStats(LispSouthboundStats lispSbStats) {
+ this.lispSbStats = lispSbStats;
}
/**
}
}
- public void init() {
- Preconditions.checkNotNull(dataBroker);
- Preconditions.checkNotNull(smc);
- this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, smc);
- dsbe = new DataStoreBackEnd(dataBroker);
- }
-
public void setIsMaster(boolean isReadFromChannelEnabled) {
this.isReadFromChannelEnabled = isReadFromChannelEnabled;
}
import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.lispflowmapping.dsbackend.DataStoreBackEnd;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
private MappingRecordBuilder mappingRecordBuilder;
private MapRegisterCache mapRegisterCache;
private LispSouthboundPlugin mockLispSouthboundPlugin;
+ private LispSouthboundStats lispSouthboundStats;
private static final long CACHE_RECORD_TIMEOUT = 90000;
private static SimpleMapCache smc;
// mapServer = context.mock(IMapServer.class);
mockLispSouthboundPlugin = mock(LispSouthboundPlugin.class);
Mockito.when(mockLispSouthboundPlugin.getStats()).thenReturn(Mockito.mock(LispSouthboundStats.class));
+ Mockito.when(mockLispSouthboundPlugin.isMapRegisterCacheEnabled()).thenReturn(true);
testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin);
testedLispService.setMapRegisterCacheTimeout(90000);
mapRegisterCache = new MapRegisterCache();
testedLispService.setMapRegisterCache(mapRegisterCache);
testedLispService.setDataBroker(Mockito.mock(DataBroker.class));
testedLispService.setSimpleMapCache(smc);
- testedLispService.init();
+ testedLispService.setAuthenticationKeyDataListener(Mockito.mock(AuthenticationKeyDataListener.class));
+ testedLispService.setDataStoreBackEnd(Mockito.mock(DataStoreBackEnd.class));
nps = context.mock(NotificationPublishService.class);
testedLispService.setNotificationProvider(nps);
+ lispSouthboundStats = new LispSouthboundStats();
+ testedLispService.setStats(lispSouthboundStats);
lispNotificationSaver = new ValueSaverAction<Notification>();
// mapRegisterSaver = new ValueSaverAction<MapRegister>();
// mapRequestSaver = new ValueSaverAction<MapRequest>();