First round of ClusterMetadata improvements:
    Introduced a PartitionId type for identifying partitions
    Introduced a admin service for making metadata updates
    Update cluster.json format to specify all partitions (including p0) and changed partitionId to be an int.

Change-Id: Ia0617f1ed0ce886680dcee4f5396a4bbdfa225da
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
index 7ddac0c..11bba9c 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
@@ -28,6 +28,7 @@
 import org.onosproject.cluster.ClusterEvent;
 import org.onosproject.cluster.ClusterEventListener;
 import org.onosproject.cluster.ClusterMetadata;
+import org.onosproject.cluster.ClusterMetadataAdminService;
 import org.onosproject.cluster.ClusterMetadataService;
 import org.onosproject.cluster.ClusterService;
 import org.onosproject.cluster.ClusterStore;
@@ -35,10 +36,13 @@
 import org.onosproject.cluster.ControllerNode;
 import org.onosproject.cluster.NodeId;
 import org.onosproject.cluster.Partition;
+import org.onosproject.cluster.PartitionId;
 import org.onosproject.event.AbstractListenerManager;
 import org.slf4j.Logger;
 
+import com.google.common.collect.Collections2;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -71,6 +75,9 @@
     protected ClusterMetadataService clusterMetadataService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected ClusterMetadataAdminService clusterMetadataAdminService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected ClusterStore store;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -136,7 +143,7 @@
                                                   .withControllerNodes(nodes)
                                                   .withPartitions(buildDefaultPartitions(nodes))
                                                   .build();
-        clusterMetadataService.setClusterMetadata(metadata);
+        clusterMetadataAdminService.setClusterMetadata(metadata);
         try {
             log.warn("Shutting down container for cluster reconfiguration!");
             systemService.reboot("now", SystemService.Swipe.NONE);
@@ -171,15 +178,36 @@
         List<ControllerNode> sorted = new ArrayList<>(nodes);
         Collections.sort(sorted, (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()));
         Collection<Partition> partitions = Lists.newArrayList();
-
+        // add p0 partition
+        partitions.add(new Partition() {
+            @Override
+            public PartitionId getId() {
+                return PartitionId.from((0));
+            }
+            @Override
+            public Collection<NodeId> getMembers() {
+                return Sets.newHashSet(Collections2.transform(nodes, ControllerNode::id));
+            }
+        });
+        // add extended partitions
         int length = nodes.size();
         int count = 3;
         for (int i = 0; i < length; i++) {
+            int index = i;
             Set<NodeId> set = new HashSet<>(count);
             for (int j = 0; j < count; j++) {
                 set.add(sorted.get((i + j) % length).id());
             }
-            partitions.add(new Partition("p" + (i + 1), set));
+            partitions.add(new Partition() {
+                @Override
+                public PartitionId getId() {
+                    return PartitionId.from((index + 1));
+                }
+                @Override
+                public Collection<NodeId> getMembers() {
+                    return set;
+                }
+            });
         }
         return partitions;
     }
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java
index a0f7a83..1bb2182 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterMetadataManager.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2015-2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.onosproject.cluster.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -17,6 +32,7 @@
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.packet.IpAddress;
 import org.onosproject.cluster.ClusterMetadata;
+import org.onosproject.cluster.ClusterMetadataAdminService;
 import org.onosproject.cluster.ClusterMetadataEvent;
 import org.onosproject.cluster.ClusterMetadataEventListener;
 import org.onosproject.cluster.ClusterMetadataService;
@@ -34,10 +50,10 @@
 @Service
 public class ClusterMetadataManager
     extends AbstractListenerManager<ClusterMetadataEvent, ClusterMetadataEventListener>
-    implements ClusterMetadataService {
+    implements ClusterMetadataService, ClusterMetadataAdminService {
 
-    private ControllerNode localNode;
     private final Logger log = getLogger(getClass());
+    private ControllerNode localNode;
 
     private ClusterMetadataStoreDelegate delegate = new InternalStoreDelegate();