commit | cd4276521ca0a7268353317ede37de33cdbe4c52 | [log] [tgz] |
---|---|---|
author | Jordan Halterman <jordan@opennetworking.org> | Fri Oct 05 13:28:51 2018 -0700 |
committer | Charles Chan <charles@opennetworking.org> | Tue Oct 09 17:24:28 2018 +0000 |
tree | fd7128e655db17de2deea24102c46b74a44e0158 | |
parent | 3315384b95838cd95da554bc206e2b5cae01d917 [diff] |
Avoid closing DeviceFlowTable when flows are purged on device down event Change-Id: Ibb0fd99dda6dff1fdcbf73ec0a0f3e1db8bcf625
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DeviceFlowTable.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DeviceFlowTable.java index ec2532b..4edd2f3 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DeviceFlowTable.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DeviceFlowTable.java
@@ -831,6 +831,16 @@ } /** + * Purges the flow table. + */ + public void purge() { + flowTasks.clear(); + flowBuckets.values().forEach(bucket -> bucket.purge()); + lastBackupTimes.clear(); + inFlightUpdates.clear(); + } + + /** * Closes the device flow table. */ public void close() {
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java index 90c503b..4502016 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java
@@ -822,9 +822,18 @@ * @param deviceId the device for which to purge flow rules */ public void purgeFlowRule(DeviceId deviceId) { - DeviceFlowTable flowTable = flowTables.remove(deviceId); - if (flowTable != null) { - flowTable.close(); + // If the device is still present in the store, purge the underlying DeviceFlowTable. + // Otherwise, remove the DeviceFlowTable and unregister message handlers. + if (deviceService.getDevice(deviceId) != null) { + DeviceFlowTable flowTable = flowTables.get(deviceId); + if (flowTable != null) { + flowTable.purge(); + } + } else { + DeviceFlowTable flowTable = flowTables.remove(deviceId); + if (flowTable != null) { + flowTable.close(); + } } }
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/FlowBucket.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/FlowBucket.java index 34d470c..ea1887d 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/FlowBucket.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/FlowBucket.java
@@ -264,6 +264,13 @@ } /** + * Purges the bucket. + */ + public void purge() { + flowBucket.clear(); + } + + /** * Clears the bucket. */ public void clear() {