Serializer related fixes

- DefaultGroupId is part of API
- KryoNamespace is thread-safe, use same instance.

Change-Id: I492f48c2ae9239edb5742c00231cd24b4d6db6a3
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 8c2308d..dc8ac58 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
@@ -144,8 +144,6 @@
 
     private final AtomicInteger groupIdGen = new AtomicInteger();
 
-    private KryoNamespace.Builder kryoBuilder = null;
-
     private KryoNamespace clusterMsgSerializer;
 
     @Property(name = "garbageCollect", boolValue = GARBAGE_COLLECT,
@@ -160,8 +158,9 @@
     @Activate
     public void activate() {
         cfgService.registerProperties(getClass());
-        kryoBuilder = new KryoNamespace.Builder()
+        KryoNamespace.Builder kryoBuilder = new KryoNamespace.Builder()
                 .register(KryoNamespaces.API)
+                .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
                 .register(DefaultGroup.class,
                           DefaultGroupBucket.class,
                           DefaultGroupDescription.class,
@@ -169,7 +168,6 @@
                           GroupDescription.Type.class,
                           Group.GroupState.class,
                           GroupBuckets.class,
-                          DefaultGroupId.class,
                           GroupStoreMessage.class,
                           GroupStoreMessage.Type.class,
                           UpdateType.class,
@@ -180,7 +178,8 @@
                           GroupStoreMapKey.class
                 );
 
-        clusterMsgSerializer = kryoBuilder.build();
+        clusterMsgSerializer = kryoBuilder.build("GroupStore");
+        Serializer serializer = Serializer.using(clusterMsgSerializer);
 
         messageHandlingExecutor = Executors.
                 newFixedThreadPool(MESSAGE_HANDLER_THREAD_POOL_SIZE,
@@ -197,7 +196,7 @@
 
         groupStoreEntriesByKey = storageService.<GroupStoreKeyMapKey, StoredGroupEntry>consistentMapBuilder()
                 .withName("onos-group-store-keymap")
-                .withSerializer(Serializer.using(kryoBuilder.build()))
+                .withSerializer(serializer)
                 .build();
         groupStoreEntriesByKey.addListener(new GroupStoreKeyMapListener());
         log.debug("Current size of groupstorekeymap:{}",
@@ -207,7 +206,7 @@
 
         auditPendingReqQueue = storageService.<GroupStoreKeyMapKey, StoredGroupEntry>consistentMapBuilder()
                 .withName("onos-pending-group-keymap")
-                .withSerializer(Serializer.using(kryoBuilder.build()))
+                .withSerializer(serializer)
                 .build();
         log.debug("Current size of pendinggroupkeymap:{}",
                   auditPendingReqQueue.size());