DistributedFlowRuleStore: handle no master present case
Change-Id: I56f4bce549aecc689d7a4798485b025a87ecdeb9
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
index 1961c8c..4458330 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
@@ -519,7 +519,8 @@
@Override
public FlowRuleEvent removeFlowRule(FlowEntry rule) {
- ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(rule.deviceId());
+ final DeviceId deviceId = rule.deviceId();
+ ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId);
final NodeId localId = clusterService.getLocalNode().id();
if (localId.equals(replicaInfo.master().orNull())) {
@@ -527,8 +528,14 @@
return removeFlowRuleInternal(rule);
}
+ if (!replicaInfo.master().isPresent()) {
+ log.warn("No master for {}", deviceId);
+ // TODO: revisit if this should be null (="no-op") or Exception
+ return null;
+ }
+
log.trace("Forwarding removeFlowRule to {}, which is the primary (master) for device {}",
- replicaInfo.master().orNull(), rule.deviceId());
+ replicaInfo.master().orNull(), deviceId);
ClusterMessage message = new ClusterMessage(
clusterService.getLocalNode().id(),