commit | da3b9f09807e4054835495b1d61b3956ef5c5cbd | [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:35 2018 +0000 |
tree | ecb2ac49b7898780c06d02bfdc94b944533ed9ab | |
parent | 14a6c506e4c6356228bd3c801fc38dc2e26e261d [diff] |
Avoid closing DeviceFlowTable when flows are purged on device down event Change-Id: Ibb0fd99dda6dff1fdcbf73ec0a0f3e1db8bcf625 (cherry picked from commit cd4276521ca0a7268353317ede37de33cdbe4c52)
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() {