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/ClusterAdminService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java
index d1c4325..4792a94 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterAdminService.java
@@ -30,7 +30,9 @@
      * instance.
      *
      * @param nodes    set of nodes that form the cluster
+     * @deprecated since 1.14
      */
+    @Deprecated
     void formCluster(Set<ControllerNode> nodes);
 
     /**
@@ -40,7 +42,9 @@
      *
      * @param nodes    set of nodes that form the cluster
      * @param partitionSize number of nodes to compose a partition
+     * @deprecated since 1.14
      */
+    @Deprecated
     void formCluster(Set<ControllerNode> nodes, int partitionSize);
 
     /**
@@ -50,14 +54,18 @@
      * @param ip      node IP listen address
      * @param tcpPort tcp listen port
      * @return newly added node
+     * @deprecated since 1.14
      */
+    @Deprecated
     ControllerNode addNode(NodeId nodeId, IpAddress ip, int tcpPort);
 
     /**
      * Removes the specified node from the cluster node list.
      *
      * @param nodeId controller node identifier
+     * @deprecated since 1.14
      */
+    @Deprecated
     void removeNode(NodeId nodeId);
 
     /**
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();
     }
 }
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java
index 20ce75e..acad25f 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataDiff.java
@@ -27,7 +27,10 @@
 
 /**
  * Utility for examining differences between two {@link ClusterMetadata metadata} values.
+ *
+ * @deprecated since 1.14
  */
+@Deprecated
 public class ClusterMetadataDiff {
 
     private final ClusterMetadata oldValue;
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
index 54f23cd..69ceb64 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
@@ -44,6 +44,13 @@
     Set<ControllerNode> getNodes();
 
     /**
+     * Returns the set of consensus nodes.
+     *
+     * @return the set of consensus nodes
+     */
+    Set<Node> getConsensusNodes();
+
+    /**
      * Returns the specified controller node.
      *
      * @param nodeId controller node identifier
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
index dfe0b23..fdcd315 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
@@ -37,6 +37,13 @@
     ControllerNode getLocalNode();
 
     /**
+     * Returns the set of storage nodes.
+     *
+     * @return set of storage nodes
+     */
+    Set<Node> getStorageNodes();
+
+    /**
      * Returns the set of current cluster members.
      *
      * @return set of cluster members
diff --git a/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java b/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
index 1d1a3ec..48932db 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
@@ -15,12 +15,10 @@
  */
 package org.onosproject.cluster;
 
-import org.onlab.packet.IpAddress;
-
 /**
  * Represents a controller instance as a member in a cluster.
  */
-public interface ControllerNode {
+public interface ControllerNode extends Node {
 
     /** Represents the operational state of the instance. */
     enum State {
@@ -60,25 +58,4 @@
         }
     }
 
-    /**
-     * Returns the instance identifier.
-     *
-     * @return instance identifier
-     */
-    NodeId id();
-
-    /**
-     * Returns the IP address of the controller instance.
-     *
-     * @return IP address
-     */
-    IpAddress ip();
-
-    /**
-     * Returns the TCP port on which the node listens for connections.
-     *
-     * @return TCP port
-     */
-    int tcpPort();
-
 }
diff --git a/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java b/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java
index d0f2f3d..f0a73b6 100644
--- a/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java
+++ b/core/api/src/main/java/org/onosproject/cluster/DefaultPartition.java
@@ -15,8 +15,6 @@
  */
 package org.onosproject.cluster;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.util.Collection;
 import java.util.Objects;
 
@@ -25,13 +23,14 @@
 import com.google.common.collect.Sets;
 import org.onosproject.core.Version;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Default {@link Partition} implementation.
  */
 public class DefaultPartition implements Partition {
 
     private final PartitionId id;
-    private final Version version;
     private final Collection<NodeId> members;
 
     /**
@@ -39,7 +38,6 @@
      */
     protected DefaultPartition() {
         id = null;
-        version = null;
         members = null;
     }
 
@@ -47,12 +45,10 @@
      * Constructs a partition.
      *
      * @param id partition identifier
-     * @param version partition version
      * @param members partition member nodes
      */
-    public DefaultPartition(PartitionId id, Version version, Collection<NodeId> members) {
+    public DefaultPartition(PartitionId id, Collection<NodeId> members) {
         this.id = checkNotNull(id);
-        this.version = version;
         this.members = ImmutableSet.copyOf(members);
     }
 
@@ -63,7 +59,6 @@
      */
     public DefaultPartition(Partition other) {
         this.id = checkNotNull(other.getId());
-        this.version = checkNotNull(other.getVersion());
         this.members = ImmutableSet.copyOf(other.getMembers());
     }
 
@@ -74,7 +69,7 @@
 
     @Override
     public Version getVersion() {
-        return version;
+        return null;
     }
 
     @Override
@@ -86,7 +81,6 @@
     public String toString() {
         return MoreObjects.toStringHelper(getClass())
                 .add("id", id)
-                .add("version", version)
                 .add("members", members)
                 .toString();
     }
diff --git a/core/api/src/main/java/org/onosproject/cluster/Node.java b/core/api/src/main/java/org/onosproject/cluster/Node.java
new file mode 100644
index 0000000..8d6a197
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/cluster/Node.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * Represents a controller instance as a member in a cluster.
+ */
+public interface Node {
+
+    /**
+     * Returns the instance identifier.
+     *
+     * @return instance identifier
+     */
+    NodeId id();
+
+    /**
+     * Returns the IP address of the controller instance.
+     *
+     * @return IP address
+     */
+    IpAddress ip();
+
+    /**
+     * Returns the TCP port on which the node listens for connections.
+     *
+     * @return TCP port
+     */
+    int tcpPort();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/cluster/Partition.java b/core/api/src/main/java/org/onosproject/cluster/Partition.java
index ebff406..33bc68f 100644
--- a/core/api/src/main/java/org/onosproject/cluster/Partition.java
+++ b/core/api/src/main/java/org/onosproject/cluster/Partition.java
@@ -35,7 +35,9 @@
      * Returns the partition version.
      *
      * @return the partition version
+     * @deprecated since 1.14
      */
+    @Deprecated
     Version getVersion();
 
     /**