Upgrade to Atomix 2.0.14

Change-Id: I919aa1337a850f7dc25621d6a990a7d8b4d2ee6f
diff --git a/core/store/primitives/pom.xml b/core/store/primitives/pom.xml
index 453e592..1ef96427 100644
--- a/core/store/primitives/pom.xml
+++ b/core/store/primitives/pom.xml
@@ -70,7 +70,7 @@
         <dependency>
             <groupId>io.atomix</groupId>
             <artifactId>atomix</artifactId>
-            <version>2.0.13</version>
+            <version>2.0.14</version>
         </dependency>
 
         <dependency>
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java
index a768a4f..999e694 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java
@@ -63,13 +63,15 @@
  */
 public class StoragePartitionClient implements DistributedPrimitiveCreator, Managed<StoragePartitionClient> {
 
+    private static final int MAX_RETRIES = 8;
+    private static final String ATOMIC_VALUES_CONSISTENT_MAP_NAME = "onos-atomic-values";
+
     private final Logger log = getLogger(getClass());
 
     private final StoragePartition partition;
     private final MemberId localMemberId;
     private final RaftClientProtocol protocol;
     private RaftClient client;
-    private static final String ATOMIC_VALUES_CONSISTENT_MAP_NAME = "onos-atomic-values";
     private final com.google.common.base.Supplier<AsyncConsistentMap<String, byte[]>> onosAtomicValuesMap =
             Suppliers.memoize(() -> newAsyncConsistentMap(ATOMIC_VALUES_CONSISTENT_MAP_NAME,
                                                           Serializer.using(KryoNamespaces.BASIC)));
@@ -110,7 +112,7 @@
                         .withReadConsistency(ReadConsistency.SEQUENTIAL)
                         .withCommunicationStrategy(CommunicationStrategy.ANY)
                         .withTimeout(Duration.ofSeconds(30))
-                        .withMaxRetries(5)
+                        .withMaxRetries(MAX_RETRIES)
                         .build()
                         .open()
                         .join());
@@ -135,7 +137,7 @@
                         .withReadConsistency(ReadConsistency.SEQUENTIAL)
                         .withCommunicationStrategy(CommunicationStrategy.ANY)
                         .withTimeout(Duration.ofSeconds(30))
-                        .withMaxRetries(5)
+                        .withMaxRetries(MAX_RETRIES)
                         .build()
                         .open()
                         .join());
@@ -159,7 +161,7 @@
                         .withReadConsistency(ReadConsistency.SEQUENTIAL)
                         .withCommunicationStrategy(CommunicationStrategy.ANY)
                         .withTimeout(Duration.ofSeconds(30))
-                        .withMaxRetries(5)
+                        .withMaxRetries(MAX_RETRIES)
                         .build()
                         .open()
                         .join());
@@ -189,7 +191,7 @@
                 .withReadConsistency(ReadConsistency.LINEARIZABLE_LEASE)
                 .withCommunicationStrategy(CommunicationStrategy.LEADER)
                 .withTimeout(Duration.ofSeconds(30))
-                .withMaxRetries(5)
+                .withMaxRetries(MAX_RETRIES)
                 .build()
                 .open()
                 .join());
@@ -211,7 +213,7 @@
                 .withReadConsistency(ReadConsistency.LINEARIZABLE_LEASE)
                 .withCommunicationStrategy(CommunicationStrategy.LEADER)
                 .withTimeout(Duration.ofSeconds(30))
-                .withMaxRetries(5)
+                .withMaxRetries(MAX_RETRIES)
                 .build()
                 .open()
                 .join());
@@ -235,7 +237,7 @@
                 .withReadConsistency(ReadConsistency.LINEARIZABLE_LEASE)
                 .withCommunicationStrategy(CommunicationStrategy.LEADER)
                 .withTimeout(Duration.ofSeconds(5))
-                .withMaxRetries(5)
+                .withMaxRetries(MAX_RETRIES)
                 .build()
                 .open()
                 .join());
@@ -250,7 +252,7 @@
                 .withReadConsistency(ReadConsistency.SEQUENTIAL)
                 .withCommunicationStrategy(CommunicationStrategy.ANY)
                 .withTimeout(Duration.ofSeconds(30))
-                .withMaxRetries(5)
+                .withMaxRetries(MAX_RETRIES)
                 .build()
                 .open()
                 .join());
