package org.opendaylight.lispflowmapping.implementation;
import java.util.List;
-
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
import org.opendaylight.lispflowmapping.implementation.lisp.MapResolver;
import org.opendaylight.lispflowmapping.implementation.lisp.MapServer;
import org.opendaylight.lispflowmapping.implementation.util.LispNotificationHelper;
-import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapRequestResultHandler;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
+import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LispMappingService implements IFlowMapping, BindingAwareProvider, IMapRequestResultHandler,
+public class LispMappingService implements IFlowMapping, IMapRequestResultHandler,
IMapNotifyHandler, OdlLispProtoListener, AutoCloseable {
protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
private ThreadLocal<Pair<MapRequest, TransportAddress>> tlsMapRequest =
new ThreadLocal<Pair<MapRequest, TransportAddress>>();
- private OdlLispSbService lispSB = null;
+ private final OdlLispSbService lispSB;
private IMapResolverAsync mapResolver;
private IMapServerAsync mapServer;
- private IMappingService mapService;
- private NotificationService notificationService;
- private BindingAwareBroker broker;
- private ProviderContext session;
-
- public LispMappingService() {
- LOG.debug("LispMappingService Module constructed!");
- }
-
- public void setBindingAwareBroker(BindingAwareBroker broker) {
- this.broker = broker;
- }
+ private final IMappingService mapService;
+ private final NotificationService notificationService;
- public void setNotificationService(NotificationService ns) {
- this.notificationService = ns;
- }
+ public LispMappingService(final NotificationService notificationService,
+ final IMappingService mappingService,
+ final OdlLispSbService odlLispService) {
- public void setMappingService(IMappingService ms) {
- LOG.trace("MappingService set in LispMappingService");
- this.mapService = ms;
+ this.notificationService = notificationService;
+ this.mapService = mappingService;
+ this.lispSB = odlLispService;
+ LOG.debug("LispMappingService Module constructed!");
}
public boolean shouldUseSmr() {
}
public void initialize() {
- broker.registerProvider(this);
- notificationService.registerNotificationListener(this);
mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
mapServer = new MapServer(mapService, smr, this, notificationService);
+ LOG.info("LISP (RFC6830) Mapping Service init finished");
}
public void basicInit() {
mapServer = new MapServer(mapService, smr, this, notificationService);
}
- @Override
- public void onSessionInitiated(ProviderContext session) {
- LOG.info("Lisp Consumer session initialized!");
- this.session = session;
- LOG.info("LISP (RFC6830) Mapping Service init finished");
- }
-
public MapReply handleMapRequest(MapRequest request) {
if (LOG.isDebugEnabled()) {
LOG.debug("DAO: Retrieving mapping for {}",
Pair<MapNotify, List<TransportAddress>> result = handleMapRegister(mapRegisterNotification.getMapRegister());
if (result != null && result.getLeft() != null) {
MapNotify mapNotify = result.getLeft();
- List <TransportAddress> rlocs = result.getRight();
+ List<TransportAddress> rlocs = result.getRight();
if (rlocs == null) {
TransportAddressBuilder tab = new TransportAddressBuilder();
tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
getLispSB().sendMapReply(smrib.build());
} else {
- LOG.warn("got null map reply");
+ LOG.debug("handleMapRequest: Got null MapReply");
}
}
}
private OdlLispSbService getLispSB() {
- if (lispSB == null) {
- lispSB = session.getRpcService(OdlLispSbService.class);
- }
return lispSB;
}