Committed by
Gerrit Code Review
some fixes to check for stale locks and active members
Change-Id: Ia3fc4ab8406dadcecc5d718e905a951f77a807cf
Showing
1 changed file
with
6 additions
and
5 deletions
... | @@ -15,8 +15,6 @@ import org.apache.felix.scr.annotations.Service; | ... | @@ -15,8 +15,6 @@ import org.apache.felix.scr.annotations.Service; |
15 | import org.apache.commons.lang3.mutable.MutableBoolean; | 15 | import org.apache.commons.lang3.mutable.MutableBoolean; |
16 | import org.onlab.util.KryoNamespace; | 16 | import org.onlab.util.KryoNamespace; |
17 | import org.onosproject.cluster.ClusterService; | 17 | import org.onosproject.cluster.ClusterService; |
18 | -import org.onosproject.cluster.ControllerNode; | ||
19 | -import org.onosproject.cluster.ControllerNode.State; | ||
20 | import org.onosproject.cluster.Leadership; | 18 | import org.onosproject.cluster.Leadership; |
21 | import org.onosproject.cluster.LeadershipEvent; | 19 | import org.onosproject.cluster.LeadershipEvent; |
22 | import org.onosproject.cluster.LeadershipEventListener; | 20 | import org.onosproject.cluster.LeadershipEventListener; |
... | @@ -51,6 +49,9 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -51,6 +49,9 @@ import static com.google.common.base.Preconditions.checkArgument; |
51 | import static org.onlab.util.Tools.groupedThreads; | 49 | import static org.onlab.util.Tools.groupedThreads; |
52 | import static org.slf4j.LoggerFactory.getLogger; | 50 | import static org.slf4j.LoggerFactory.getLogger; |
53 | 51 | ||
52 | +import static org.onosproject.cluster.ControllerNode.State.ACTIVE; | ||
53 | +import static org.onosproject.cluster.ControllerNode.State.INACTIVE; | ||
54 | + | ||
54 | /** | 55 | /** |
55 | * Distributed Lock Manager implemented on top of ConsistentMap. | 56 | * Distributed Lock Manager implemented on top of ConsistentMap. |
56 | * <p> | 57 | * <p> |
... | @@ -286,7 +287,7 @@ public class DistributedLeadershipManager implements LeadershipService { | ... | @@ -286,7 +287,7 @@ public class DistributedLeadershipManager implements LeadershipService { |
286 | Versioned<List<NodeId>> candidates = candidateMap.get(path); | 287 | Versioned<List<NodeId>> candidates = candidateMap.get(path); |
287 | if (candidates != null) { | 288 | if (candidates != null) { |
288 | List<NodeId> activeNodes = candidates.value().stream() | 289 | List<NodeId> activeNodes = candidates.value().stream() |
289 | - .filter(n -> clusterService.getState(n) == State.ACTIVE) | 290 | + .filter(n -> clusterService.getState(n) == ACTIVE) |
290 | .collect(Collectors.toList()); | 291 | .collect(Collectors.toList()); |
291 | if (localNodeId.equals(activeNodes.get(LEADER_CANDIDATE_POS))) { | 292 | if (localNodeId.equals(activeNodes.get(LEADER_CANDIDATE_POS))) { |
292 | leaderLockAttempt(path, candidates.value()); | 293 | leaderLockAttempt(path, candidates.value()); |
... | @@ -491,8 +492,8 @@ public class DistributedLeadershipManager implements LeadershipService { | ... | @@ -491,8 +492,8 @@ public class DistributedLeadershipManager implements LeadershipService { |
491 | try { | 492 | try { |
492 | leaderMap.entrySet() | 493 | leaderMap.entrySet() |
493 | .stream() | 494 | .stream() |
494 | - .filter(e -> clusterService.getState(e.getValue().value()) == ControllerNode.State.INACTIVE) | 495 | + .filter(e -> clusterService.getState(e.getValue().value()) == INACTIVE) |
495 | - .filter(e -> localNodeId.equals(e.getValue().value()) && !activeTopics.contains(e.getKey())) | 496 | + .filter(e -> activeTopics.contains(e.getKey())) |
496 | .forEach(entry -> { | 497 | .forEach(entry -> { |
497 | String path = entry.getKey(); | 498 | String path = entry.getKey(); |
498 | NodeId nodeId = entry.getValue().value(); | 499 | NodeId nodeId = entry.getValue().value(); | ... | ... |
-
Please register or login to post a comment