Checkstyle: fix issues and enforce on implementation
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / LispMappingService.java
index 0f39a018a7ae7c155c8efe6df029d30f96b0e757..47f5e7821cd3254d73c3b559438750da29fe7593 100644 (file)
 
 package org.opendaylight.lispflowmapping.implementation;
 
-import java.net.InetAddress;
-
+import java.util.List;
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKey;
-import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceNoMaskKey;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+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.LispAFIConvertor;
 import org.opendaylight.lispflowmapping.implementation.util.LispNotificationHelper;
-import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
-import org.opendaylight.lispflowmapping.interfaces.dao.ILispTypeConverter;
-import org.opendaylight.lispflowmapping.interfaces.dao.IQueryAll;
-import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
 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.type.sbplugin.ILispSouthboundPlugin;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.AddMapping;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRegister;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.RequestMapping;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainerBuilder;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.Address;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
+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.proto.rev151105.MapNotify;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MappingKeepAlive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.OdlLispProtoListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrReplyMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping;
+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.map.register.cache.metadata.container.MapRegisterCacheMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.OdlLispSbService;
+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.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class LispMappingService implements CommandProvider, IFlowMapping, BindingAwareConsumer, //
-        IMapRequestResultHandler, IMapNotifyHandler {
-    protected static final Logger logger = LoggerFactory.getLogger(LispMappingService.class);
-
-    private ILispDAO lispDao = null;
-    private IMapResolverAsync mapResolver;
-    private IMapServerAsync mapServer;
-    private volatile boolean shouldIterateMask;
-    private volatile boolean shouldAuthenticate;
-    private ThreadLocal<MapReply> tlsMapReply = new ThreadLocal<MapReply>();
-    private ThreadLocal<MapNotify> tlsMapNotify = new ThreadLocal<MapNotify>();
-    private ThreadLocal<Pair<MapRequest, InetAddress>> tlsMapRequest = new ThreadLocal<Pair<MapRequest, InetAddress>>();
-
-    private ILispSouthboundPlugin lispSB = null;
-
-    private ConsumerContext session;
+public class LispMappingService implements IFlowMapping, IMapRequestResultHandler,
+        IMapNotifyHandler, OdlLispProtoListener, AutoCloseable {
+    protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
 
-    class LispIpv4AddressInMemoryConverter implements ILispTypeConverter<Ipv4Address, Integer> {
-    }
-
-    class LispIpv6AddressInMemoryConverter implements ILispTypeConverter<Ipv6Address, Integer> {
-    }
+    private volatile boolean smr = ConfigIni.getInstance().smrIsSet();
+    private volatile String elpPolicy = ConfigIni.getInstance().getElpPolicy();
 
-    class MappingServiceKeyConvertor implements ILispTypeConverter<MappingServiceKey, Integer> {
-    }
+    private ThreadLocal<MapReply> tlsMapReply = new ThreadLocal<MapReply>();
+    private ThreadLocal<Pair<MapNotify, List<TransportAddress>>> tlsMapNotify =
+            new ThreadLocal<Pair<MapNotify, List<TransportAddress>>>();
+    private ThreadLocal<Pair<MapRequest, TransportAddress>> tlsMapRequest =
+            new ThreadLocal<Pair<MapRequest, TransportAddress>>();
 
-    class MappingServiceNoMaskKeyConvertor implements ILispTypeConverter<MappingServiceNoMaskKey, Integer> {
-    }
+    private final OdlLispSbService lispSB;
+    private IMapResolverAsync mapResolver;
+    private IMapServerAsync mapServer;
 
-    void setBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
-        logger.trace("BindingAwareBroker set!");
-        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-        bindingAwareBroker.registerConsumer(this, bundleContext);
-    }
+    private final IMappingService mapService;
+    private final NotificationService notificationService;
 
-    void unsetBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
-        logger.debug("BindingAwareBroker was unset in LispMappingService");
-    }
+    public LispMappingService(final NotificationService notificationService,
+            final IMappingService mappingService,
+            final OdlLispSbService odlLispService) {
 
-    public void basicInit(ILispDAO dao) {
-        lispDao = dao;
-        mapResolver = new MapResolver(dao);
-        mapServer = new MapServer(dao);
+        this.notificationService = notificationService;
+        this.mapService = mappingService;
+        this.lispSB = odlLispService;
+        LOG.debug("LispMappingService Module constructed!");
     }
 
-    void setLispDao(ILispDAO dao) {
-        logger.trace("LispDAO set in LispMappingService");
-        basicInit(dao);
+    public boolean shouldUseSmr() {
+        return this.smr;
     }
 
-    void unsetLispDao(ILispDAO dao) {
-        logger.trace("LispDAO was unset in LispMappingService");
-        mapServer = null;
-        mapResolver = null;
-        lispDao = null;
-    }
-
-    public void init() {
-        try {
-            registerWithOSGIConsole();
-            logger.info("LISP (RFC6830) Mapping Service init finished");
-        } catch (Throwable t) {
-            logger.error(t.getStackTrace().toString());
+    public void setShouldUseSmr(boolean smr) {
+        this.smr = smr;
+        if (mapServer != null) {
+            mapServer.setSubscriptionService(smr);
         }
-    }
-
-    private void registerWithOSGIConsole() {
-        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-        bundleContext.registerService(CommandProvider.class.getName(), this, null);
-    }
-
-    public void destroy() {
-        logger.info("LISP (RFC6830) Mapping Service is destroyed!");
-        mapResolver = null;
-        mapServer = null;
-    }
-
-    public void _removeEid(final CommandInterpreter ci) {
-        lispDao.remove(LispAFIConvertor.asIPAfiAddress(ci.nextArgument()));
-    }
-
-    public void _dumpAll(final CommandInterpreter ci) {
-        ci.println("EID\tRLOCs");
-        if (lispDao instanceof IQueryAll) {
-            ((IQueryAll) lispDao).getAll(new IRowVisitor() {
-                String lastKey = "";
-
-                public void visitRow(Object keyId, String valueKey, Object value) {
-                    String key = keyId.getClass().getSimpleName() + "#" + keyId;
-                    if (!lastKey.equals(key)) {
-                        ci.println();
-                        ci.print(key + "\t");
-                    }
-                    ci.print(valueKey + "=" + value + "\t");
-                    lastKey = key;
-                }
-            });
-            ci.println();
-        } else {
-            ci.println("Not implemented by this DAO");
+        if (mapResolver != null) {
+            mapResolver.setSubscriptionService(smr);
         }
-        return;
+        ConfigIni.getInstance().setSmr(smr);
     }
 
-    public void _setShouldOverwriteRlocs(final CommandInterpreter ci) {
-        try {
-            boolean shouldOverwriteRloc = Boolean.parseBoolean(ci.nextArgument());
-            setOverwrite(shouldOverwriteRloc);
-        } catch (Exception e) {
-            ci.println("Bad Usage!!");
-        }
-
+    public NotificationService getNotificationService() {
+        return this.notificationService;
     }
 
-    public void _addDefaultPassword(final CommandInterpreter ci) {
-        LispAddressContainerBuilder builder = new LispAddressContainerBuilder();
-        builder.setAddress((Address) (new Ipv4Builder().setIpv4Address(new Ipv4Address("0.0.0.0")).build()));
-        addAuthenticationKey(builder.build(), 0, "password");
+    public void initialize() {
+        mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
+        mapServer = new MapServer(mapService, smr, this, notificationService);
+        LOG.info("LISP (RFC6830) Mapping Service init finished");
     }
 
-    public String getHelp() {
-        StringBuffer help = new StringBuffer();
-        help.append("---LISP Mapping Service---\n");
-        help.append("\t dumpAll        - Dump all current EID -> RLOC mapping\n");
-        help.append("\t removeEid      - Remove a single LispIPv4Address Eid\n");
-        help.append("\t setShouldOverwritingRloc(true/false)      - set the map server's behaivior regarding existing RLOCs\n");
-        return help.toString();
+    public void basicInit() {
+        mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
+        mapServer = new MapServer(mapService, smr, this, notificationService);
     }
 
     public MapReply handleMapRequest(MapRequest request) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("DAO: Retrieving mapping for {}",
+                    LispAddressStringifier.getString(request.getEidItem().get(0).getEid()));
+        }
+
         tlsMapReply.set(null);
         tlsMapRequest.set(null);
-        mapResolver.handleMapRequest(request, this);
-        // After this invocation we assume that the thread local is filled with
-        // the reply
+        mapResolver.handleMapRequest(request);
+        // After this invocation we assume that the thread local is filled with the reply
         if (tlsMapRequest.get() != null) {
-            getLispSB().handleMapRequest(tlsMapRequest.get().getLeft(), tlsMapRequest.get().getRight());
+            SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
+            smrib.setMapRequest(new MapRequestBuilder(tlsMapRequest.get().getLeft()).build());
+            smrib.setTransportAddress(tlsMapRequest.get().getRight());
+            getLispSB().sendMapRequest(smrib.build());
             return null;
         } else {
             return tlsMapReply.get();
         }
-
     }
 
-    public MapNotify handleMapRegister(MapRegister mapRegister) {
+    public Pair<MapNotify, List<TransportAddress>> handleMapRegister(MapRegister mapRegister) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("DAO: Adding mapping for {}",
+                    LispAddressStringifier.getString(mapRegister.getMappingRecordItem().get(0)
+                            .getMappingRecord().getEid()));
+        }
+
         tlsMapNotify.set(null);
-        mapServer.handleMapRegister(mapRegister, this);
-        // After this invocation we assume that the thread local is filled with
-        // the reply
+        mapServer.handleMapRegister(mapRegister);
+        // After this invocation we assume that the thread local is filled with the reply
         return tlsMapNotify.get();
     }
 
-    public String getAuthenticationKey(LispAddressContainer address, int maskLen) {
-        return mapServer.getAuthenticationKey(address, maskLen);
-    }
-
-    public boolean removeAuthenticationKey(LispAddressContainer address, int maskLen) {
-        return mapServer.removeAuthenticationKey(address, maskLen);
+    public void setShouldAuthenticate(boolean shouldAuthenticate) {
+        this.mapResolver.setShouldAuthenticate(shouldAuthenticate);
     }
 
-    public boolean addAuthenticationKey(LispAddressContainer address, int maskLen, String key) {
-        return mapServer.addAuthenticationKey(address, maskLen, key);
+    private void sendMapNotify(MapNotify mapNotify, TransportAddress address) {
+        SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
+        smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
+        smnib.setTransportAddress(address);
+        getLispSB().sendMapNotify(smnib.build());
     }
 
-    public boolean shouldIterateMask() {
-        return this.shouldIterateMask;
+    @Override
+    public void onAddMapping(AddMapping mapRegisterNotification) {
+        Pair<MapNotify, List<TransportAddress>> result = handleMapRegister(mapRegisterNotification.getMapRegister());
+        if (result != null && result.getLeft() != null) {
+            MapNotify mapNotify = result.getLeft();
+            List<TransportAddress> rlocs = result.getRight();
+            if (rlocs == null) {
+                TransportAddressBuilder tab = new TransportAddressBuilder();
+                tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
+                tab.setPort(new PortNumber(LispMessage.PORT_NUM));
+                sendMapNotify(mapNotify, tab.build());
+            } else {
+                for (TransportAddress ta : rlocs) {
+                    sendMapNotify(mapNotify, ta);
+                }
+            }
+        } else {
+            LOG.debug("Not sending Map-Notify");
+        }
     }
 
-    public void setShouldIterateMask(boolean shouldIterateMask) {
-        this.shouldIterateMask = shouldIterateMask;
-        this.mapResolver.setShouldIterateMask(shouldIterateMask);
-        this.mapServer.setShouldIterateMask(shouldIterateMask);
+    @Override
+    public void onRequestMapping(RequestMapping mapRequestNotification) {
+        MapReply mapReply = handleMapRequest(mapRequestNotification.getMapRequest());
+        if (mapReply != null) {
+            SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder();
+            smrib.setMapReply((new MapReplyBuilder(mapReply).build()));
+            smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
+            getLispSB().sendMapReply(smrib.build());
+        } else {
+            LOG.debug("handleMapRequest: Got null MapReply");
+        }
     }
 
-    public void setShouldAuthenticate(boolean shouldAuthenticate) {
-        this.shouldAuthenticate = shouldAuthenticate;
-        this.mapResolver.setShouldAuthenticate(shouldAuthenticate);
-        this.mapServer.setShouldAuthenticate(shouldAuthenticate);
+    @Override
+    public void onGotMapReply(GotMapReply notification) {
+        LOG.debug("Received GotMapReply notification, ignoring");
     }
 
-    public boolean shouldAuthenticate() {
-        return shouldAuthenticate;
+    @Override
+    public void onGotMapNotify(GotMapNotify notification) {
+        LOG.debug("Received GotMapNotify notification, ignoring");
     }
 
-    public void onSessionInitialized(ConsumerContext session) {
-        logger.info("Lisp Consumer session initialized!");
-        NotificationService notificationService = session.getSALService(NotificationService.class);
-        notificationService.registerNotificationListener(AddMapping.class, new MapRegisterNotificationHandler());
-        notificationService.registerNotificationListener(RequestMapping.class, new MapRequestNotificationHandler());
-        this.session = session;
+    @Override
+    public void onXtrRequestMapping(XtrRequestMapping notification) {
+        LOG.debug("Received XtrRequestMapping notification, ignoring");
     }
 
-    private class MapRegisterNotificationHandler implements NotificationListener<AddMapping> {
-
-        @Override
-        public void onNotification(AddMapping mapRegisterNotification) {
-            MapNotify mapNotify = handleMapRegister(mapRegisterNotification.getMapRegister());
-            getLispSB().handleMapNotify(mapNotify,
-                    LispNotificationHelper.getInetAddressFromIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress()));
-
-        }
+    @Override
+    public void onXtrReplyMapping(XtrReplyMapping notification) {
+        LOG.debug("Received XtrReplyMapping notification, ignoring");
     }
 
-    private class MapRequestNotificationHandler implements NotificationListener<RequestMapping> {
-
-        @Override
-        public void onNotification(RequestMapping mapRequestNotification) {
-            MapReply mapReply = handleMapRequest(mapRequestNotification.getMapRequest());
-            getLispSB().handleMapReply(mapReply,
-                    LispNotificationHelper.getInetAddressFromIpAddress(mapRequestNotification.getTransportAddress().getIpAddress()));
+    @Override
+    public void onMappingKeepAlive(MappingKeepAlive notification) {
+        final MapRegisterCacheMetadata cacheMetadata = notification.getMapRegisterCacheMetadata();
+        for (EidLispAddress eidLispAddress : cacheMetadata.getEidLispAddress()) {
+            final Eid eid = eidLispAddress.getEid();
+            final Long timestamp = cacheMetadata.getTimestamp();
+            LOG.debug("Update map registration for eid {} with timestamp {}", LispAddressStringifier.getString(eid),
+                    timestamp);
+            mapService.updateMappingRegistration(MappingOrigin.Southbound, eid, timestamp);
         }
-
     }
 
-    private ILispSouthboundPlugin getLispSB() {
-        if (lispSB == null) {
-            lispSB = session.getRpcService(ILispSouthboundPlugin.class);
-        }
+    private OdlLispSbService getLispSB() {
         return lispSB;
     }
 
+    @Override
     public void handleMapReply(MapReply reply) {
         tlsMapReply.set(reply);
     }
 
-    public void handleMapNotify(MapNotify notify) {
-        tlsMapNotify.set(notify);
+    @Override
+    public void handleMapNotify(MapNotify notify, List<TransportAddress> rlocs) {
+        tlsMapNotify.set(new MutablePair<MapNotify, List<TransportAddress>>(notify, rlocs));
     }
 
     @Override
-    public void handleNonProxyMapRequest(MapRequest mapRequest, InetAddress targetAddress) {
-        tlsMapRequest.set(new MutablePair<MapRequest, InetAddress>(mapRequest, targetAddress));
+    public void handleSMR(MapRequest smr, Rloc subscriber) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Sending SMR to {} with Source-EID {} and EID Record {}",
+                    LispAddressStringifier.getString(subscriber),
+                    LispAddressStringifier.getString(smr.getSourceEid().getEid()),
+                    LispAddressStringifier.getString(smr.getEidItem().get(0).getEid()));
+        }
+        SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
+        smrib.setMapRequest(new MapRequestBuilder(smr).build());
+        smrib.setTransportAddress(LispNotificationHelper.getTransportAddressFromRloc(subscriber));
+        getLispSB().sendMapRequest(smrib.build());
+
     }
 
     @Override
-    public void clean() {
-        lispDao.clearAll();
+    public void handleNonProxyMapRequest(MapRequest mapRequest, TransportAddress transportAddress) {
+        tlsMapRequest.set(new MutablePair<MapRequest, TransportAddress>(mapRequest, transportAddress));
     }
 
-    @Override
-    public boolean shouldOverwrite() {
-        return mapServer.shouldOverwrite();
+    public void destroy() {
+        LOG.info("LISP (RFC6830) Mapping Service is destroyed!");
+        mapResolver = null;
+        mapServer = null;
     }
 
     @Override
-    public void setOverwrite(boolean overwrite) {
-        mapServer.setOverwrite(overwrite);
+    public void close() throws Exception {
+        destroy();
     }
-
 }