BugFix : Changes to get ping between two hosts to work 38/4238/3
authorMoiz Raja <moraja@cisco.com>
Tue, 14 Jan 2014 23:07:47 +0000 (15:07 -0800)
committerMoiz Raja <moraja@cisco.com>
Wed, 15 Jan 2014 02:08:29 +0000 (18:08 -0800)
1. InventoryUpdates were not getting to ConnectionManager because the InventoryAndReadAdapter was not tracking all listeners
2. DataPacketServiceAdapter was not setup as an IPluginInDataPacketService
3. DataPacketServiceAdapters delegate was not set to the PacketProcessingService
4. Node was not set on the TransmitPacketInput causing an NPE somewhere in the MD-SAL internals (this should probably be better addressed as I have hit this twice already)
5. DataPacketServiceAdapter now handles situation where the NodeConnectors is null

Current state
An IllegalArgumentException is being thrown from the openflowplugin "Session cookie is invalid" - Need to look at that further

Change-Id: I643ea435d7bda9ee7b3a5d603a381c3cfbaa0cce
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/DataPacketServiceAdapter.java

index 2156a81..3d19c98 100644 (file)
@@ -28,8 +28,10 @@ import org.opendaylight.controller.sal.utils.GlobalConstants
 import org.opendaylight.controller.sal.utils.INodeConnectorFactory
 import org.opendaylight.controller.sal.utils.INodeFactory
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices
+import org.opendaylight.controller.sal.packet.IPluginInDataPacketService
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryService
@@ -38,6 +40,7 @@ import org.osgi.framework.BundleContext
 
 import static org.opendaylight.controller.sal.compatibility.NodeMapping.*
 import org.opendaylight.controller.sal.compatibility.topology.TopologyProvider
+import org.opendaylight.controller.sal.compatibility.adsal.DataPacketServiceAdapter
 
 class ComponentActivator extends ComponentActivatorAbstractBase implements BindingAwareConsumer {
 
@@ -64,6 +67,10 @@ class ComponentActivator extends ComponentActivatorAbstractBase implements Bindi
     @Property
     TopologyProvider tpProvider = new TopologyProvider()
 
+    @Property
+    DataPacketServiceAdapter dataPacketService = new DataPacketServiceAdapter()
+
+
 
     override protected init() {
         Node.NodeIDType.registerIDType(MD_SAL_TYPE, String);
@@ -89,6 +96,7 @@ class ComponentActivator extends ComponentActivatorAbstractBase implements Bindi
 
         // Data Packet Service
         subscribe.registerNotificationListener(inventory);
+        dataPacketService.delegate = session.getRpcService(PacketProcessingService)
 
         // Inventory Service
         inventory.dataService = session.getSALService(DataBrokerService);
@@ -99,6 +107,8 @@ class ComponentActivator extends ComponentActivatorAbstractBase implements Bindi
                inventory.dataProviderService = session.getSALService(DataProviderService)
                topology.dataService = session.getSALService(DataProviderService)
                tpProvider.dataService = session.getSALService(DataProviderService)
+
+
                tpProvider.start();
 
         subscribe.registerNotificationListener(dataPacket)
@@ -113,6 +123,14 @@ class ComponentActivator extends ComponentActivatorAbstractBase implements Bindi
         configure(imp, c);
     }
 
+    override protected getImplementations() {
+        return Arrays.asList(dataPacketService)
+    }
+
+    override protected configureInstance(Component c, Object imp, String containerName) {
+        instanceConfigure(imp, c, containerName);
+    }
+
     private def dispatch configure(MDSalNodeFactory imp, Component it) {
         setInterface(INodeFactory.name, properties);
     }
@@ -154,6 +172,14 @@ class ComponentActivator extends ComponentActivatorAbstractBase implements Bindi
 
     }
 
