[prev in list] [next in list] [prev in thread] [next in thread]
List: james-dev
Subject: [2/3] james-project git commit: JAMES-2549 Set default consistency level to Quorum
From: aduprat () apache ! org
Date: 2018-09-18 11:39:56
Message-ID: 332080b2e1c74843a8fad62b74171582 () git ! apache ! org
[Download RAW message or body]
JAMES-2549 Set default consistency level to Quorum
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0f08a463
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0f08a463
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0f08a463
Branch: refs/heads/master
Commit: 0f08a463a9a7521bcd58dc4001c9b6489cc37599
Parents: da4a8d2
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Mon Sep 17 17:25:48 2018 +0200
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Sep 17 17:25:48 2018 +0200
----------------------------------------------------------------------
.../backends/cassandra/init/ClusterBuilder.java | 16 ++++++++++++----
.../backends/cassandra/init/ClusterBuilderTest.java | 15 +++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/0f08a463/backends-common/cas \
sandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java \
b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java
index 3b3c721..851b302 100644
--- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java
+++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.PoolingOptions;
import com.datastax.driver.core.QueryOptions;
import com.datastax.driver.core.SocketOptions;
@@ -164,10 +165,7 @@ public class ClusterBuilder {
password.map(password ->
clusterBuilder.withCredentials(username, password)));
- getRefreshSchemaIntervalMillis().map(refreshSchemaIntervalMillis ->
- clusterBuilder.withQueryOptions(
- new QueryOptions()
- .setRefreshSchemaIntervalMillis(refreshSchemaIntervalMillis)));
+ clusterBuilder.withQueryOptions(queryOptions());
SocketOptions socketOptions = new SocketOptions();
readTimeoutMillis.ifPresent(socketOptions::setReadTimeoutMillis);
@@ -186,6 +184,16 @@ public class ClusterBuilder {
}
}
+ private QueryOptions queryOptions() {
+ QueryOptions queryOptions = new QueryOptions()
+ .setConsistencyLevel(ConsistencyLevel.QUORUM);
+
+ getRefreshSchemaIntervalMillis().ifPresent(refreshSchemaIntervalMillis ->
+ \
queryOptions.setRefreshSchemaIntervalMillis(refreshSchemaIntervalMillis)); +
+ return queryOptions;
+ }
+
private Optional<Integer> getRefreshSchemaIntervalMillis() {
return refreshSchemaIntervalMillis;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/0f08a463/backends-common/cas \
sandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java \
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java
index c74276e..9f081c2 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java
@@ -23,10 +23,25 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
class ClusterBuilderTest {
@Test
+ void consistencyLevelShouldBeEqualToQuorum() {
+ Cluster cluster = ClusterBuilder.builder()
+ .host("localhost")
+ .port(ClusterBuilder.DEFAULT_CASSANDRA_PORT)
+ .build();
+
+ ConsistencyLevel consistencyLevel = cluster.getConfiguration()
+ .getQueryOptions()
+ .getConsistencyLevel();
+
+ assertThat(consistencyLevel).isEqualTo(ConsistencyLevel.QUORUM);
+ }
+
+ @Test
void refreshSchemaIntervalMillisShouldReturnDefaultValueWhenNotGiven() {
Cluster cluster = ClusterBuilder.builder()
.host("localhost")
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic