2 * Copyright (c) 2014, 2017 Contextream, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.lispflowmapping.implementation.lisp;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.Maps;
13 import com.google.common.collect.Sets;
14 import com.google.common.util.concurrent.ThreadFactoryBuilder;
15 import java.net.InetAddress;
16 import java.net.NetworkInterface;
17 import java.net.SocketException;
18 import java.util.ArrayList;
19 import java.util.Arrays;
20 import java.util.Enumeration;
21 import java.util.HashSet;
22 import java.util.Iterator;
23 import java.util.List;
25 import java.util.Objects;
27 import java.util.concurrent.Executors;
28 import java.util.concurrent.ScheduledExecutorService;
29 import java.util.concurrent.ScheduledFuture;
30 import java.util.concurrent.ThreadFactory;
31 import java.util.concurrent.TimeUnit;
32 import org.apache.commons.lang3.BooleanUtils;
33 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
34 import org.opendaylight.lispflowmapping.config.ConfigIni;
35 import org.opendaylight.lispflowmapping.implementation.util.LoggingUtil;
36 import org.opendaylight.lispflowmapping.implementation.util.MSNotificationInputUtil;
37 import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
38 import org.opendaylight.lispflowmapping.interfaces.dao.Subscriber;
39 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
40 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
41 import org.opendaylight.lispflowmapping.interfaces.lisp.ISmrNotificationListener;
42 import org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent;
43 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
44 import org.opendaylight.lispflowmapping.lisp.authentication.LispAuthenticationUtil;
45 import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
46 import org.opendaylight.lispflowmapping.lisp.type.MappingData;
47 import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
48 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
49 import org.opendaylight.lispflowmapping.lisp.util.MapNotifyBuilderHelper;
50 import org.opendaylight.lispflowmapping.lisp.util.MapRequestUtil;
51 import org.opendaylight.lispflowmapping.lisp.util.MappingRecordUtil;
52 import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
53 import org.opendaylight.lispflowmapping.lisp.util.SourceDestKeyHelper;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinaryBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceListener;
79 import org.opendaylight.yangtools.concepts.ListenerRegistration;
80 import org.slf4j.Logger;
81 import org.slf4j.LoggerFactory;
83 public class MapServer implements IMapServerAsync, OdlMappingserviceListener, ISmrNotificationListener {
85 private static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
86 private static final byte[] ALL_ZEROES_XTR_ID = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
87 private IMappingService mapService;
88 private boolean subscriptionService;
89 private IMapNotifyHandler notifyHandler;
90 private NotificationService notificationService;
91 private ListenerRegistration<MapServer> mapServerListenerRegistration;
92 private SmrScheduler scheduler;
94 public MapServer(IMappingService mapService, boolean subscriptionService,
95 IMapNotifyHandler notifyHandler, NotificationService notificationService) {
96 Preconditions.checkNotNull(mapService);
97 this.mapService = mapService;
98 this.subscriptionService = subscriptionService;
99 this.notifyHandler = notifyHandler;
100 this.notificationService = notificationService;
101 if (notificationService != null) {
102 notificationService.registerNotificationListener(this);
104 scheduler = new SmrScheduler();
108 public void setSubscriptionService(boolean subscriptionService) {
109 this.subscriptionService = subscriptionService;
112 @SuppressWarnings("unchecked")
113 public void handleMapRegister(MapRegister mapRegister) {
114 boolean mappingUpdated = false;
115 boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
116 Set<Subscriber> subscribers = Sets.newConcurrentHashSet();
117 MappingRecord oldMapping;
120 if (!mapRegister.isXtrSiteIdPresent() || mapRegister.getXtrId() == null) {
121 LOG.error("Merge bit is set in Map-Register, but xTR-ID is not present. Will not merge.");
123 } else if (Arrays.equals(mapRegister.getXtrId().getValue(), ALL_ZEROES_XTR_ID)) {
124 LOG.warn("Merge bit is set in Map-Register, but xTR-ID is all zeroes.");
128 for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
129 MappingRecord mapping = record.getMappingRecord();
130 Eid eid = mapping.getEid();
131 MappingData mappingData = new MappingData(mapping, System.currentTimeMillis());
132 mappingData.setMergeEnabled(merge);
133 mappingData.setXtrId(mapRegister.getXtrId());
135 oldMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
136 mapService.addMapping(MappingOrigin.Southbound, eid, getSiteId(mapRegister), mappingData);
137 if (oldMapping != null
138 && MappingRecordUtil.isNegativeMapping(oldMapping)
139 && !oldMapping.getEid().equals(eid)) {
140 if (subscriptionService) {
141 // Here we save the subscribers of the OLD mapping before removing. We will add to this set the
142 // subscribers of the NEW mapping below (since the EIDs are different, the result of
143 // mappingChanged() will be true, and then send an SMR to all subscribers with the EID of the NEW
145 Set<Subscriber> oldMappingSubscribers = mapService.getSubscribers(oldMapping.getEid());
146 if (oldMappingSubscribers != null) {
147 subscribers.addAll(oldMappingSubscribers);
148 LoggingUtil.logSubscribers(LOG, oldMapping.getEid(), subscribers);
151 mapService.removeMapping(MappingOrigin.Southbound, oldMapping.getEid());
154 if (subscriptionService) {
155 MappingRecord newMapping = merge
156 ? getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid)) : mapping;
158 if (mappingChanged(oldMapping, newMapping)) {
159 if (LOG.isDebugEnabled()) {
160 LOG.debug("Mapping update occured for {} SMRs will be sent for its subscribers.",
161 LispAddressStringifier.getString(eid));
163 Set<Subscriber> newMappingSubscribers = mapService.getSubscribers(eid);
164 if (oldMapping != null && !oldMapping.getEid().equals(eid)) {
165 newMappingSubscribers = addParentSubscribers(eid, newMappingSubscribers);
167 if (newMappingSubscribers != null) {
168 subscribers.addAll(newMappingSubscribers);
169 LoggingUtil.logSubscribers(LOG, eid, subscribers);
171 handleSmr(eid, subscribers);
172 mappingUpdated = true;
176 if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
177 LOG.trace("MapRegister wants MapNotify");
178 MapNotifyBuilder builder = new MapNotifyBuilder();
179 List<TransportAddress> rlocs = null;
181 Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
182 List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
183 for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
184 MappingRecord mapping = record.getMappingRecord();
185 MappingRecord currentRecord = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound,
187 mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
188 Set<IpAddressBinary> sourceRlocs = (Set<IpAddressBinary>) mapService.getData(
189 MappingOrigin.Southbound, mapping.getEid(), SubKeys.SRC_RLOCS);
190 if (sourceRlocs != null) {
191 notifyRlocs.addAll(sourceRlocs);
194 MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mergedMappings);
195 // send map-notify to merge group only when mapping record is changed
196 if (mappingUpdated) {
197 rlocs = getTransportAddresses(notifyRlocs);
200 MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
202 List<MappingRecordItem> mappings = builder.getMappingRecordItem();
203 if (mappings != null && mappings.get(0) != null && mappings.get(0).getMappingRecord() != null
204 && mappings.get(0).getMappingRecord().getEid() != null) {
205 MappingAuthkey authkey = mapService.getAuthenticationKey(mappings.get(0).getMappingRecord().getEid());
206 if (authkey != null) {
207 builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(),
208 authkey.getKeyString()));
211 notifyHandler.handleMapNotify(builder.build(), rlocs);
215 private static List<TransportAddress> getTransportAddresses(Set<IpAddressBinary> addresses) {
216 List<TransportAddress> rlocs = new ArrayList<TransportAddress>();
217 for (IpAddressBinary address : addresses) {
218 TransportAddressBuilder tab = new TransportAddressBuilder();
219 tab.setIpAddress(address);
220 tab.setPort(new PortNumber(LispMessage.PORT_NUM));
221 rlocs.add(tab.build());
226 private static SiteId getSiteId(MapRegister mapRegister) {
227 return (mapRegister.getSiteId() != null) ? new SiteId(mapRegister.getSiteId()) : null;
230 private static MappingRecord getMappingRecord(MappingData mappingData) {
231 return (mappingData != null) ? mappingData.getRecord() : null;
235 public void onMappingChanged(MappingChanged notification) {
236 LOG.trace("MappingChanged event of type: `{}'", notification.getChangeType());
237 if (subscriptionService) {
238 Eid eid = notification.getMappingRecord().getEid();
239 Set<Subscriber> subscribers = MSNotificationInputUtil.toSubscriberSet(notification.getSubscriberItem());
240 LoggingUtil.logSubscribers(LOG, eid, subscribers);
241 if (mapService.isMaster()) {
242 sendSmrs(eid, subscribers);
243 if (eid.getAddress() instanceof SourceDestKey) {
244 Set<Subscriber> dstSubscribers = MSNotificationInputUtil.toSubscriberSetFromDst(
245 notification.getDstSubscriberItem());
246 LoggingUtil.logSubscribers(LOG, SourceDestKeyHelper.getDstBinary(eid), dstSubscribers);
247 sendSmrs(SourceDestKeyHelper.getDstBinary(eid), dstSubscribers);
253 private static boolean mappingChanged(MappingRecord oldMapping, MappingRecord newMapping) {
254 // We only check for fields we care about
255 // XXX: This code needs to be checked and updated when the YANG model for MappingRecord is modified
256 Preconditions.checkNotNull(newMapping, "The new mapping should never be null");
257 if (oldMapping == null) {
258 LOG.trace("mappingChanged(): old mapping is null");
260 } else if (!Objects.equals(oldMapping.getEid(), newMapping.getEid())) {
261 LOG.trace("mappingChanged(): EID");
263 } else if (!Objects.equals(oldMapping.getLocatorRecord(), newMapping.getLocatorRecord())) {
264 LOG.trace("mappingChanged(): RLOC");
266 } else if (!Objects.equals(oldMapping.getAction(), newMapping.getAction())) {
267 LOG.trace("mappingChanged(): action");
269 } else if (!Objects.equals(oldMapping.getRecordTtl(), newMapping.getRecordTtl())) {
270 LOG.trace("mappingChanged(): TTL");
272 } else if (!Objects.equals(oldMapping.getMapVersion(), newMapping.getMapVersion())) {
273 LOG.trace("mappingChanged(): mapping version");
279 private void handleSmr(Eid eid, Set<Subscriber> subscribers) {
280 sendSmrs(eid, subscribers);
282 // For SrcDst LCAF also send SMRs to Dst prefix
283 if (eid.getAddress() instanceof SourceDestKey) {
284 Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
285 Set<Subscriber> dstSubs = mapService.getSubscribers(dstAddr);
286 sendSmrs(dstAddr, dstSubs);
290 private void sendSmrs(Eid eid, Set<Subscriber> subscribers) {
291 if (subscribers == null) {
294 final MapRequestBuilder mrb = MapRequestUtil.prepareSMR(eid, LispAddressUtil.toRloc(getLocalAddress()));
295 LOG.trace("Built SMR packet: " + mrb.build().toString());
297 scheduler.scheduleSmrs(mrb, subscribers.iterator());
300 private Set<Subscriber> addParentSubscribers(Eid eid, Set<Subscriber> subscribers) {
301 Eid parentPrefix = mapService.getParentPrefix(eid);
302 if (parentPrefix == null) {
306 Set<Subscriber> parentSubscribers = mapService.getSubscribers(parentPrefix);
307 if (parentSubscribers != null) {
308 if (subscribers != null) {
309 subscribers.addAll(parentSubscribers);
311 subscribers = parentSubscribers;
317 private static InetAddress getLocalAddress() {
319 Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
320 while (interfaces.hasMoreElements()) {
321 NetworkInterface current = interfaces.nextElement();
322 LOG.trace("Interface " + current.toString());
323 if (!current.isUp() || current.isLoopback() || current.isVirtual()) {
326 Enumeration<InetAddress> addresses = current.getInetAddresses();
327 while (addresses.hasMoreElements()) {
328 InetAddress currentAddr = addresses.nextElement();
329 // Skip loopback and link local addresses
330 if (currentAddr.isLoopbackAddress() || currentAddr.isLinkLocalAddress()) {
333 LOG.debug(currentAddr.getHostAddress());
337 } catch (SocketException se) {
338 LOG.debug("Caught socket exception", se);
344 public void onSmrInvokedReceived(SmrEvent event) {
345 scheduler.smrReceived(event);
349 * Task scheduler is responsible for resending SMR messages to a subscriber (xTR)
350 * {@value ConfigIni#LISP_SMR_RETRY_COUNT} times, or until {@link ISmrNotificationListener#onSmrInvokedReceived}
353 private class SmrScheduler {
354 final int cpuCores = Runtime.getRuntime().availableProcessors();
355 private final ThreadFactory threadFactory = new ThreadFactoryBuilder()
356 .setNameFormat("smr-executor-%d").build();
357 private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(cpuCores * 2, threadFactory);
358 private final Map<Eid, Map<Subscriber, ScheduledFuture<?>>> eidFutureMap = Maps.newConcurrentMap();
360 void scheduleSmrs(MapRequestBuilder mrb, Iterator<Subscriber> subscribers) {
361 final Eid srcEid = fixSrcEidMask(mrb.getSourceEid().getEid());
362 cancelExistingFuturesForEid(srcEid);
364 final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = Maps.newConcurrentMap();
366 // Using Iterator ensures that we don't get a ConcurrentModificationException when removing a Subscriber
368 while (subscribers.hasNext()) {
369 Subscriber subscriber = subscribers.next();
370 if (subscriber.timedOut()) {
371 LOG.debug("Lazy removing expired subscriber entry " + subscriber.getString());
372 subscribers.remove();
374 final ScheduledFuture<?> future = executor.scheduleAtFixedRate(new CancellableRunnable(
375 mrb, subscriber), 0L, ConfigIni.getInstance().getSmrTimeout(), TimeUnit.MILLISECONDS);
376 subscriberFutureMap.put(subscriber, future);
380 if (subscriberFutureMap.isEmpty()) {
383 eidFutureMap.put(srcEid, subscriberFutureMap);
386 void smrReceived(SmrEvent event) {
387 final List<Subscriber> subscriberList = event.getSubscriberList();
388 for (Subscriber subscriber : subscriberList) {
389 if (LOG.isTraceEnabled()) {
390 LOG.trace("SMR-invoked event, EID {}, subscriber {}",
391 LispAddressStringifier.getString(event.getEid()),
392 subscriber.getString());
393 LOG.trace("eidFutureMap: {}", eidFutureMap);
395 final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = eidFutureMap.get(event.getEid());
396 if (subscriberFutureMap != null) {
397 final ScheduledFuture<?> future = subscriberFutureMap.get(subscriber);
398 if (future != null && !future.isCancelled()) {
400 if (LOG.isDebugEnabled()) {
401 LOG.debug("SMR-invoked MapRequest received, scheduled task for subscriber {}, EID {} with"
402 + " nonce {} has been cancelled", subscriber.getString(),
403 LispAddressStringifier.getString(event.getEid()), event.getNonce());
405 subscriberFutureMap.remove(subscriber);
407 if (future == null) {
408 LOG.trace("No outstanding SMR tasks for EID {}, subscriber {}",
409 LispAddressStringifier.getString(event.getEid()), subscriber.getString());
411 LOG.trace("Future {} is cancelled", future);
414 if (subscriberFutureMap.isEmpty()) {
415 eidFutureMap.remove(event.getEid());
418 if (LOG.isTraceEnabled()) {
419 LOG.trace("No outstanding SMR tasks for EID {}",
420 LispAddressStringifier.getString(event.getEid()));
426 private void cancelExistingFuturesForEid(Eid eid) {
427 synchronized (eidFutureMap) {
428 if (eidFutureMap.containsKey(eid)) {
429 final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = eidFutureMap.get(eid);
430 Iterator<Subscriber> oldSubscribers = subscriberFutureMap.keySet().iterator();
431 while (oldSubscribers.hasNext()) {
432 Subscriber subscriber = oldSubscribers.next();
433 ScheduledFuture<?> subscriberFuture = subscriberFutureMap.get(subscriber);
434 subscriberFuture.cancel(true);
436 eidFutureMap.remove(eid);
442 * See https://bugs.opendaylight.org/show_bug.cgi?id=8469#c1 why this is necessary.
444 * TL;DR The sourceEid field in the MapRequestBuilder object will be serialized to a packet on the wire, and
445 * a Map-Request can't store the prefix length in the source EID.
447 * Since we store all prefixes as binary internally, we only care about and fix those address types.
449 private Eid fixSrcEidMask(Eid eid) {
450 Address address = eid.getAddress();
451 if (address instanceof Ipv4PrefixBinary) {
452 return new EidBuilder(eid).setAddress(new Ipv4PrefixBinaryBuilder((Ipv4PrefixBinary) address)
453 .setIpv4MaskLength(MaskUtil.IPV4_MAX_MASK).build()).build();
454 } else if (address instanceof Ipv6PrefixBinary) {
455 return new EidBuilder(eid).setAddress(new Ipv6PrefixBinaryBuilder((Ipv6PrefixBinary) address)
456 .setIpv6MaskLength(MaskUtil.IPV6_MAX_MASK).build()).build();
461 private final class CancellableRunnable implements Runnable {
462 private MapRequestBuilder mrb;
463 private Subscriber subscriber;
464 private int executionCount = 1;
466 CancellableRunnable(MapRequestBuilder mrb, Subscriber subscriber) {
468 this.subscriber = subscriber;
471 @SuppressWarnings("checkstyle:IllegalCatch")
474 final Eid srcEid = mrb.getSourceEid().getEid();
477 // The address stored in the SMR's EID record is used as Source EID in the SMR-invoked
478 // Map-Request. To ensure consistent behavior it is set to the value used to originally request
480 if (executionCount <= ConfigIni.getInstance().getSmrRetryCount()) {
482 mrb.setEidItem(new ArrayList<EidItem>());
483 mrb.getEidItem().add(new EidItemBuilder().setEid(subscriber.getSrcEid()).build());
484 notifyHandler.handleSMR(mrb.build(), subscriber.getSrcRloc());
485 if (LOG.isTraceEnabled()) {
486 LOG.trace("Attempt #{} to send SMR to subscriber {} for EID {}",
488 subscriber.getString(),
489 LispAddressStringifier.getString(mrb.getSourceEid().getEid()));
493 LOG.trace("Cancelling execution of a SMR Map-Request after {} failed attempts.",
495 cancelAndRemove(subscriber, srcEid);
498 } catch (Exception e) {
499 LOG.error("Errors encountered while handling SMR:", e);
500 cancelAndRemove(subscriber, srcEid);
506 private void cancelAndRemove(Subscriber sub, Eid eid) {
507 final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = eidFutureMap.get(eid);
508 if (subscriberFutureMap == null) {
509 LOG.warn("Couldn't find subscriber {} in SMR scheduler internal list", sub);
513 if (subscriberFutureMap.containsKey(sub)) {
514 ScheduledFuture<?> eidFuture = subscriberFutureMap.get(sub);
515 subscriberFutureMap.remove(sub);
516 eidFuture.cancel(false);
518 if (subscriberFutureMap.isEmpty()) {
519 eidFutureMap.remove(eid);