Topology Notifications, seprating PortNotification 61/4261/4
authorGaurav Bhagwani <gaurav.bhagwani@ericsson.com>
Thu, 16 Jan 2014 13:29:37 +0000 (18:59 +0530)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 16 Jan 2014 16:37:33 +0000 (16:37 +0000)
Signed-off-by: Gaurav Bhagwani <gaurav.bhagwani@ericsson.com>
Change-Id: I41b4113b00c0c54dce2fc46652f55f762ee3c57f

test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.xtend
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java [new file with mode: 0644]
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java [new file with mode: 0644]

index 5c3e638247661450f4485d9f7fa6657baa2e975c..743b0efe907dbcc3dde539a8a75cb531f15fc45b 100644 (file)
@@ -24,6 +24,8 @@ class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
     var OpenflowpluginMeterTestCommandProvider cmdMeterProvider;
     var OpenflowpluginTableFeaturesTestCommandProvider cmdTableProvider;
     var OpenflowpluginStatsTestCommandProvider cmdStatsProvider;
+    var OpenflowpluginTestNodeConnectorNotification cmdNodeConnectorNotification;
+    var OpenflowpluginTestTopologyNotification cmdTopologyNotification;
     public static final String NODE_ID =  "foo:node:1";
 
     override onSessionInitiated(ProviderContext session) {
@@ -38,8 +40,9 @@ class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
         cmdGroupProvider.onSessionInitiated(session);
         cmdMeterProvider.onSessionInitiated(session);
         cmdTableProvider.onSessionInitiated(session);
-        cmdStatsProvider.onSessionInitiated(session);
-        
+        cmdStatsProvider.onSessionInitiated(session);      
+        cmdNodeConnectorNotification.onSessionInitiated(session);
+        cmdTopologyNotification.onSessionInitiated(session);
     }
     
     override startImpl(BundleContext ctx) {
@@ -49,7 +52,8 @@ class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
         cmdMeterProvider = new OpenflowpluginMeterTestCommandProvider(ctx);
         cmdTableProvider = new OpenflowpluginTableFeaturesTestCommandProvider(ctx);
         cmdStatsProvider = new OpenflowpluginStatsTestCommandProvider(ctx);
-    
+        cmdNodeConnectorNotification = new OpenflowpluginTestNodeConnectorNotification(ctx);
+       cmdTopologyNotification = new OpenflowpluginTestTopologyNotification(ctx);
     }
 
     override protected stopImpl(BundleContext context) {
index dca5f3ec2868b00c92d9084d5cc003e632f420d4..7682951631a23730a5e44f16ba7ddb67e1da9f73 100644 (file)
@@ -123,6 +123,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Node
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
@@ -137,14 +138,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
@@ -196,10 +192,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     private final String originalFlowName = "Foo";
     private final String updatedFlowName = "Bar";
     private final FlowEventListener flowEventListener = new FlowEventListener();
-    private final PortEventListener portEventListener = new PortEventListener();
     private static NotificationService notificationService;
     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
-    private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener2Reg;
 
     public OpenflowpluginTestCommandProvider(BundleContext ctx) {
         this.ctx = ctx;
@@ -210,7 +204,6 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         notificationService = session.getSALService(NotificationService.class);
         // For switch events
         listener1Reg = notificationService.registerNotificationListener(flowEventListener);
-        listener2Reg = notificationService.registerNotificationListener(portEventListener);
         dataBrokerService = session.getSALService(DataBrokerService.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
         createTestFlow(createTestNode(null), null, null);
@@ -244,25 +237,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         @Override
         public void onFlowRemoved(FlowRemoved notification) {
-            LOG.info("removed flow.........................." + notification.toString());
-            LOG.info("remove flow Xid........................." + notification.getTransactionId().getValue());
-            LOG.info("-----------------------------------------------------------------------------------");
+            LOG.debug("removed flow.........................." + notification.toString());
+            LOG.debug("remove flow Xid........................." + notification.getTransactionId().getValue());
+            LOG.debug("-----------------------------------------------------------------------------------");
             removedFlows.add(notification);
         };
 
         @Override
         public void onFlowUpdated(FlowUpdated notification) {
-            LOG.info("updated flow.........................." + notification.toString());
-            LOG.info("updated flow Xid........................." + notification.getTransactionId().getValue());
-            LOG.info("-----------------------------------------------------------------------------------");
+            LOG.debug("updated flow.........................." + notification.toString());
+            LOG.debug("updated flow Xid........................." + notification.getTransactionId().getValue());
+            LOG.debug("-----------------------------------------------------------------------------------");
             updatedFlows.add(notification);
         }
 
         @Override
         public void onNodeErrorNotification(NodeErrorNotification notification) {
-            LOG.info("Error notification  flow Xid........................."
+            LOG.error("Error notification  flow Xid........................."
                     + notification.getTransactionId().getValue());
-            LOG.info("-----------------------------------------------------------------------------------");
+            LOG.debug("-----------------------------------------------------------------------------------");
         }
 
         @Override
@@ -273,49 +266,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         @Override
         public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
-            LOG.info("Switch flow removed : Cookies..................." + notification.getCookie().toString());
-            LOG.info("-----------------------------------------------------------------------------------");
-        }
-
-    }
-
-    final class PortEventListener implements OpendaylightInventoryListener {
-
-        List<NodeUpdated> nodeUpdated = new ArrayList<>();
-        List<NodeRemoved> nodeRemoved = new ArrayList<>();
-        List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
-        List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
-
-        @Override
-        public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
-            LOG.info("NodeConnectorRemoved Notification ...................");
-            LOG.info(notification.getNodeConnectorRef().toString());
-            LOG.info("----------------------------------------------------------------------");
-            nodeConnectorRemoved.add(notification);
-        }
-
-        @Override
-        public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
-            LOG.info("NodeConnectorUpdated Notification...................");
-            LOG.info(notification.getNodeConnectorRef().toString());
-            LOG.info("----------------------------------------------------------------------");
-            nodeConnectorUpdated.add(notification);
-        }
-
-        @Override
-        public void onNodeRemoved(NodeRemoved notification) {
-            LOG.info("NodeConnectorUpdated Notification ...................");
-            LOG.info(notification.getNodeRef().toString());
-            LOG.info("----------------------------------------------------------------------");
-            nodeRemoved.add(notification);
-        }
-
-        @Override
-        public void onNodeUpdated(NodeUpdated notification) {
-            LOG.info("NodeConnectorUpdated Notification ...................");
-            LOG.info(notification.getNodeRef().toString());
-            LOG.info("----------------------------------------------------------------------");
-            nodeUpdated.add(notification);
+            LOG.debug("Switch flow removed : Cookies..................." + notification.getCookie().toString());
+            LOG.debug("-----------------------------------------------------------------------------------");
         }
     }
 
