Merge "Fix multi-host caching in visual topology"
authorGiovanni Meo <gmeo@cisco.com>
Fri, 20 Sep 2013 14:18:28 +0000 (14:18 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 20 Sep 2013 14:18:28 +0000 (14:18 +0000)
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/web/devices/src/main/resources/js/page.js
opendaylight/web/troubleshoot/src/main/resources/js/page.js

index 6e3e6b6633b0fc6098ee6795dac661df71a20fed..c839d15f10c81308909a03f804e5587ec6ef612c 100644 (file)
@@ -202,59 +202,6 @@ public class ForwardingRulesManager implements
     private ConcurrentMap<FlowEntryDistributionOrder, FlowEntryDistributionOrderFutureTask> workMonitor =
             new ConcurrentHashMap<FlowEntryDistributionOrder, FlowEntryDistributionOrderFutureTask>();
 
-    /*
-     * Create an executor pool to create the distributionOrder, this is a stop
-     * gap solution caused by an issue with non-transactional caches in the
-     * implementation we use, being currently worked on. It has been noticed in
-     * fact that when non-transactional caches are being used sometime the key
-     * are no distributed to all the nodes properly. To workaround the issue
-     * transactional caches are being used, but there was a reason for using
-     * non-transactional caches to start with, in fact we needed to be able in
-     * the context of a northbound transaction to program the FRM entries
-     * irrespective of the fact that transaction would commit or no else we
-     * would not be able to achieve the entry programming and implement the
-     * scheme for recovery from network element failures. Bottom line, now in
-     * order to make sure an update on a transactional cache goes out while in a
-     * transaction that need to be initiated by a different thread.
-     */
-    private ExecutorService executor;
-
-    class DistributeOrderCallable implements Callable<Future<Status>> {
-        private FlowEntryInstall e;
-        private FlowEntryInstall u;
-        private UpdateType t;
-        DistributeOrderCallable(FlowEntryInstall e, FlowEntryInstall u, UpdateType t) {
-            this.e = e;
-            this.u = u;
-            this.t = t;
-        }
-
-        @Override
-        public Future<Status> call() throws Exception {
-            if (e == null || t == null) {
-                logsync.error("Unexpected null Entry up update type");
-                return null;
-            }
-            // Create the work order and distribute it
-            FlowEntryDistributionOrder fe =
-                    new FlowEntryDistributionOrder(e, t, clusterContainerService.getMyAddress());
-            // First create the monitor job
-            FlowEntryDistributionOrderFutureTask ret = new FlowEntryDistributionOrderFutureTask(fe);
-            logsync.trace("Node {} not local so sending fe {}", e.getNode(), fe);
-            workMonitor.put(fe, ret);
-            if (t.equals(UpdateType.CHANGED)) {
-                // Then distribute the work
-                workOrder.put(fe, u);
-            } else {
-                // Then distribute the work
-                workOrder.put(fe, e);
-            }
-            logsync.trace("WorkOrder requested");
-            // Now create an Handle to monitor the execution of the operation
-            return ret;
-        }
-    }
-
     /**
      * @param e
      *            Entry being installed/updated/removed
@@ -275,21 +222,23 @@ public class ForwardingRulesManager implements
 
         Node n = e.getNode();
         if (connectionManager.getLocalityStatus(n) == ConnectionLocality.NOT_LOCAL) {
-            Callable<Future<Status>> worker = new DistributeOrderCallable(e, u, t);
-            if (worker != null) {
-                Future<Future<Status>> workerRes = this.executor.submit(worker);
-                try {
-                    return workerRes.get();
-                } catch (InterruptedException e1) {
-                    // we where interrupted, not a big deal.
-                    return null;
-                } catch (ExecutionException e1) {
-                    logsync.error(
-                            "We got an execution exception {} we cannot much, so returning we don't have nothing to wait for",
-                            e);
-                    return null;
-                }
+            // Create the work order and distribute it
+            FlowEntryDistributionOrder fe =
+                    new FlowEntryDistributionOrder(e, t, clusterContainerService.getMyAddress());
+            // First create the monitor job
+            FlowEntryDistributionOrderFutureTask ret = new FlowEntryDistributionOrderFutureTask(fe);
+            logsync.trace("Node {} not local so sending fe {}", n, fe);
+            workMonitor.put(fe, ret);
+            if (t.equals(UpdateType.CHANGED)) {
+                // Then distribute the work
+                workOrder.put(fe, u);
+            } else {
+                // Then distribute the work
+                workOrder.put(fe, e);
             }
+            logsync.trace("WorkOrder requested");
+            // Now create an Handle to monitor the execution of the operation
+            return ret;
         }
 
         logsync.trace("Node {} could be local. so processing Entry:{} UpdateType:{}", n, e, t);
@@ -1407,10 +1356,10 @@ public class ForwardingRulesManager implements
                     EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
 
             clusterContainerService.createCache(WORKSTATUSCACHE,
- EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+ EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
 
             clusterContainerService.createCache(WORKORDERCACHE,
- EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+ EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
 
         } catch (CacheConfigException cce) {
             log.error("CacheConfigException");
@@ -2112,6 +2061,7 @@ public class ForwardingRulesManager implements
      *      pratice to have in it's context operations that can take time,
      *      hence moving off to a different thread for async processing.
      */
+    private ExecutorService executor;
     @Override
     public void modeChangeNotify(final Node node, final boolean proactive) {
         Callable<Status> modeChangeCallable = new Callable<Status>() {
index 2488d06d0cae7745a4efc58c8d8a42ff1f565271..e6f75c2c3847d57b7c2b71f46ec5972550706f08 100644 (file)
@@ -1326,6 +1326,7 @@ one.f.switchmanager.spanPortConfig = {
             var $label = one.lib.form.label("Node");
             var $select = one.lib.form.select.create(nodes);
             one.lib.form.select.prepend($select, { '' : 'Please Select a Node' });
+            $select.val($select.find("option:first").val());
             $select.attr('id', one.f.switchmanager.spanPortConfig.id.modal.form.nodes);
             
             // bind onchange
index bcf911f0a5583a46bf14b5150ff20a01c1096bfc..a8b6860d10926cce6c925131948626ce573e6dad 100644 (file)
@@ -90,13 +90,10 @@ one.f.troubleshooting.existingNodes = {
             modal: "one_f_troubleshooting_existingNodes_id_modal",
             existingNodesDataGrid: "one_f_troubleshooting_existingNodes_id_datagrid",
             portsDataGrid: "one_f_troubleshooting_existingNodes_id_portsDataGrid",
-            flowsDataGrid: "one_f_troubleshooting_existingNodes_id_flowsDataGrid"
-        },
-        // TODO: Make these values configurable.
-        autoRefreshInterval: {
-            flows: 10000,
-            ports: 10000,
-            refreshRateInterval: 5000
+            flowsDataGrid: "one_f_troubleshooting_existingNodes_id_flowsDataGrid",
+            refreshFlowsButton:"one_f_troubleshooting_existingNodes_id_refreshFlowsButton",
+            refreshPortsButton:"one_f_troubleshooting_existingNodes_id_refreshPortsButton"
+
         },
         load: {
             main: function($dashlet) {
@@ -122,13 +119,18 @@ one.f.troubleshooting.existingNodes = {
                     if(one.f.troubleshooting === undefined){
                         return;
                     }
-                    clearTimeout(one.f.troubleshooting.existingNodes.registry.refreshTimer);
                     $.getJSON(one.main.constants.address.prefix + "/troubleshoot/flowStats?nodeId=" + nodeId, function(content) {
                         $rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
                         one.f.troubleshooting.rightBottomDashlet.setDashletHeader("Flows");
                         one.lib.dashlet.empty($rightBottomDashlet);
                         $rightBottomDashlet.append(one.lib.dashlet.header("Flow Details"));
-
+                        var button = one.lib.dashlet.button.single("Refresh",
+                                one.f.troubleshooting.existingNodes.id.refreshFlowsButton, "btn-primary", "btn-mini");
+                        var $button = one.lib.dashlet.button.button(button);
+                        $button.click(function() {
+                            one.f.troubleshooting.existingNodes.load.flows(nodeId);
+                        });
+                        $rightBottomDashlet.append($button);
                         var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.flowsDataGrid, {
                             searchable: true,
                             filterable: false,
@@ -138,16 +140,6 @@ one.f.troubleshooting.existingNodes = {
                         $rightBottomDashlet.append($gridHTML);
                         var dataSource = one.f.troubleshooting.existingNodes.data.flowsGrid(content);
                         $("#" + one.f.troubleshooting.existingNodes.id.flowsDataGrid).datagrid({dataSource: dataSource});
-
-                        var numberOfFlows = content.nodeData.length;
-                        var refreshRate = one.f.troubleshooting.existingNodes.autoRefreshInterval.flows;
-                        if (numberOfFlows > 0) {
-                            refreshRate += Math.floor(numberOfFlows / 500) *
-                                one.f.troubleshooting.existingNodes.autoRefreshInterval.refreshRateInterval;
-                        }
-                        one.f.troubleshooting.existingNodes.registry.refreshTimer = setTimeout(
-                                one.f.troubleshooting.existingNodes.load.flows,
-                                refreshRate, nodeId);
                     });
                 } catch(e) {}
             },
@@ -156,13 +148,18 @@ one.f.troubleshooting.existingNodes = {
                     if(one.f.troubleshooting === undefined){
                         return;
                     }
-                    clearTimeout(one.f.troubleshooting.existingNodes.registry.refreshTimer);
                     $.getJSON(one.main.constants.address.prefix + "/troubleshoot/portStats?nodeId=" + nodeId, function(content) {
                         $rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
                         one.f.troubleshooting.rightBottomDashlet.setDashletHeader("Ports");
                         one.lib.dashlet.empty($rightBottomDashlet);
                         $rightBottomDashlet.append(one.lib.dashlet.header("Port Details"));
-
+                        var button = one.lib.dashlet.button.single("Refresh",
+                                one.f.troubleshooting.existingNodes.id.refreshPortsButton, "btn-primary", "btn-mini");
+                        var $button = one.lib.dashlet.button.button(button);
+                        $button.click(function() {
+                            one.f.troubleshooting.existingNodes.load.ports(nodeId);
+                        });
+                        $rightBottomDashlet.append($button);
                         var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.portsDataGrid, {
                             searchable: true,
                             filterable: false,
@@ -172,16 +169,6 @@ one.f.troubleshooting.existingNodes = {
                         $rightBottomDashlet.append($gridHTML);
                         var dataSource = one.f.troubleshooting.existingNodes.data.portsGrid(content);
                         $("#" + one.f.troubleshooting.existingNodes.id.portsDataGrid).datagrid({dataSource: dataSource});
-
-                        var numberOfPorts = content.nodeData.length;
-                        var refreshRate = one.f.troubleshooting.existingNodes.autoRefreshInterval.ports;
-                        if (numberOfPorts > 0) {
-                            refreshRate += Math.floor(numberOfPorts / 500) *
-                                one.f.troubleshooting.existingNodes.autoRefreshInterval.refreshRateInterval;
-                        }
-                        one.f.troubleshooting.existingNodes.registry.refreshTimer = setTimeout(
-                                one.f.troubleshooting.existingNodes.load.ports,
-                                refreshRate, nodeId);
                     });
                 } catch(e) {}
             } 
@@ -296,7 +283,7 @@ one.f.troubleshooting.existingNodes = {
                         }
                     ],
                     data: data.nodeData,
-                    delay: 200
+                    delay: 0
                 });
                 return source;
             },