Upgrade to Atomix 3.1

Change-Id: I2039286b49dafacc786e9ba66db74ef8619ed151
diff --git a/core/store/primitives/BUILD b/core/store/primitives/BUILD
index aad4b68..0cb83ef 100644
--- a/core/store/primitives/BUILD
+++ b/core/store/primitives/BUILD
@@ -42,6 +42,12 @@
     "backup",
 ]
 
+# A list of all cluster protocol packages for dynamic class loading
+CLUSTER_PACKAGES = ",".join([
+    "io.atomix.cluster.discovery",
+    "io.atomix.cluster.protocol",
+])
+
 # A list of all core protocol packages for dynamic class loading
 PROTOCOL_PACKAGES = ",".join(["io.atomix.primitive.partition.impl"] + ["io.atomix.protocols.{protocol},io.atomix.protocols.{protocol}.partition".format(protocol = protocol) for protocol in _protocol_package_names] + ["io.atomix.protocols.gossip"])
 
@@ -53,6 +59,7 @@
 
 # A list of all dynamically loadable Atomix packages
 INCLUDE_PACKAGES = ",".join([
+    CLUSTER_PACKAGES,
     PRIMITIVE_PACKAGES,
     PROTOCOL_PACKAGES,
     CORE_PACKAGES,
diff --git a/lib/deps.json b/lib/deps.json
index b5e6ca0..51cc3c9 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -146,14 +146,14 @@
     "aopalliance-repackaged": "mvn:org.glassfish.hk2.external:aopalliance-repackaged:2.5.0-b42",
     "amqp-client": "mvn:com.rabbitmq:amqp-client:jar:3.6.1",
     "asm": "mvn:org.ow2.asm:asm:5.2",
-    "atomix": "mvn:io.atomix:atomix:3.0.7",
-    "atomix-cluster": "mvn:io.atomix:atomix-cluster:3.0.7",
-    "atomix-gossip": "mvn:io.atomix:atomix-gossip:3.0.7",
-    "atomix-primary-backup": "mvn:io.atomix:atomix-primary-backup:3.0.7",
-    "atomix-primitive": "mvn:io.atomix:atomix-primitive:3.0.7",
-    "atomix-raft": "mvn:io.atomix:atomix-raft:3.0.7",
-    "atomix-storage": "mvn:io.atomix:atomix-storage:3.0.7",
-    "atomix-utils": "mvn:io.atomix:atomix-utils:3.0.7",
+    "atomix": "mvn:io.atomix:atomix:3.1.0-beta1",
+    "atomix-cluster": "mvn:io.atomix:atomix-cluster:3.1.0-beta1",
+    "atomix-gossip": "mvn:io.atomix:atomix-gossip:3.1.0-beta1",
+    "atomix-primary-backup": "mvn:io.atomix:atomix-primary-backup:3.1.0-beta1",
+    "atomix-primitive": "mvn:io.atomix:atomix-primitive:3.1.0-beta1",
+    "atomix-raft": "mvn:io.atomix:atomix-raft:3.1.0-beta1",
+    "atomix-storage": "mvn:io.atomix:atomix-storage:3.1.0-beta1",
+    "atomix-utils": "mvn:io.atomix:atomix-utils:3.1.0-beta1",
     "classgraph": "mvn:io.github.classgraph:classgraph:4.2.3",
     "commons-codec": "mvn:commons-codec:commons-codec:1.10",
     "commons-cli": "mvn:commons-cli:commons-cli:1.3",
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index 129a333..05a0d9a 100644
--- a/tools/build/bazel/generate_workspace.bzl
+++ b/tools/build/bazel/generate_workspace.bzl
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Tue, 6 Nov 2018 23:15:46 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Wed, 14 Nov 2018 00:05:28 GMT. Do not edit this file manually. *****
 # ***** Use onos-lib-gen *****
 
 load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -163,51 +163,51 @@
     if "atomix" not in native.existing_rules():
         java_import_external(
             name = "atomix",
-            jar_sha256 = "4d6c72efa8e42908dbb3e6594fde5f5aef7a7c5c981da67a624ba2cbf2959b71",
+            jar_sha256 = "1476cc7c56ad7af112c8c6abeb49c354267a92a2112db9eb7827a619058906fe",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix/3.0.7/atomix-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix/3.1.0-beta1/atomix-3.1.0-beta1.jar"],        )
     if "atomix_cluster" not in native.existing_rules():
         java_import_external(
             name = "atomix_cluster",
-            jar_sha256 = "2415ca61a697593eaacf7afb5884b999fdd77600ba21b5edda5a3af50a8fcb10",
+            jar_sha256 = "b4ef338207dad63641e44f6625c8ac82c0b6226e4d3fa4abbe2baf1b64e450a6",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-cluster/3.0.7/atomix-cluster-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-cluster/3.1.0-beta1/atomix-cluster-3.1.0-beta1.jar"],        )
     if "atomix_gossip" not in native.existing_rules():
         java_import_external(
             name = "atomix_gossip",
-            jar_sha256 = "ebc82fe9dc396ab03c7dd8e8db1507b90238d1d426c585390ea5fcc0696675fd",
+            jar_sha256 = "5f81596b8f2e69d0f1b0435fd19184fb7bc32cb26e71a85f19d07cbb54d9b47b",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-gossip/3.0.7/atomix-gossip-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-gossip/3.1.0-beta1/atomix-gossip-3.1.0-beta1.jar"],        )
     if "atomix_primary_backup" not in native.existing_rules():
         java_import_external(
             name = "atomix_primary_backup",
-            jar_sha256 = "0205ffef779bcb55144355679a34f1adeba6644f8949bed0cd8f80ffb48aa014",
+            jar_sha256 = "9c1968ec494e6e3681d2e9778efd9a52a181294480562101416e1adf0efa0577",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-primary-backup/3.0.7/atomix-primary-backup-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-primary-backup/3.1.0-beta1/atomix-primary-backup-3.1.0-beta1.jar"],        )
     if "atomix_primitive" not in native.existing_rules():
         java_import_external(
             name = "atomix_primitive",
-            jar_sha256 = "8f37e8e73c168e48b7fd45c40514b447eb319a78bdb0a3af5520d0546b9551f1",
+            jar_sha256 = "bf7aaef9da2e84ae8ec9e56519eafcda8dfb2d11e34d2f21cb7c998ccea0241d",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-primitive/3.0.7/atomix-primitive-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-primitive/3.1.0-beta1/atomix-primitive-3.1.0-beta1.jar"],        )
     if "atomix_raft" not in native.existing_rules():
         java_import_external(
             name = "atomix_raft",
-            jar_sha256 = "76c3d624e4f384cb9bc43430f5a57fca4eb7b9ec1394a67020b5a5bb7c0f1988",
+            jar_sha256 = "f1ef53faf59f4b8f2c61b9c7b2752905c39ed42fa703c9124d05fff049df69d6",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-raft/3.0.7/atomix-raft-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-raft/3.1.0-beta1/atomix-raft-3.1.0-beta1.jar"],        )
     if "atomix_storage" not in native.existing_rules():
         java_import_external(
             name = "atomix_storage",
-            jar_sha256 = "f190f17969c4c31fee50af99034c6a569505a7d7afd3b034661373d455377dd6",
+            jar_sha256 = "a66d596c30edbf1e7daa57e4d77443cb564c9976135efc3a1ae7cddf203984c8",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-storage/3.0.7/atomix-storage-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-storage/3.1.0-beta1/atomix-storage-3.1.0-beta1.jar"],        )
     if "atomix_utils" not in native.existing_rules():
         java_import_external(
             name = "atomix_utils",
-            jar_sha256 = "d13840f8bc55385167ca18637b955fd554d6b3ee0fe1c20c8ba1c87f0cc68cde",
+            jar_sha256 = "8b0f495df89b1f4dbc2290291ed6336d448f3fde3850e5880379af2c8e2814d2",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-utils/3.0.7/atomix-utils-3.0.7.jar"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/io/atomix/atomix-utils/3.1.0-beta1/atomix-utils-3.1.0-beta1.jar"],        )
     if "classgraph" not in native.existing_rules():
         java_import_external(
             name = "classgraph",
@@ -1424,14 +1424,14 @@
 artifact_map["@aopalliance_repackaged//:aopalliance_repackaged"] = "mvn:org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b42"
 artifact_map["@amqp_client//:amqp_client"] = "mvn:com.rabbitmq:amqp-client:jar:3.6.1"
 artifact_map["@asm//:asm"] = "mvn:org.ow2.asm:asm:jar:5.2"
-artifact_map["@atomix//:atomix"] = "mvn:io.atomix:atomix:jar:3.0.7"
-artifact_map["@atomix_cluster//:atomix_cluster"] = "mvn:io.atomix:atomix-cluster:jar:3.0.7"
-artifact_map["@atomix_gossip//:atomix_gossip"] = "mvn:io.atomix:atomix-gossip:jar:3.0.7"
-artifact_map["@atomix_primary_backup//:atomix_primary_backup"] = "mvn:io.atomix:atomix-primary-backup:jar:3.0.7"
-artifact_map["@atomix_primitive//:atomix_primitive"] = "mvn:io.atomix:atomix-primitive:jar:3.0.7"
-artifact_map["@atomix_raft//:atomix_raft"] = "mvn:io.atomix:atomix-raft:jar:3.0.7"
-artifact_map["@atomix_storage//:atomix_storage"] = "mvn:io.atomix:atomix-storage:jar:3.0.7"
-artifact_map["@atomix_utils//:atomix_utils"] = "mvn:io.atomix:atomix-utils:jar:3.0.7"
+artifact_map["@atomix//:atomix"] = "mvn:io.atomix:atomix:jar:3.1.0-beta1"
+artifact_map["@atomix_cluster//:atomix_cluster"] = "mvn:io.atomix:atomix-cluster:jar:3.1.0-beta1"
+artifact_map["@atomix_gossip//:atomix_gossip"] = "mvn:io.atomix:atomix-gossip:jar:3.1.0-beta1"
+artifact_map["@atomix_primary_backup//:atomix_primary_backup"] = "mvn:io.atomix:atomix-primary-backup:jar:3.1.0-beta1"
+artifact_map["@atomix_primitive//:atomix_primitive"] = "mvn:io.atomix:atomix-primitive:jar:3.1.0-beta1"
+artifact_map["@atomix_raft//:atomix_raft"] = "mvn:io.atomix:atomix-raft:jar:3.1.0-beta1"
+artifact_map["@atomix_storage//:atomix_storage"] = "mvn:io.atomix:atomix-storage:jar:3.1.0-beta1"
+artifact_map["@atomix_utils//:atomix_utils"] = "mvn:io.atomix:atomix-utils:jar:3.1.0-beta1"
 artifact_map["@classgraph//:classgraph"] = "mvn:io.github.classgraph:classgraph:jar:4.2.3"
 artifact_map["@commons_codec//:commons_codec"] = "mvn:commons-codec:commons-codec:jar:1.10"
 artifact_map["@commons_cli//:commons_cli"] = "mvn:commons-cli:commons-cli:jar:1.3"
diff --git a/tools/test/bin/atomix-push-bits b/tools/test/bin/atomix-push-bits
index f50eec3..58671dc 100755
--- a/tools/test/bin/atomix-push-bits
+++ b/tools/test/bin/atomix-push-bits
@@ -26,7 +26,7 @@
 
 . $ONOS_ROOT/tools/build/envDefaults
 
-ATOMIX_VERSION=${ATOMIX_VERSION:-3.0.7}
+ATOMIX_VERSION=${ATOMIX_VERSION:-3.1.0-beta1}
 ATOMIX_MAVEN=~/.m2/repository/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz
 ATOMIX_LOCAL=/tmp/atomix-$ATOMIX_VERSION.tar.gz
 ATOMIX_REMOTE=https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz
diff --git a/tools/test/bin/onos-check-nodes b/tools/test/bin/onos-check-nodes
index 7733c27..0c48a6a 100755
--- a/tools/test/bin/onos-check-nodes
+++ b/tools/test/bin/onos-check-nodes
@@ -6,15 +6,18 @@
 aux=/tmp/stc/stc-$$.log
 trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT
 
-onos ${1:-$OCI} "onos:nodes" > $aux
-cat $aux
+for attempt in {1..5}; do
+    onos ${1:-$OCI} "onos:nodes" > $aux
+    cat $aux
 
-# Normalize the nodes
-cut -d= -f3 $aux | cut -d: -f1 | sort > $aux.1
+    # Normalize the nodes
+    cut -d= -f3 $aux | cut -d: -f1 | sort > $aux.1
 
-# Normalize the expected nodes
-nodes=${2:-$ONOS_INSTANCES}
-(for node in $nodes; do echo $node; done) | sort > $aux.2
+    # Normalize the expected nodes
+    nodes=${2:-$ONOS_INSTANCES}
+    (for node in $nodes; do echo $node; done) | sort > $aux.2
 
-# Check for differences
-diff $aux.1 $aux.2
+    # Check for differences
+    diff $aux.1 $aux.2 && exit 0
+    sleep 1
+done
\ No newline at end of file