From: Giovanni Meo Date: Thu, 26 Sep 2013 15:58:12 +0000 (+0200) Subject: Make FRM cleanup only local entries X-Git-Tag: releasepom-0.1.0~9^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=29ce42d7a6d86b5add5b54ccfdedce62afc4f812 Make FRM cleanup only local entries - FRM when shutting down should only clean local entries and avoid to trigger remote deletion because that cleanup will also be initiated on the remote controller - On shutdown make sure to wake up who may still be sleeping Change-Id: I15346f73a761c71014c02762e44ccdae8e95edef Signed-off-by: Giovanni Meo --- diff --git a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/FlowEntryDistributionOrderFutureTask.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/FlowEntryDistributionOrderFutureTask.java index 0c105bae1e..b8c2d1db55 100644 --- a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/FlowEntryDistributionOrderFutureTask.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/FlowEntryDistributionOrderFutureTask.java @@ -65,6 +65,12 @@ final class FlowEntryDistributionOrderFutureTask implements Future { @Override public boolean cancel(boolean mayInterruptIfRunning) { + if (this.waitingLatch.getCount() != 0L) { + this.retStatus = new Status(StatusCode.GONE); + this.waitingLatch.countDown(); + logger.trace("Cancelled the workOrder"); + return true; + } return false; } diff --git a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java index 3c936de769..3ee407de02 100644 --- a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java @@ -1876,7 +1876,9 @@ public class ForwardingRulesManager implements * If requested, a copy of each original flow entry will be stored in the * inactive list so that it can be re-applied when needed (This is typically * the case when running in the default container and controller moved to - * container mode) + * container mode) NOTE WELL: The routine as long as does a bulk change will + * operate only on the entries for nodes locally attached so to avoid + * redundant operations initiated by multiple nodes * * @param preserveFlowEntries * if true, a copy of each original entry is stored in the @@ -1902,9 +1904,15 @@ public class ForwardingRulesManager implements // Now remove the entries for (FlowEntryInstall flowEntryHw : toRemove) { - Status status = this.removeEntryInternal(flowEntryHw, false); - if (!status.isSuccess()) { - log.warn("Failed to remove entry: {}. The failure is: {}", flowEntryHw, status.getDescription()); + Node n = flowEntryHw.getNode(); + if (n != null && connectionManager.getLocalityStatus(n) == ConnectionLocality.LOCAL) { + Status status = this.removeEntryInternal(flowEntryHw, false); + if (!status.isSuccess()) { + log.warn("Failed to remove entry: {}. The failure is: {}", flowEntryHw, status.getDescription()); + } + } else { + log.debug("Not removing entry {} because not connected locally, the remote guy will do it's job", + flowEntryHw); } } } @@ -2641,6 +2649,12 @@ public class ForwardingRulesManager implements uninstallAllFlowEntries(false); // Shutdown executor this.executor.shutdownNow(); + // Now walk all the workMonitor and wake up the one sleeping because + // destruction is happening + for (FlowEntryDistributionOrder fe : workMonitor.keySet()) { + FlowEntryDistributionOrderFutureTask task = workMonitor.get(fe); + task.cancel(true); + } } public void setFlowProgrammerService(IFlowProgrammerService service) {