@@ -446,6 +398,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             break;
         case "f23":
             id += 23;
+            // f23 can be used as test-case for generating error notification
+            // if the particular group is not configured - tested
             flow.setMatch(createMatch1().build());
             flow.setInstructions(createAppyActionInstruction16().build());
             break;
@@ -769,6 +723,20 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         return flow;
     }
 
+    private FlowBuilder createtablemiss(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
+        FlowBuilder flow = new FlowBuilder();
+        long id = 456;
+        MatchBuilder matchBuilder = new MatchBuilder();
+        flow.setMatch(matchBuilder.build());
+        flow.setInstructions(createSentToControllerInstructions().build());
+        flow.setPriority(0);
+        flow.setTableId((short) 0);
+        FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+        flow.setKey(key);
+        testFlow = flow;
+        return flow;
+    }
+
     private short getTableId(String tableId) {
         short table = 2;
         try {
@@ -946,8 +914,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ActionBuilder ab = new ActionBuilder();
 
         OutputActionBuilder output = new OutputActionBuilder();
-        output.setMaxLength(56);
-        Uri value = new Uri("CONTROLLER");
+        output.setMaxLength(new Integer(0xffff));
+        Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
         output.setOutputNodeConnector(value);
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setOrder(0);
@@ -1231,8 +1199,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
-    }  
-       
+    }
 
     private static InstructionsBuilder createAppyActionInstruction9() {
 
@@ -1847,7 +1814,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         isb.setInstruction(instructions);
         return isb;
     }
