Currently need to specify handshaker behavior in onos-drivers xml file.
Later this need will be removed as the system will use default behaviors.
Fixed a bug in group checker where it was consulting the wrong map.
Cleaned up some logs

Change-Id: I45d91bc8d4c19474dcf0c37f82763985e5d2c84f
diff --git a/apps/bgprouter/src/main/java/org/onosproject/bgprouter/BgpRouter.java b/apps/bgprouter/src/main/java/org/onosproject/bgprouter/BgpRouter.java
index f38d1cb..13fbc01 100644
--- a/apps/bgprouter/src/main/java/org/onosproject/bgprouter/BgpRouter.java
+++ b/apps/bgprouter/src/main/java/org/onosproject/bgprouter/BgpRouter.java
@@ -366,14 +366,14 @@
                       @Override
                       public void onSuccess(Objective objective) {
                           log.info("Successfully installed interface based "
-                                  + "filtering objcetives");
+                                  + "filtering objcetives for intf {}", intf);
                       }
 
                       @Override
                       public void onError(Objective objective,
                                           ObjectiveError error) {
-                          log.error("Failed to install interface filters {}: {}",
-                                   objective, error);
+                          log.error("Failed to install interface filters for intf {}: {}",
+                                   intf, error);
                           // TODO something more than just logging
                       }
                   }));
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java
index 3509148..f05f6cb 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java
@@ -353,14 +353,14 @@
         flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
             @Override
             public void onSuccess(FlowRuleOperations ops) {
-                pass(filt);
                 log.info("Applied filtering rules");
+                pass(filt);
             }
 
             @Override
             public void onError(FlowRuleOperations ops) {
-                fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
                 log.info("Failed to apply filtering rules");
+                fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
             }
         }));
 
@@ -377,7 +377,7 @@
      * @param nextObj  the nextObjective of type SIMPLE
      */
     private void processSimpleNextObjective(NextObjective nextObj) {
-        // break up next objective to GroupChain objects
+        // break up simple next objective to GroupChain objects
         TrafficTreatment treatment = nextObj.next().iterator().next();
         // for the l2interface group, get vlan and port info
         // for the l3unicast group, get the src/dst mac and vlan info
@@ -824,7 +824,7 @@
     private class GroupChecker implements Runnable {
         @Override
         public void run() {
-            Set<GroupKey> keys = pendingNextObjectives.asMap().keySet().stream()
+            Set<GroupKey> keys = pendingGroups.keySet().stream()
                     .filter(key -> groupService.getGroup(deviceId, key) != null)
                     .collect(Collectors.toSet());
 
@@ -832,43 +832,49 @@
                 //first check for group chain
                 GroupChainElem gce = pendingGroups.remove(key);
                 if (gce != null) {
-                    log.info("Heard back from group service. Processing next "
-                            + "group in group chain with group key {}", gce.getGkey());
+                    log.info("Group service processed group key {}. Processing next "
+                            + "group in group chain with group key {}",
+                            appKryo.deserialize(key.key()),
+                            appKryo.deserialize(gce.getGkey().key()));
                     processGroupChain(gce);
                 } else {
                     OfdpaGroupChain obj = pendingNextObjectives.getIfPresent(key);
-                    if (obj == null) {
-                        return;
+                    log.info("Group service processed group key {}. Done implementing "
+                            + "next objective: {}", appKryo.deserialize(key.key()),
+                            obj.nextObjective().id());
+                    if (obj != null) {
+                        pass(obj.nextObjective());
+                        pendingNextObjectives.invalidate(key);
+                        flowObjectiveStore.putNextGroup(obj.nextObjective().id(), obj);
                     }
-                    pass(obj.nextObjective());
-                    pendingNextObjectives.invalidate(key);
-                    log.info("Heard back from group service. Applying pending "
-                            + "objectives for nextId {}", obj.nextObjective().id());
-                    flowObjectiveStore.putNextGroup(obj.nextObjective().id(), obj);
                 }
             });
         }
     }
 
