Fix null value put in FRM incativeFlows hash map 89/589/2
authorAlessandro Boch <aboch@cisco.com>
Thu, 11 Jul 2013 00:23:53 +0000 (17:23 -0700)
committerAlessandro Boch <aboch@cisco.com>
Thu, 11 Jul 2013 01:29:15 +0000 (18:29 -0700)
- Also renamed ForwardingRulesManagerImpl class to ForwardingRulesManager as already in internal directory
- Minor changes in FlowProgrammerService

Change-Id: I38b46f4ce29b5d6f4dfc0f38db3d3cef960b26ac
Signed-off-by: Alessandro Boch <aboch@cisco.com>
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java [moved from opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java with 99% similarity]
opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerIT.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java

index 5b2b3b3..b3dae0f 100644 (file)
@@ -65,7 +65,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public Object[] getImplementations() {
-        Object[] res = { ForwardingRulesManagerImpl.class };
+        Object[] res = { ForwardingRulesManager.class };
         return res;
     }
 
@@ -86,7 +86,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public void configureInstance(Component c, Object imp, String containerName) {
-        if (imp.equals(ForwardingRulesManagerImpl.class)) {
+        if (imp.equals(ForwardingRulesManager.class)) {
             String interfaces[] = null;
             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
             Set<String> propSet = new HashSet<String>();
@@ -88,13 +88,13 @@ import org.slf4j.LoggerFactory;
  * the network. It also maintains the central repository of all the forwarding
  * rules installed on the network nodes.
  */
-public class ForwardingRulesManagerImpl implements IForwardingRulesManager, PortGroupChangeListener,
+public class ForwardingRulesManager implements IForwardingRulesManager, PortGroupChangeListener,
         IContainerListener, ISwitchManagerAware, IConfigurationContainerAware, IInventoryListener, IObjectReader,
         ICacheUpdateAware<Long, String>, CommandProvider, IFlowProgrammerListener {
     private static final String SAVE = "Save";
     private static final String NODEDOWN = "Node is Down";
     private static final String SUCCESS = StatusCode.SUCCESS.toString();
-    private static final Logger log = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class);
+    private static final Logger log = LoggerFactory.getLogger(ForwardingRulesManager.class);
     private Map<Long, String> flowsSaveEvent;
     private String frmFileName;
     private String portGroupFileName;
@@ -1690,7 +1690,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Port
             FlowEntryInstall flowEntries = mapEntry.getValue();
             // Skip internal generated static flows
             if (!flowEntries.isInternal()) {
-                inactiveFlows.put(flowEntries.getOriginal(), null);
+                inactiveFlows.put(flowEntries.getOriginal(), flowEntries.getOriginal());
             }
         }
 
index c3f4105..c497eb2 100644 (file)
@@ -1,18 +1,23 @@
 package org.opendaylight.controller.forwardingrulesmanager.internal;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Bundle;
+
 import javax.inject.Inject;
 
 import org.junit.Assert;
-import org.junit.Test;
 import org.junit.Before;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
@@ -25,14 +30,15 @@ import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.NodeCreator;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.osgi.framework.BundleContext;
-import static org.junit.Assert.*;
-import org.ops4j.pax.exam.junit.Configuration;
-import static org.ops4j.pax.exam.CoreOptions.*;
-
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @RunWith(PaxExam.class)
 public class ForwardingRulesManagerIT {
@@ -166,8 +172,7 @@ public class ForwardingRulesManagerIT {
         // Assert if true, if false we are good to go!
         assertFalse(debugit);
 
-        ServiceReference r = bc
-                .getServiceReference(IForwardingRulesManager.class.getName());
+        ServiceReference r = bc.getServiceReference(IForwardingRulesManager.class.getName());
         if (r != null) {
             this.manager = (IForwardingRulesManager) bc.getService(r);
         }
@@ -195,8 +200,10 @@ public class ForwardingRulesManagerIT {
         Node node = NodeCreator.createOFNode(1L);
         FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
 
-        Status stat = manager.installFlowEntry(null);
-        Assert.assertTrue(stat.getCode().equals(StatusCode.NOTACCEPTABLE));
+        Status stat = manager.installFlowEntry(fe);
+
+        // OF plugin is not there in integration testing mode
+        Assert.assertTrue(stat.getCode() == StatusCode.NOSERVICE);
     }
 
 }
index 369588c..a7bdb9d 100644 (file)
@@ -116,20 +116,20 @@ public class FlowProgrammerService implements IFlowProgrammerService,
     }
 
     // Set the reference to the plugin flow programmer
-    public void setService(Map props, IPluginInFlowProgrammerService s) {
+    public void setService(Map<String, Object> props, IPluginInFlowProgrammerService s) {
         if (this.pluginFlowProgrammer == null) {
             logger.error("pluginFlowProgrammer store null");
             return;
         }
 
-        logger.trace("Got a service set request {}", s);
-        String type = null;
-        for (Object e : props.entrySet()) {
-            Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:({}) value:({})", entry.getKey(),
-                    entry.getValue());
+        if (logger.isTraceEnabled()) {
+            logger.trace("Got a service set request {}", s);
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
+            }
         }
 
+        String type = null;
         Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
             type = (String) value;
@@ -143,20 +143,21 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         }
     }
 
-    public void unsetService(Map props, IPluginInFlowProgrammerService s) {
+    public void unsetService(Map<String, Object> props, IPluginInFlowProgrammerService s) {
         if (this.pluginFlowProgrammer == null) {
             logger.error("pluginFlowProgrammer store null");
             return;
         }
 
-        String type = null;
         logger.debug("Received unsetpluginFlowProgrammer request");
-        for (Object e : props.entrySet()) {
-            Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:({}) value:({})", entry.getKey(),
-                    entry.getValue());
+        if (logger.isTraceEnabled()) {
+            logger.trace("Got a service set request {}", s);
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
+            }
         }
 
+        String type = null;
         Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
             type = (String) value;