-       
+
     private static InstructionsBuilder createAppyActionInstruction33() {
 
         List<Action> actionList = new ArrayList<Action>();
@@ -2326,12 +2293,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
         ActionBuilder ab1 = new ActionBuilder();
         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
-    /*    ActionBuilder ab2 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
-        ActionBuilder ab3 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
-        ActionBuilder ab4 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();   */
+        /*
+         * ActionBuilder ab2 = new ActionBuilder(); SetFieldBuilder
+         * setFieldBuilder2 = new SetFieldBuilder(); ActionBuilder ab3 = new
+         * ActionBuilder(); SetFieldBuilder setFieldBuilder3 = new
+         * SetFieldBuilder(); ActionBuilder ab4 = new ActionBuilder();
+         * SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
+         */
         ActionBuilder ab5 = new ActionBuilder();
         SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
         ActionBuilder ab6 = new ActionBuilder();
@@ -2340,17 +2308,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         // IPv6
         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
         Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
-     //   Ipv6MatchBuilder ipv6Builder2 = new Ipv6MatchBuilder();
-      //  Ipv6MatchBuilder ipv6Builder3 = new Ipv6MatchBuilder();
-       // Ipv6MatchBuilder ipv6Builder4 = new Ipv6MatchBuilder();
+        // Ipv6MatchBuilder ipv6Builder2 = new Ipv6MatchBuilder();
+        // Ipv6MatchBuilder ipv6Builder3 = new Ipv6MatchBuilder();
+        // Ipv6MatchBuilder ipv6Builder4 = new Ipv6MatchBuilder();
         Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
         Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
 
         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
-      //  Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
-      //  MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
-       // MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
+        // Ipv6Address ndtarget = new
+        // Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
+        // MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
+        // MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
         nextheader.setIpv6Exthdr(58);
         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
@@ -2359,9 +2328,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         ipv6Builder.setIpv6Source(srcip6);
         ipv6Builder1.setIpv6Destination(dstip6);
-     //   ipv6Builder2.setIpv6NdTarget(ndtarget);
-      //  ipv6Builder3.setIpv6NdSll(ndsll);
-       // ipv6Builder4.setIpv6NdTll(ndtll);
+        // ipv6Builder2.setIpv6NdTarget(ndtarget);
+        // ipv6Builder3.setIpv6NdSll(ndsll);
+        // ipv6Builder4.setIpv6NdTll(ndtll);
         ipv6Builder5.setIpv6ExtHeader(nextheader.build());
         ipv6Builder6.setIpv6Label(ipv6label.build());
 
@@ -2375,21 +2344,22 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionLists.add(ab1.build());
 
-    /*  setFieldBuilder2.setLayer3Match(ipv6Builder2.build());
-        ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
-        ab2.setKey(new ActionKey(2));
-        actionLists.add(ab2.build());
-
-        setFieldBuilder3.setLayer3Match(ipv6Builder3.build());
-        ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
-        ab3.setKey(new ActionKey(3));
-        actionLists.add(ab3.build());
-
-        setFieldBuilder4.setLayer3Match(ipv6Builder4.build());
-        ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
-        ab4.setKey(new ActionKey(4));
-        actionLists.add(ab4.build());
-*/
+        /*
+         * setFieldBuilder2.setLayer3Match(ipv6Builder2.build());
+         * ab2.setAction(new
+         * SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
+         * ab2.setKey(new ActionKey(2)); actionLists.add(ab2.build());
+         *
+         * setFieldBuilder3.setLayer3Match(ipv6Builder3.build());
+         * ab3.setAction(new
+         * SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
+         * ab3.setKey(new ActionKey(3)); actionLists.add(ab3.build());
+         *
+         * setFieldBuilder4.setLayer3Match(ipv6Builder4.build());
+         * ab4.setAction(new
+         * SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
+         * ab4.setKey(new ActionKey(4)); actionLists.add(ab4.build());
+         */
         setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
         ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
         ab5.setKey(new ActionKey(5));
@@ -2415,7 +2385,6 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         return isb;
     }
 
-
     private static InstructionsBuilder createAppyActionInstruction45() {
 
         List<Action> actionList = new ArrayList<Action>();
@@ -2639,7 +2608,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         return match;
     }
-       
+
     /**
      * @return
      */
@@ -2663,8 +2632,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         match.setIcmpv6Match(icmpv6match.build());
 
         return match;
-    }  
-       
+    }
+
     private static MatchBuilder createMatch33() {
 
         MatchBuilder match = new MatchBuilder();
@@ -2680,12 +2649,12 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
         return match;
-    }  
+    }
 
     private static MatchBuilder createInphyportMatch(NodeId nodeId) {
         MatchBuilder match = new MatchBuilder();
-        match.setInPort(new NodeConnectorId(nodeId+":202"));
-        match.setInPhyPort(new NodeConnectorId(nodeId+":10122"));
+        match.setInPort(new NodeConnectorId(nodeId + ":202"));
+        match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
         return match;
     }
 
