[ONOS-5156] DistributedGroupStore: keep both entries map in sync

There are 2 maps to store groupstores, keep both in sync from the start.
It can happen that the deviceid-based map isn't properly initialized
when the store gets data from other peers in a cluster in activate()

Change-Id: Ia33929f734a846c72890cf57095ea9ff8d2d394c
diff --git a/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java b/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
index f9a53ec..6f3549b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
@@ -212,6 +212,7 @@
         groupStoreEntriesByKey.addListener(mapListener);
         log.debug("Current size of groupstorekeymap:{}",
                   groupStoreEntriesByKey.size());
+        synchronizeGroupStoreEntries();
 
         log.debug("Creating GroupStoreId Map From GroupStoreKey Map");
         matchGroupEntries();
@@ -284,6 +285,18 @@
         }
     }
 
+
+    private void synchronizeGroupStoreEntries() {
+        Map<GroupStoreKeyMapKey, StoredGroupEntry> groupEntryMap = groupStoreEntriesByKey.asJavaMap();
+        for (Entry<GroupStoreKeyMapKey, StoredGroupEntry> entry : groupEntryMap.entrySet()) {
+            GroupStoreKeyMapKey key = entry.getKey();
+            StoredGroupEntry value = entry.getValue();
+
+            ConcurrentMap<GroupId, StoredGroupEntry> groupIdTable = getGroupIdTable(value.deviceId());
+            groupIdTable.put(value.id(), value);
+        }
+    }
+
     /**
      * Returns the group store eventual consistent key map.
      *