+    private def dispatch instanceConfigure(DataPacketServiceAdapter imp, Component it, String containerName) {
+        setInterface(IPluginInDataPacketService.name, properties)
+    }
+
+    private def dispatch instanceConfigure(ComponentActivator imp, Component it, String containerName) {
+    }
+
+
     private def dispatch configure(InventoryAndReadAdapter imp, Component it) {
         setInterface(Arrays.asList(IPluginInInventoryService.name, IPluginInReadService.name), properties)
         add(
@@ -164,7 +190,7 @@ class ComponentActivator extends ComponentActivatorAbstractBase implements Bindi
         add(
             createServiceDependency() //
             .setService(IPluginOutInventoryService) //
-            .setCallbacks("setInventoryPublisher", "setInventoryPublisher") //
+            .setCallbacks("setInventoryPublisher", "unsetInventoryPublisher") //
             .setRequired(false))
         add(
             createServiceDependency() //
index 47a3d11..21af047 100644 (file)
@@ -3,6 +3,8 @@ package org.opendaylight.controller.sal.compatibility
 import java.util.ArrayList
 import java.util.Collections
 import java.util.List
+import java.util.Set
+import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
 import org.opendaylight.controller.sal.core.Edge
@@ -93,15 +95,23 @@ class InventoryAndReadAdapter implements IPluginInReadService,
     @Property
     OpendaylightFlowTableStatisticsService flowTableStatisticsService;
 
-    @Property
-    IPluginOutInventoryService inventoryPublisher;
-
     @Property
     FlowTopologyDiscoveryService topologyDiscovery;
     
     @Property
-    List<IPluginOutReadService> statisticsPublisher = new ArrayList<IPluginOutReadService>();
-       
+    List<IPluginOutReadService> statisticsPublisher = new CopyOnWriteArrayList<IPluginOutReadService>();
+
+    @Property
+    List<IPluginOutInventoryService> inventoryPublisher = new CopyOnWriteArrayList<IPluginOutInventoryService>();
+
+       def setInventoryPublisher(IPluginOutInventoryService listener){
+        inventoryPublisher.add(listener);
+       }
+
+       def unsetInventoryPublisher(IPluginOutInventoryService listener){
+        inventoryPublisher.remove(listener);
+       }
+
     def setReadPublisher(IPluginOutReadService listener) {
        statisticsPublisher.add(listener);
     }
@@ -330,7 +340,7 @@ class InventoryAndReadAdapter implements IPluginInReadService,
     override onNodeRemoved(NodeRemoved notification) {
         val properties = Collections.<org.opendaylight.controller.sal.core.Property>emptySet();
 
-        inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.REMOVED, properties);
+        publishNodeUpdate(notification.nodeRef.toADNode, UpdateType.REMOVED, properties);
     }
 
     override onNodeConnectorUpdated(NodeConnectorUpdated update) {
@@ -341,7 +351,7 @@ class InventoryAndReadAdapter implements IPluginInReadService,
 
         var nodeConnector = update.nodeConnectorRef.toADNodeConnector
 
-        inventoryPublisher.updateNodeConnector(nodeConnector , updateType , update.toADNodeConnectorProperties);
+        publishNodeConnectorUpdate(nodeConnector , updateType , update.toADNodeConnectorProperties);
     }
 
     override onNodeUpdated(NodeUpdated notification) {
@@ -351,7 +361,7 @@ class InventoryAndReadAdapter implements IPluginInReadService,
         if ( this._dataService.readOperationalData(identifier) == null ){
             updateType = UpdateType.ADDED;
         }
-        inventoryPublisher.updateNode(notification.nodeRef.toADNode, updateType, notification.toADNodeProperties);
+        publishNodeUpdate(notification.nodeRef.toADNode, updateType, notification.toADNodeProperties);
         
                //Notify the listeners of IPluginOutReadService
         
@@ -574,4 +584,17 @@ class InventoryAndReadAdapter implements IPluginInReadService,
        override  getConfiguredNotConnectedNodes() {
         return Collections.emptySet();
        }
+
+
+       private def publishNodeUpdate(Node node, UpdateType updateType, Set<org.opendaylight.controller.sal.core.Property> properties){
+           for( publisher : inventoryPublisher){
+               publisher.updateNode(node, updateType, properties);
+           }
+       }
+
+       private def publishNodeConnectorUpdate(org.opendaylight.controller.sal.core.NodeConnector nodeConnector, UpdateType updateType, Set<org.opendaylight.controller.sal.core.Property> properties){
+           for( publisher : inventoryPublisher){
+               publisher.updateNodeConnector(nodeConnector, updateType, properties);
+           }
+       }
 }
index aa67600..edd3a27 100644 (file)
@@ -3,7 +3,6 @@ package org.opendaylight.controller.sal.compatibility.adsal;
 import org.opendaylight.controller.sal.compatibility.NodeMapping;
 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
 import org.opendaylight.controller.sal.packet.RawPacket;
-import org.opendaylight.controller.sal.packet.RawPacket;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
@@ -22,8 +21,12 @@ public class DataPacketServiceAdapter implements IPluginInDataPacketService {
     private TransmitPacketInput toTransmitPacketInput(RawPacket rawPacket) {
         TransmitPacketInputBuilder builderTPIB = new TransmitPacketInputBuilder();
 
-        NodeConnectorRef egress = NodeMapping.toNodeConnectorRef(rawPacket.getOutgoingNodeConnector());
-        NodeConnectorRef ingress = NodeMapping.toNodeConnectorRef(rawPacket.getIncomingNodeConnector());
+        builderTPIB.setNode(NodeMapping.toNodeRef(rawPacket.getOutgoingNodeConnector().getNode()));
+
+        NodeConnectorRef egress = rawPacket.getOutgoingNodeConnector() == null ? null :
+                NodeMapping.toNodeConnectorRef(rawPacket.getOutgoingNodeConnector());
+        NodeConnectorRef ingress = rawPacket.getIncomingNodeConnector() == null ? null :
+                NodeMapping.toNodeConnectorRef(rawPacket.getIncomingNodeConnector());
         byte[] payload = rawPacket.getPacketData();
 
         builderTPIB.setEgress(egress);
@@ -33,4 +36,14 @@ public class DataPacketServiceAdapter implements IPluginInDataPacketService {
         return builderTPIB.build();
     }
 
+    public PacketProcessingService getDelegate() {
+        return delegate;
+    }
+
+    public void setDelegate(PacketProcessingService delegate) {
+        this.delegate = delegate;
+    }
+
+
+
 }