@@ -3088,7 +3057,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     public void _removeMDFlow(CommandInterpreter ci) {
         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
         NodeBuilder tn = createTestNode(ci.nextArgument());
-        FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
+        String flowtype = ci.nextArgument();
+        FlowBuilder tf;
+        if (flowtype.equals("fTM")) {
+            tf = createtablemiss(tn, flowtype, ci.nextArgument());
+        } else {
+            tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
+        }
         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
                 .child(Flow.class, tf.getKey()).build();
@@ -3111,7 +3086,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     public void _addMDFlow(CommandInterpreter ci) {
         NodeBuilder tn = createTestNode(ci.nextArgument());
-        FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
+        String flowtype = ci.nextArgument();
+        FlowBuilder tf;
+        if (flowtype.equals("fTM")) {
+            tf = createtablemiss(tn, flowtype, ci.nextArgument());
+        } else {
+            tf = createTestFlow(tn, flowtype, ci.nextArgument());
+        }
         writeFlow(ci, tf, tn);
     }
 
diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java
new file mode 100644 (file)
index 0000000..7136c40
--- /dev/null
@@ -0,0 +1,81 @@
+package org.opendaylight.openflowplugin.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OpenflowpluginTestNodeConnectorNotification {
+
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
+
+    private DataBrokerService dataBrokerService;
+    private ProviderContext pc;
+    private final BundleContext ctx;
+    private final PortEventListener portEventListener = new PortEventListener();
+    private static NotificationService notificationService;
+    private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listenerReg;
+
+    public OpenflowpluginTestNodeConnectorNotification(BundleContext ctx) {
+        this.ctx = ctx;
+    }
+
+    public void onSessionInitiated(ProviderContext session) {
+        pc = session;
+        notificationService = session.getSALService(NotificationService.class);
+        // For switch events
+        listenerReg = notificationService.registerNotificationListener(portEventListener);
+        dataBrokerService = session.getSALService(DataBrokerService.class);
+    }
+
+    final class PortEventListener implements OpendaylightInventoryListener {
+
+        List<NodeUpdated> nodeUpdated = new ArrayList<>();
+        List<NodeRemoved> nodeRemoved = new ArrayList<>();
+        List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
+        List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
+
+        @Override
+        public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
+            LOG.debug("NodeConnectorRemoved Notification ...................");
+            LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
+            LOG.debug("----------------------------------------------------------------------");
+            nodeConnectorRemoved.add(notification);
+        }
+
+        @Override
+        public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
+            LOG.debug("NodeConnectorUpdated Notification...................");
+            LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
+            LOG.debug("----------------------------------------------------------------------");
+            nodeConnectorUpdated.add(notification);
+        }
+
+        @Override
+        public void onNodeRemoved(NodeRemoved notification) {
+            LOG.debug("NodeRemoved Notification ...................");
+            LOG.debug("NodeRef " + notification.getNodeRef());
+            LOG.debug("----------------------------------------------------------------------");
+            nodeRemoved.add(notification);
+        }
+
+        @Override
+        public void onNodeUpdated(NodeUpdated notification) {
+            LOG.debug("NodeUpdated Notification ...................");
+            LOG.debug("NodeRef " + notification.getNodeRef());
+            LOG.debug("----------------------------------------------------------------------");
+            nodeUpdated.add(notification);
+        }
+    }
+}
diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java
new file mode 100644 (file)
index 0000000..9f8e0d0
--- /dev/null
@@ -0,0 +1,78 @@
+package org.opendaylight.openflowplugin.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkOverutilized;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkUtilizationNormal;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OpenflowpluginTestTopologyNotification {
+
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
+
+    private DataBrokerService dataBrokerService;
+    private ProviderContext pc;
+    private final BundleContext ctx;
+    private final TopologyEventListener topologyEventListener = new TopologyEventListener();
+    private static NotificationService notificationService;
+    private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listenerReg;
+
+    public OpenflowpluginTestTopologyNotification(BundleContext ctx) {
+        this.ctx = ctx;
+    }
+
+    public void onSessionInitiated(ProviderContext session) {
+        pc = session;
+        notificationService = session.getSALService(NotificationService.class);
+        // For switch events
+        listenerReg = notificationService.registerNotificationListener(topologyEventListener);
+        dataBrokerService = session.getSALService(DataBrokerService.class);
+    }
+
+    final class TopologyEventListener implements FlowTopologyDiscoveryListener {
+
+        List<LinkDiscovered> linkdiscovered = new ArrayList<>();
+        List<LinkOverutilized> linkoverutilized = new ArrayList<>();
+        List<LinkRemoved> linkremoved = new ArrayList<>();
+        List<LinkUtilizationNormal> linkutilizationnormal = new ArrayList<>();
+
+        @Override
+        public void onLinkDiscovered(LinkDiscovered notification) {
+            LOG.debug("-------------------------------------------");
+            LOG.debug("LinkDiscovered notification ........");
+            LOG.debug("-------------------------------------------");
+        }
+
+        @Override
+        public void onLinkOverutilized(LinkOverutilized notification) {
+            LOG.debug("-------------------------------------------");
+            LOG.debug("LinkOverutilized notification ........");
+            LOG.debug("-------------------------------------------");
+        }
+
+        @Override
+        public void onLinkRemoved(LinkRemoved notification) {
+            LOG.debug("-------------------------------------------");
+            LOG.debug("LinkRemoved notification   ........");
+            LOG.debug("-------------------------------------------");
+        }
+
+        @Override
+        public void onLinkUtilizationNormal(LinkUtilizationNormal notification) {
+            LOG.debug("-------------------------------------------");
+            LOG.debug("LinkUtilizationNormal notification ........");
+            LOG.debug("-------------------------------------------");
+        }
+
+    }
+}