-
     private class InnerGroupListener implements GroupListener {
         @Override
         public void event(GroupEvent event) {
+            log.info("received group event of type {}", event.type());
             if (event.type() == GroupEvent.Type.GROUP_ADDED) {
                 GroupKey key = event.subject().appCookie();
                 // first check for group chain
                 GroupChainElem gce = pendingGroups.remove(key);
                 if (gce != null) {
-                    log.info("group ADDED .. Processing next group in group chain "
-                            + "with group key {}", gce.getGkey());
+                    log.info("group ADDED with group key {} .. "
+                            + "Processing next group in group chain with group key {}",
+                            appKryo.deserialize(key.key()),
+                            appKryo.deserialize(gce.getGkey().key()));
                     processGroupChain(gce);
                 } else {
                     OfdpaGroupChain obj = pendingNextObjectives.getIfPresent(key);
-                    log.info("group ADDED .. Applying pending objectives if any");
                     if (obj != null) {
-                        flowObjectiveStore.putNextGroup(obj.nextObjective().id(), obj);
+                        log.info("group ADDED with key {}.. Done implementing next "
+                                + "objective: {}",
+                                appKryo.deserialize(key.key()), obj.nextObjective().id());
                         pass(obj.nextObjective());
                         pendingNextObjectives.invalidate(key);
+                        flowObjectiveStore.putNextGroup(obj.nextObjective().id(), obj);
                     }
                 }
             }
diff --git a/drivers/src/main/resources/onos-drivers.xml b/drivers/src/main/resources/onos-drivers.xml
index 3273f1b..5d2a1f3 100644
--- a/drivers/src/main/resources/onos-drivers.xml
+++ b/drivers/src/main/resources/onos-drivers.xml
@@ -30,10 +30,14 @@
     <driver name="spring-open-cpqd" manufacturer="Stanford University, Ericsson Research and CPqD Research" hwVersion="OpenFlow 1.3 Reference Userspace Switch" swVersion=".*">
         <behaviour api="org.onosproject.net.behaviour.Pipeliner"
                    impl="org.onosproject.driver.pipeline.SpringOpenTTP"/>
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.handshaker.DefaultSwitchHandShaker"/>
     </driver>
     <driver name="spring-open" manufacturer="Dell " hwVersion="OpenFlow switch HW ver. 1.0" swVersion="OpenFlow switch SW ver. 1.0 and 1.3">
         <behaviour api="org.onosproject.net.behaviour.Pipeliner"
                    impl="org.onosproject.driver.pipeline.SpringOpenTTPDell"/>
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.handshaker.DefaultSwitchHandShaker"/>
     </driver>
     <driver name="cpqd" manufacturer="Stanford University, Ericsson Research and CPqD Research"
             hwVersion="OpenFlow 1.3 Reference Userspace Switch" swVersion=".*">
@@ -58,6 +62,8 @@
     <driver name="ofdpa" manufacturer="Broadcom Corp." hwVersion="OF-DPA 1.0" swVersion="OF-DPA 1.0">
         <behaviour api="org.onosproject.net.behaviour.Pipeliner"
                    impl="org.onosproject.driver.pipeline.OFDPA1Pipeline"/>
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.handshaker.DefaultSwitchHandShaker"/>
     </driver>
 </drivers>
 
diff --git a/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java b/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
index 4779c5d..3907ec6 100644
--- a/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
+++ b/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
@@ -417,9 +417,9 @@
                             h.channel.getRemoteAddress());
                     return;
                 }
-                log.info("Received switch description reply from switch at {}",
-                        h.channel.getRemoteAddress());
                 OFDescStatsReply drep = (OFDescStatsReply) m;
+                log.info("Received switch description reply {} from switch at {}",
+                         drep, h.channel.getRemoteAddress());
                 // Here is where we differentiate between different kinds of switches
                 h.sw = h.controller.getOFSwitchInstance(h.thisdpid, drep, h.ofVersion);