Committed by
Charles Chan
Bugfix: store entry is not removed properly after device disconnected
Change-Id: I4c967a1d98208b5d3eee0e7b00dfd4ed2fddde01
Showing
2 changed files
with
18 additions
and
30 deletions
... | @@ -57,13 +57,11 @@ import org.onosproject.store.serializers.KryoNamespaces; | ... | @@ -57,13 +57,11 @@ import org.onosproject.store.serializers.KryoNamespaces; |
57 | import org.onosproject.store.service.ConsistentMap; | 57 | import org.onosproject.store.service.ConsistentMap; |
58 | import org.onosproject.store.service.Serializer; | 58 | import org.onosproject.store.service.Serializer; |
59 | import org.onosproject.store.service.StorageService; | 59 | import org.onosproject.store.service.StorageService; |
60 | -import org.onosproject.store.service.Versioned; | ||
61 | import org.slf4j.Logger; | 60 | import org.slf4j.Logger; |
62 | import org.slf4j.LoggerFactory; | 61 | import org.slf4j.LoggerFactory; |
63 | 62 | ||
64 | import java.util.Collection; | 63 | import java.util.Collection; |
65 | import java.util.Collections; | 64 | import java.util.Collections; |
66 | -import java.util.Iterator; | ||
67 | import java.util.List; | 65 | import java.util.List; |
68 | import java.util.Map; | 66 | import java.util.Map; |
69 | import java.util.Optional; | 67 | import java.util.Optional; |
... | @@ -518,27 +516,22 @@ public class McastHandler { | ... | @@ -518,27 +516,22 @@ public class McastHandler { |
518 | * @param deviceId device ID | 516 | * @param deviceId device ID |
519 | */ | 517 | */ |
520 | public void removeDevice(DeviceId deviceId) { | 518 | public void removeDevice(DeviceId deviceId) { |
521 | - Iterator<Map.Entry<McastStoreKey, Versioned<NextObjective>>> itNextObj = | 519 | + mcastNextObjStore.entrySet().stream() |
522 | - mcastNextObjStore.entrySet().iterator(); | 520 | + .filter(entry -> entry.getKey().deviceId().equals(deviceId)) |
523 | - while (itNextObj.hasNext()) { | 521 | + .forEach(entry -> { |
524 | - Map.Entry<McastStoreKey, Versioned<NextObjective>> entry = itNextObj.next(); | ||
525 | - if (entry.getKey().deviceId().equals(deviceId)) { | ||
526 | ConnectPoint source = getSource(entry.getKey().mcastIp()); | 522 | ConnectPoint source = getSource(entry.getKey().mcastIp()); |
527 | removeGroupFromDevice(entry.getKey().deviceId(), entry.getKey().mcastIp(), | 523 | removeGroupFromDevice(entry.getKey().deviceId(), entry.getKey().mcastIp(), |
528 | assignedVlan(deviceId.equals(source.deviceId()) ? source : null)); | 524 | assignedVlan(deviceId.equals(source.deviceId()) ? source : null)); |
529 | - itNextObj.remove(); | 525 | + mcastNextObjStore.remove(entry.getKey()); |
530 | - } | 526 | + }); |
531 | - } | 527 | + log.debug("{} is removed from mcastNextObjStore", deviceId); |
532 | - | ||
533 | - Iterator<Map.Entry<McastStoreKey, Versioned<McastRole>>> itRole = | ||
534 | - mcastRoleStore.entrySet().iterator(); | ||
535 | - while (itRole.hasNext()) { | ||
536 | - Map.Entry<McastStoreKey, Versioned<McastRole>> entry = itRole.next(); | ||
537 | - if (entry.getKey().deviceId().equals(deviceId)) { | ||
538 | - itRole.remove(); | ||
539 | - } | ||
540 | - } | ||
541 | 528 | ||
529 | + mcastRoleStore.entrySet().stream() | ||
530 | + .filter(entry -> entry.getKey().deviceId().equals(deviceId)) | ||
531 | + .forEach(entry -> { | ||
532 | + mcastRoleStore.remove(entry.getKey()); | ||
533 | + }); | ||
534 | + log.debug("{} is removed from mcastRoleStore", deviceId); | ||
542 | } | 535 | } |
543 | 536 | ||
544 | /** | 537 | /** | ... | ... |
... | @@ -44,12 +44,9 @@ import org.onosproject.store.serializers.KryoNamespaces; | ... | @@ -44,12 +44,9 @@ import org.onosproject.store.serializers.KryoNamespaces; |
44 | import org.onosproject.store.service.ConsistentMap; | 44 | import org.onosproject.store.service.ConsistentMap; |
45 | import org.onosproject.store.service.Serializer; | 45 | import org.onosproject.store.service.Serializer; |
46 | import org.onosproject.store.service.StorageService; | 46 | import org.onosproject.store.service.StorageService; |
47 | -import org.onosproject.store.service.Versioned; | ||
48 | import org.slf4j.Logger; | 47 | import org.slf4j.Logger; |
49 | import org.slf4j.LoggerFactory; | 48 | import org.slf4j.LoggerFactory; |
50 | 49 | ||
51 | -import java.util.Iterator; | ||
52 | -import java.util.Map; | ||
53 | import java.util.Set; | 50 | import java.util.Set; |
54 | import java.util.concurrent.CompletableFuture; | 51 | import java.util.concurrent.CompletableFuture; |
55 | import java.util.stream.Collectors; | 52 | import java.util.stream.Collectors; |
... | @@ -398,14 +395,12 @@ public class XConnectHandler { | ... | @@ -398,14 +395,12 @@ public class XConnectHandler { |
398 | * @param deviceId device ID | 395 | * @param deviceId device ID |
399 | */ | 396 | */ |
400 | protected void removeDevice(DeviceId deviceId) { | 397 | protected void removeDevice(DeviceId deviceId) { |
401 | - Iterator<Map.Entry<XConnectStoreKey, Versioned<NextObjective>>> itNextObj = | 398 | + xConnectNextObjStore.entrySet().stream() |
402 | - xConnectNextObjStore.entrySet().iterator(); | 399 | + .filter(entry -> entry.getKey().deviceId().equals(deviceId)) |
403 | - while (itNextObj.hasNext()) { | 400 | + .forEach(entry -> { |
404 | - Map.Entry<XConnectStoreKey, Versioned<NextObjective>> entry = itNextObj.next(); | 401 | + xConnectNextObjStore.remove(entry.getKey()); |
405 | - if (entry.getKey().deviceId().equals(deviceId)) { | 402 | + }); |
406 | - itNextObj.remove(); | 403 | + log.debug("{} is removed from xConnectNextObjStore", deviceId); |
407 | - } | ||
408 | - } | ||
409 | } | 404 | } |
410 | 405 | ||
411 | /** | 406 | /** | ... | ... |
-
Please register or login to post a comment