- Supports multi-table feature in the improved batch process in the flow rule subsystem.
- Fix a bug of unsafe type conversion in OpenFlowGroupProvider.

Change-Id: I9a62f81b66d350b84296192f770dc8987aa0967b
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
index 56ced3d..928f7b0 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -222,7 +222,11 @@
                               fbe.operator(), fbe);
                     continue;
                 }
-            sw.sendMsg(mod);
+            if (fbe.target().type() == FlowRule.Type.DEFAULT) {
+                sw.sendMsg(mod);
+            } else {
+                sw.sendMsg(mod, getTableType(fbe.target().type()));
+            }
         }
         OFBarrierRequest.Builder builder = sw.factory()
                 .buildBarrierRequest()
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
index a6ec780..6fb5d0a 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
@@ -87,11 +87,11 @@
     private static final AtomicLong XID_COUNTER = new AtomicLong(1);
     private final Map<Dpid, GroupStatsCollector> collectors = Maps.newHashMap();
     private final Map<Long, OFStatsReply> groupStats = Maps.newConcurrentMap();
-    private final Map<Integer, GroupOperation> pendingGroupOperations =
+    private final Map<GroupId, GroupOperation> pendingGroupOperations =
             Maps.newConcurrentMap();
 
     /* Map<Group ID, Transaction ID> */
-    private final Map<Integer, Long> pendingXidMaps = Maps.newConcurrentMap();
+    private final Map<GroupId, Long> pendingXidMaps = Maps.newConcurrentMap();
 
     /**
      * Creates a OpenFlow group provider.
@@ -157,9 +157,9 @@
                     log.error("Unsupported Group operation");
             }
             sw.sendMsg(groupMod);
-            pendingGroupOperations.put(groupMod.getGroup().getGroupNumber(),
-                    groupOperation);
-            pendingXidMaps.put(groupMod.getGroup().getGroupNumber(), groupModXid);
+            GroupId groudId = new DefaultGroupId(groupMod.getGroup().getGroupNumber());
+            pendingGroupOperations.put(groudId, groupOperation);
+            pendingXidMaps.put(groudId, groupModXid);
         }
      }
 
@@ -282,14 +282,14 @@
                 case ERROR:
                     OFErrorMsg errorMsg = (OFErrorMsg) msg;
                     if (errorMsg.getErrType() == OFErrorType.GROUP_MOD_FAILED) {
-                        int pendingGroupId = -1;
-                        for (Map.Entry<Integer, Long> entry: pendingXidMaps.entrySet()) {
+                        GroupId pendingGroupId = null;
+                        for (Map.Entry<GroupId, Long> entry: pendingXidMaps.entrySet()) {
                             if (entry.getValue() == errorMsg.getXid()) {
                                 pendingGroupId = entry.getKey();
                                 break;
                             }
                         }
-                        if (pendingGroupId == -1) {
+                        if (pendingGroupId == null) {
                             log.warn("Error for unknown group operation: {}",
                                     errorMsg.getXid());
                         } else {