InstanceIdentifier.create(MappingDatabase.class);
private static final InstanceIdentifier<LastUpdated> LAST_UPDATED =
InstanceIdentifier.create(MappingDatabase.class).child(LastUpdated.class);
+ private DataBroker broker;
private BindingTransactionChain txChain;
public DataStoreBackEnd(DataBroker broker) {
- this.txChain = broker.createTransactionChain(this);
+ this.broker = broker;
+ createTransactionChain();
}
+ public void createTransactionChain() {
+ LOG.debug("Creating DataStoreBackEnd transaction chain...");
+ txChain = broker.createTransactionChain(this);
+ }
public void addAuthenticationKey(AuthenticationKey authenticationKey) {
if (LOG.isDebugEnabled()) {
public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
LOG.info("DataStoreBackEnd closed successfully, chain {}", chain);
}
+
+ public void closeTransactionChain() {
+ LOG.debug("Closing DataStoreBackEnd transaction chain...");
+ txChain.close();
+ }
}
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
+import java.util.List;
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.lisp.util.LispAddressStringifier;
import org.opendaylight.lispflowmapping.mapcache.AuthKeyDb;
import org.opendaylight.lispflowmapping.southbound.lisp.AuthenticationKeyDataListener;
import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundHandler;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.dataBroker = dataBroker;
this.notificationPublishService = notificationPublishService;
this.clusterSingletonService = clusterSingletonService;
- this.clusterSingletonService.registerClusterSingletonService(this);
if (Epoll.isAvailable()) {
// When lispflowmapping is under heavy load, there are usually two threads nearing 100% CPU core
// utilization. In order to have some headroom, we reserve 3 cores for "other" tasks, and allow the
this.akdb = new AuthKeyDb(new HashMapDb());
this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, akdb);
this.dsbe = new DataStoreBackEnd(dataBroker);
+ restoreDaoFromDatastore();
- lispSouthboundHandler = new LispSouthboundHandler(this);
+ LispSouthboundHandler lispSouthboundHandler = new LispSouthboundHandler(this);
lispSouthboundHandler.setDataBroker(dataBroker);
lispSouthboundHandler.setNotificationProvider(notificationPublishService);
lispSouthboundHandler.setAuthKeyDb(akdb);
lispSouthboundHandler.setMapRegisterCache(mapRegisterCache);
lispSouthboundHandler.setMapRegisterCacheTimeout(mapRegisterCacheTimeout);
lispSouthboundHandler.setAuthenticationKeyDataListener(authenticationKeyDataListener);
- lispSouthboundHandler.setDataStoreBackEnd(dsbe);
lispSouthboundHandler.setStats(statistics);
- lispSouthboundHandler.restoreDaoFromDatastore();
+ this.lispSouthboundHandler = lispSouthboundHandler;
- lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
+ LispXtrSouthboundHandler lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
lispXtrSouthboundHandler.setNotificationProvider(notificationPublishService);
+ this.lispXtrSouthboundHandler = lispXtrSouthboundHandler;
if (Epoll.isAvailable()) {
eventLoopGroup = new EpollEventLoopGroup(numChannels, threadFactory);
start();
startXtr();
+ clusterSingletonService.registerClusterSingletonService(this);
LOG.info("LISP (RFC6830) Southbound Plugin is up!");
}
}
LOG.info("LISP (RFC6830) Southbound Plugin is down!");
}
+ /**
+ * Restore all keys from MDSAL datastore.
+ */
+ public void restoreDaoFromDatastore() {
+ final List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
+ LOG.info("Restoring {} keys from datastore into southbound DAO", authKeys.size());
+
+ for (AuthenticationKey authKey : authKeys) {
+ final Eid key = authKey.getEid();
+ final MappingAuthkey mappingAuthkey = authKey.getMappingAuthkey();
+ LOG.debug("Adding authentication key '{}' with key-ID {} for {}", mappingAuthkey.getKeyString(),
+ mappingAuthkey.getKeyType(),
+ LispAddressStringifier.getString(key));
+ akdb.addAuthenticationKey(key, mappingAuthkey);
+ }
+ }
+
public void handleSerializedLispBuffer(TransportAddress address, ByteBuffer outBuffer,
final MessageType packetType) {
InetAddress ip = getInetAddress(address);
lispSouthboundHandler.close();
unloadActions();
clusterSingletonService.close();
+ dsbe.closeTransactionChain();
}
@Override
public void instantiateServiceInstance() {
if (lispSouthboundHandler != null) {
lispSouthboundHandler.setNotificationProvider(notificationPublishService);
- lispSouthboundHandler.restoreDaoFromDatastore();
lispSouthboundHandler.setIsMaster(true);
}
if (lispXtrSouthboundHandler != null) {
import java.util.Objects;
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.authentication.ILispAuthentication;
import org.opendaylight.lispflowmapping.lisp.authentication.LispAuthenticationUtil;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private ConcurrentLispSouthboundStats lispSbStats = null;
private AuthKeyDb akdb;
private AuthenticationKeyDataListener authenticationKeyDataListener;
- private DataStoreBackEnd dsbe;
private boolean isReadFromChannelEnabled = true;
private Channel channel;
this.authenticationKeyDataListener = authenticationKeyDataListener;
}
- public void setDataStoreBackEnd(DataStoreBackEnd dsbe) {
- this.dsbe = dsbe;
- }
-
public void setStats(ConcurrentLispSouthboundStats lispSbStats) {
this.lispSbStats = lispSbStats;
}
- /**
- * Restore all keys from MDSAL datastore.
- */
- public void restoreDaoFromDatastore() {
- final List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
- LOG.info("Restoring {} keys from datastore into southbound DAO", authKeys.size());
-
- for (AuthenticationKey authKey : authKeys) {
- final Eid key = authKey.getEid();
- final MappingAuthkey mappingAuthkey = authKey.getMappingAuthkey();
- LOG.debug("Adding authentication key '{}' with key-ID {} for {}", mappingAuthkey.getKeyString(),
- mappingAuthkey.getKeyType(),
- LispAddressStringifier.getString(key));
- akdb.addAuthenticationKey(key, mappingAuthkey);
- }
- }
-
public void setIsMaster(boolean isReadFromChannelEnabled) {
this.isReadFromChannelEnabled = isReadFromChannelEnabled;
}