Upgrade to Atomix 3.0-rc5
* Upgrade Raft primitives to Atomix 3.0
* Replace cluster store and messaging implementations with Atomix cluster management/messaging
* Add test scripts for installing/starting Atomix cluster
* Replace core primitives with Atomix primitives.

Change-Id: I7623653c81292a34f21b01f5f38ca11b5ef15cad
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
index c205345..8f7d960 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
@@ -17,23 +17,20 @@
 
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Objects;
 import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.onosproject.net.Provided;
-import org.onosproject.net.provider.ProviderId;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Verify.verify;
-import static com.google.common.base.Charsets.UTF_8;
 
 import com.google.common.base.MoreObjects;
-import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import com.google.common.hash.Funnel;
 import com.google.common.hash.PrimitiveSink;
+import org.onosproject.net.Provided;
+import org.onosproject.net.provider.ProviderId;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
  * Cluster metadata.
@@ -46,8 +43,8 @@
 
     private final ProviderId providerId;
     private final String name;
-    private final Set<ControllerNode> nodes;
-    private final Set<Partition> partitions;
+    private final ControllerNode localNode;
+    private final Set<Node> nodes;
 
     public static final Funnel<ClusterMetadata> HASH_FUNNEL = new Funnel<ClusterMetadata>() {
         @Override
@@ -60,31 +57,23 @@
     private ClusterMetadata() {
         providerId = null;
         name = null;
+        localNode = null;
         nodes = null;
-        partitions = null;
     }
 
-    public ClusterMetadata(ProviderId providerId,
-            String name,
-            Set<ControllerNode> nodes,
-            Set<Partition> partitions) {
+    public ClusterMetadata(
+        ProviderId providerId,
+        String name,
+        ControllerNode localNode,
+        Set<Node> nodes) {
         this.providerId = checkNotNull(providerId);
         this.name = checkNotNull(name);
+        this.localNode = localNode;
         this.nodes = ImmutableSet.copyOf(checkNotNull(nodes));
-        // verify that partitions are constituted from valid cluster nodes.
-        boolean validPartitions = Collections2.transform(nodes, ControllerNode::id)
-                .containsAll(partitions
-                        .stream()
-                        .flatMap(r -> r.getMembers().stream())
-                        .collect(Collectors.toSet()));
-        verify(validPartitions, "Partition locations must be valid cluster nodes");
-        this.partitions = ImmutableSet.copyOf(checkNotNull(partitions));
     }
 
-    public ClusterMetadata(String name,
-            Set<ControllerNode> nodes,
-            Set<Partition> partitions) {
-        this(new ProviderId("none", "none"), name, nodes, partitions);
+    public ClusterMetadata(String name, ControllerNode localNode, Set<Node> nodes) {
+        this(new ProviderId("none", "none"), name, localNode, nodes);
     }
 
     @Override
@@ -102,20 +91,39 @@
     }
 
     /**
+     * Returns the local controller node.
+     * @return the local controller node
+     */
+    public ControllerNode getLocalNode() {
+        return localNode;
+    }
+
+    /**
      * Returns the collection of {@link org.onosproject.cluster.ControllerNode nodes} that make up the cluster.
      * @return cluster nodes
      */
     public Collection<ControllerNode> getNodes() {
-        return this.nodes;
+        return (Collection) nodes;
+    }
+
+    /**
+     * Returns the collection of storage nodes.
+     *
+     * @return the collection of storage nodes
+     */
+    public Collection<Node> getStorageNodes() {
+        return nodes;
     }
 
     /**
      * Returns the collection of {@link org.onosproject.cluster.Partition partitions} that make
      * up the cluster.
      * @return collection of partitions.
+     * @deprecated since 1.14
      */
+    @Deprecated
     public Collection<Partition> getPartitions() {
-        return this.partitions;
+        return Collections.emptySet();
     }
 
     @Override
@@ -124,13 +132,12 @@
                 .add("providerId", providerId)
                 .add("name", name)
                 .add("nodes", nodes)
-                .add("partitions", partitions)
                 .toString();
     }
 
     @Override
     public int hashCode() {
-        return Arrays.deepHashCode(new Object[] {providerId, name, nodes, partitions});
+        return Arrays.deepHashCode(new Object[] {providerId, name, nodes});
     }
 
     /*
@@ -140,7 +147,6 @@
      */
     @Override
     public boolean equals(Object object) {
-
         if (object == null) {
             return false;
         }
@@ -151,9 +157,8 @@
         ClusterMetadata that = (ClusterMetadata) object;
 
         return Objects.equals(this.name, that.name) &&
+               this.localNode.equals(that.localNode) &&
                Objects.equals(this.nodes.size(), that.nodes.size()) &&
-               Objects.equals(this.partitions.size(), that.partitions.size()) &&
-               Sets.symmetricDifference(this.nodes, that.nodes).isEmpty() &&
-               Sets.symmetricDifference(this.partitions, that.partitions).isEmpty();
+               Sets.symmetricDifference(this.nodes, that.nodes).isEmpty();
     }
 }