Committed by
Gerrit Code Review
DistributedFlowRuleStore: handle no master present case
Change-Id: I56f4bce549aecc689d7a4798485b025a87ecdeb9
Showing
1 changed file
with
9 additions
and
2 deletions
... | @@ -519,7 +519,8 @@ public class DistributedFlowRuleStore | ... | @@ -519,7 +519,8 @@ public class DistributedFlowRuleStore |
519 | 519 | ||
520 | @Override | 520 | @Override |
521 | public FlowRuleEvent removeFlowRule(FlowEntry rule) { | 521 | public FlowRuleEvent removeFlowRule(FlowEntry rule) { |
522 | - ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(rule.deviceId()); | 522 | + final DeviceId deviceId = rule.deviceId(); |
523 | + ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); | ||
523 | 524 | ||
524 | final NodeId localId = clusterService.getLocalNode().id(); | 525 | final NodeId localId = clusterService.getLocalNode().id(); |
525 | if (localId.equals(replicaInfo.master().orNull())) { | 526 | if (localId.equals(replicaInfo.master().orNull())) { |
... | @@ -527,8 +528,14 @@ public class DistributedFlowRuleStore | ... | @@ -527,8 +528,14 @@ public class DistributedFlowRuleStore |
527 | return removeFlowRuleInternal(rule); | 528 | return removeFlowRuleInternal(rule); |
528 | } | 529 | } |
529 | 530 | ||
531 | + if (!replicaInfo.master().isPresent()) { | ||
532 | + log.warn("No master for {}", deviceId); | ||
533 | + // TODO: revisit if this should be null (="no-op") or Exception | ||
534 | + return null; | ||
535 | + } | ||
536 | + | ||
530 | log.trace("Forwarding removeFlowRule to {}, which is the primary (master) for device {}", | 537 | log.trace("Forwarding removeFlowRule to {}, which is the primary (master) for device {}", |
531 | - replicaInfo.master().orNull(), rule.deviceId()); | 538 | + replicaInfo.master().orNull(), deviceId); |
532 | 539 | ||
533 | ClusterMessage message = new ClusterMessage( | 540 | ClusterMessage message = new ClusterMessage( |
534 | clusterService.getLocalNode().id(), | 541 | clusterService.getLocalNode().id(), | ... | ... |
-
Please register or login to post a comment