@@ -266,7 +268,7 @@
                 .withCommunicationStrategy(CommunicationStrategy.LEADER)
                 .withMinTimeout(Duration.ofSeconds(1))
                 .withMaxTimeout(Duration.ofSeconds(5))
-                .withMaxRetries(5)
+                .withMaxRetries(MAX_RETRIES)
                 .build()
                 .open()
                 .join());
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionServer.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionServer.java
index 5e322d5..29e3f15 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionServer.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionServer.java
@@ -42,7 +42,8 @@
 
     private static final int MAX_SEGMENT_SIZE = 1024 * 1024 * 64;
     private static final long ELECTION_TIMEOUT_MILLIS = 2500;
-    private static final long HEARTBEAT_INTERVAL_MILLIS = 250;
+    private static final int ELECTION_THRESHOLD = 5;
+    private static final long HEARTBEAT_INTERVAL_MILLIS = 500;
 
     private final MemberId localMemberId;
     private final StoragePartition partition;
@@ -103,8 +104,11 @@
                 .withProtocol(protocol.get())
                 .withElectionTimeout(Duration.ofMillis(ELECTION_TIMEOUT_MILLIS))
                 .withHeartbeatInterval(Duration.ofMillis(HEARTBEAT_INTERVAL_MILLIS))
+                .withElectionThreshold(ELECTION_THRESHOLD)
                 .withStorage(RaftStorage.newBuilder()
-                        .withStorageLevel(StorageLevel.MAPPED)
+                        .withPrefix(String.format("partition-%s", partition.getId()))
+                        .withStorageLevel(StorageLevel.DISK)
+                        .withFlushOnCommit()
                         .withSerializer(new AtomixSerializerAdapter(Serializer.using(StorageNamespaces.RAFT_STORAGE)))
                         .withDirectory(dataFolder)
                         .withMaxSegmentSize(MAX_SEGMENT_SIZE)
diff --git a/features/features.xml b/features/features.xml
index 8c6149e..567eda2 100644
--- a/features/features.xml
+++ b/features/features.xml
@@ -59,7 +59,7 @@
         <bundle>mvn:com.typesafe/config/1.2.1</bundle>
         <bundle>mvn:com.googlecode.concurrent-trees/concurrent-trees/2.6.0</bundle>
         <bundle>mvn:commons-io/commons-io/2.4</bundle>
-        <bundle>mvn:io.atomix/atomix/2.0.13</bundle>
+        <bundle>mvn:io.atomix/atomix/2.0.14</bundle>
 
         <bundle>mvn:org.glassfish.jersey.core/jersey-client/2.25.1</bundle>
 
diff --git a/lib/BUCK b/lib/BUCK
index 94c9a80..2b3f1c0 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Tue, 23 Jan 2018 23:45:30 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Tue, 23 Jan 2018 23:55:27 GMT. Do not edit this file manually. *****
 # ***** Use onos-lib-gen *****
 
 pass_thru_pom(
@@ -178,10 +178,10 @@
 
 remote_jar (
   name = 'atomix',
-  out = 'atomix-2.0.13.jar',
-  url = 'mvn:io.atomix:atomix:jar:2.0.13',
-  sha1 = '3f865c961cb5a15131734b5733fe1ae56e181103',
-  maven_coords = 'io.atomix:atomix:2.0.13',
+  out = 'atomix-2.0.14.jar',
+  url = 'mvn:io.atomix:atomix:jar:2.0.14',
+  sha1 = 'b2deb5601c8385c0eaabc952a19241c772f0984c',
+  maven_coords = 'io.atomix:atomix:2.0.14',
   visibility = [ 'PUBLIC' ],
 )
 
diff --git a/lib/deps.json b/lib/deps.json
index c016f3a..ccd562d 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -112,7 +112,7 @@
     "aopalliance-repackaged": "mvn:org.glassfish.hk2.external:aopalliance-repackaged:2.5.0-b32",
     "amqp-client": "mvn:com.rabbitmq:amqp-client:jar:3.6.1",
     "asm": "mvn:org.ow2.asm:asm:5.0.4",
-    "atomix": "mvn:io.atomix:atomix:2.0.13",
+    "atomix": "mvn:io.atomix:atomix:2.0.14",
     "commons-codec": "mvn:commons-codec:commons-codec:1.10",
     "commons-collections": "mvn:commons-collections:commons-collections:3.2.2",
     "commons-configuration": "mvn:commons-configuration:commons-configuration:1.10",