You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/11/08 03:11:58 UTC
[james-project] 11/36: JAMES-2904 ClusterBuild should be turned
into ClusterFactory
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit b48dc9715eaafb681aa4093e7fe60ff5c4dae03a
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Oct 2 12:29:22 2019 +0700
JAMES-2904 ClusterBuild should be turned into ClusterFactory
Two part of James code were handling default values: the ClusterConfiguration
and the ClusterBuilder.
This made adding new options complicated.
---
.../backends/cassandra/init/ClusterBuilder.java | 178 ---------------------
.../backends/cassandra/init/ClusterFactory.java | 87 ++++++++++
.../init/ClusterWithKeyspaceCreatedFactory.java | 36 -----
.../cassandra/init/ResilientClusterProvider.java | 13 +-
.../init/configuration/ClusterConfiguration.java | 15 +-
.../james/backends/cassandra/CassandraCluster.java | 9 +-
.../james/backends/cassandra/DockerCassandra.java | 16 +-
...terBuilderTest.java => ClusterFactoryTest.java} | 9 +-
.../SessionWithInitializedTablesFactoryTest.java | 8 +-
src/site/xdoc/server/config-cassandra.xml | 4 +-
10 files changed, 118 insertions(+), 257 deletions(-)
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
deleted file mode 100644
index e41c6d6..0000000
--- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterBuilder.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you 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.apache.james.backends.cassandra.init;
-
-import java.util.Collection;
-import java.util.Optional;
-
-import org.apache.james.backends.cassandra.init.configuration.QueryLoggerConfiguration;
-import org.apache.james.util.Host;
-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;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-
-public class ClusterBuilder {
- private static final Logger LOGGER = LoggerFactory.getLogger(ClusterBuilder.class);
- private static final String DEFAULT_CLUSTER_IP = "localhost";
- public static final int DEFAULT_CASSANDRA_PORT = 9042;
-
- public static ClusterBuilder builder() {
- return new ClusterBuilder();
- }
-
- private Optional<String> username;
- private Optional<String> password;
-
- private Optional<Collection<Host>> servers;
-
- private Optional<QueryLoggerConfiguration> queryLogger;
- private Optional<Integer> readTimeoutMillis;
- private Optional<Integer> connectTimeoutMillis;
- private Optional<PoolingOptions> poolingOptions;
- private Optional<Boolean> useSsl;
-
- private ClusterBuilder() {
- username = Optional.empty();
- password = Optional.empty();
- useSsl = Optional.empty();
-
- servers = Optional.empty();
-
- queryLogger = Optional.empty();
- readTimeoutMillis = Optional.empty();
- connectTimeoutMillis = Optional.empty();
- poolingOptions = Optional.empty();
- }
-
- public ClusterBuilder username(String username) {
- return username(Optional.of(username));
- }
-
- public ClusterBuilder password(String password) {
- return password(Optional.of(password));
- }
-
- public ClusterBuilder username(Optional<String> username) {
- this.username = username;
-
- return this;
- }
-
- public ClusterBuilder password(Optional<String> password) {
- this.password = password;
-
- return this;
- }
-
- public ClusterBuilder useSsl(boolean useSsl) {
- this.useSsl = Optional.of(useSsl);
-
- return this;
- }
-
- public ClusterBuilder poolingOptions(PoolingOptions poolingOptions) {
- this.poolingOptions = Optional.of(poolingOptions);
- return this;
- }
-
- public ClusterBuilder poolingOptions(Optional<PoolingOptions> poolingOptions) {
- this.poolingOptions = poolingOptions;
- return this;
- }
-
- public ClusterBuilder servers(Host... servers) {
- this.servers = Optional.of(ImmutableList.copyOf(servers));
-
- return this;
- }
-
- public ClusterBuilder servers(Collection<Host> servers) {
- this.servers = Optional.of(servers);
-
- return this;
- }
-
- public ClusterBuilder queryLoggerConfiguration(QueryLoggerConfiguration queryLogger) {
- this.queryLogger = Optional.of(queryLogger);
-
- return this;
- }
-
- public ClusterBuilder readTimeoutMillis(int readTimeoutMillis) {
- this.readTimeoutMillis = Optional.of(readTimeoutMillis);
- return this;
- }
-
- public ClusterBuilder connectTimeoutMillis(int connectTimeoutMillis) {
- this.connectTimeoutMillis = Optional.of(connectTimeoutMillis);
- return this;
- }
-
- public Cluster build() {
- Preconditions.checkState(username.isPresent() == password.isPresent(), "If you specify username, you must specify password");
-
- Cluster.Builder clusterBuilder = Cluster.builder()
- .withoutJMXReporting();
- getServers().forEach(server -> clusterBuilder
- .addContactPoint(server.getHostName())
- .withPort(server.getPort()));
-
- username.map(username ->
- password.map(password ->
- clusterBuilder.withCredentials(username, password)));
-
- clusterBuilder.withQueryOptions(queryOptions());
-
- SocketOptions socketOptions = new SocketOptions();
- readTimeoutMillis.ifPresent(socketOptions::setReadTimeoutMillis);
- connectTimeoutMillis.ifPresent(socketOptions::setConnectTimeoutMillis);
- clusterBuilder.withSocketOptions(socketOptions);
- poolingOptions.ifPresent(clusterBuilder::withPoolingOptions);
-
- useSsl.filter(b -> b).ifPresent(any -> clusterBuilder.withSSL());
-
- Cluster cluster = clusterBuilder.build();
- try {
- queryLogger.map(queryLoggerConfiguration ->
- cluster.register(queryLoggerConfiguration.getQueryLogger()));
- return cluster;
- } catch (Exception e) {
- cluster.close();
- throw e;
- }
- }
-
- private QueryOptions queryOptions() {
- return new QueryOptions()
- .setConsistencyLevel(ConsistencyLevel.QUORUM);
- }
-
- private Collection<Host> getServers() {
- return servers.orElse(ImmutableList.of(
- Host.from(DEFAULT_CLUSTER_IP, DEFAULT_CASSANDRA_PORT)));
- }
-}
diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterFactory.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterFactory.java
new file mode 100644
index 0000000..eafd622
--- /dev/null
+++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterFactory.java
@@ -0,0 +1,87 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you 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.apache.james.backends.cassandra.init;
+
+import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.QueryOptions;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.SocketOptions;
+import com.google.common.base.Preconditions;
+
+public class ClusterFactory {
+ public static Cluster create(ClusterConfiguration configuration) {
+ Preconditions.checkState(configuration.getUsername().isPresent() == configuration.getPassword().isPresent(), "If you specify username, you must specify password");
+
+ Cluster.Builder clusterBuilder = Cluster.builder()
+ .withoutJMXReporting();
+ configuration.getHosts().forEach(server -> clusterBuilder
+ .addContactPoint(server.getHostName())
+ .withPort(server.getPort()));
+
+ configuration.getUsername().ifPresent(username ->
+ configuration.getPassword().ifPresent(password ->
+ clusterBuilder.withCredentials(username, password)));
+
+ clusterBuilder.withQueryOptions(queryOptions());
+
+ SocketOptions socketOptions = new SocketOptions();
+ socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis());
+ socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis());
+ clusterBuilder.withSocketOptions(socketOptions);
+ configuration.getPoolingOptions().ifPresent(clusterBuilder::withPoolingOptions);
+
+ if (configuration.useSsl()) {
+ clusterBuilder.withSSL();
+ }
+
+ Cluster cluster = clusterBuilder.build();
+ try {
+ configuration.getQueryLoggerConfiguration().map(queryLoggerConfiguration ->
+ cluster.register(queryLoggerConfiguration.getQueryLogger()));
+ return cluster;
+ } catch (Exception e) {
+ cluster.close();
+ throw e;
+ }
+ }
+
+ public static Cluster createWithKeyspace(ClusterConfiguration clusterConfiguration) {
+ Cluster cluster = create(clusterConfiguration);
+ createKeyspace(clusterConfiguration, cluster);
+ return cluster;
+ }
+
+ public static void createKeyspace(ClusterConfiguration clusterConfiguration, Cluster cluster) {
+ try (Session session = cluster.connect()) {
+ session.execute("CREATE KEYSPACE IF NOT EXISTS " + clusterConfiguration.getKeyspace()
+ + " WITH replication = {'class':'SimpleStrategy', 'replication_factor':" + clusterConfiguration.getReplicationFactor() + "}"
+ + " AND durable_writes = " + clusterConfiguration.isDurableWrites()
+ + ";");
+ }
+ }
+
+ private static QueryOptions queryOptions() {
+ return new QueryOptions()
+ .setConsistencyLevel(ConsistencyLevel.QUORUM);
+ }
+}
diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterWithKeyspaceCreatedFactory.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterWithKeyspaceCreatedFactory.java
deleted file mode 100644
index a93ca15..0000000
--- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ClusterWithKeyspaceCreatedFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you 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.apache.james.backends.cassandra.init;
-
-import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Session;
-
-public class ClusterWithKeyspaceCreatedFactory {
- public static void createKeyspace(Cluster cluster, ClusterConfiguration clusterConfiguration) {
- try (Session session = cluster.connect()) {
- session.execute("CREATE KEYSPACE IF NOT EXISTS " + clusterConfiguration.getKeyspace()
- + " WITH replication = {'class':'SimpleStrategy', 'replication_factor':" + clusterConfiguration.getReplicationFactor() + "}"
- + " AND durable_writes = " + clusterConfiguration.isDurableWrites()
- + ";");
- }
- }
-}
diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ResilientClusterProvider.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ResilientClusterProvider.java
index 523a925..743b887 100644
--- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ResilientClusterProvider.java
+++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/ResilientClusterProvider.java
@@ -60,18 +60,9 @@ public class ResilientClusterProvider implements Provider<Cluster> {
ImmutableList.copyOf(configuration.getHosts()).toString());
return () -> {
- Cluster cluster = ClusterBuilder.builder()
- .servers(configuration.getHosts())
- .username(configuration.getUsername())
- .password(configuration.getPassword())
- .useSsl(configuration.isUseSsl())
- .poolingOptions(configuration.getPoolingOptions())
- .queryLoggerConfiguration(configuration.getQueryLoggerConfiguration())
- .readTimeoutMillis(configuration.getReadTimeoutMillis())
- .connectTimeoutMillis(configuration.getConnectTimeoutMillis())
- .build();
+ Cluster cluster = ClusterFactory.create(configuration);
try {
- ClusterWithKeyspaceCreatedFactory.createKeyspace(cluster, configuration);
+ ClusterFactory.createKeyspace(configuration, cluster);
return cluster;
} catch (Exception e) {
cluster.close();
diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/configuration/ClusterConfiguration.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/configuration/ClusterConfiguration.java
index 68958f4..82c4afb 100644
--- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/configuration/ClusterConfiguration.java
+++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/configuration/ClusterConfiguration.java
@@ -26,7 +26,6 @@ import java.util.Objects;
import java.util.Optional;
import org.apache.commons.configuration2.Configuration;
-import org.apache.james.backends.cassandra.init.ClusterBuilder;
import org.apache.james.util.Host;
import com.datastax.driver.core.HostDistance;
@@ -190,7 +189,7 @@ public class ClusterConfiguration {
replicationFactor.orElse(DEFAULT_REPLICATION_FACTOR),
minDelay.orElse(DEFAULT_CONNECTION_MIN_DELAY),
maxRetry.orElse(DEFAULT_CONNECTION_MAX_RETRIES),
- queryLoggerConfiguration.orElse(QueryLoggerConfiguration.DEFAULT),
+ queryLoggerConfiguration,
poolingOptions,
readTimeoutMillis.orElse(DEFAULT_READ_TIMEOUT_MILLIS),
connectTimeoutMillis.orElse(DEFAULT_CONNECT_TIMEOUT_MILLIS),
@@ -218,6 +217,8 @@ public class ClusterConfiguration {
private static final int DEFAULT_CONNECTION_MIN_DELAY = 5000;
private static final int DEFAULT_READ_TIMEOUT_MILLIS = 5000;
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 5000;
+ public static final int DEFAULT_CASSANDRA_PORT = 9042;
+
private static final boolean DEFAULT_SSL = false;
public static Builder builder() {
@@ -245,7 +246,7 @@ public class ClusterConfiguration {
String[] ipAndPorts = configuration.getStringArray(CASSANDRA_NODES);
return Arrays.stream(ipAndPorts)
- .map(string -> Host.parseConfString(string, ClusterBuilder.DEFAULT_CASSANDRA_PORT))
+ .map(string -> Host.parseConfString(string, DEFAULT_CASSANDRA_PORT))
.collect(Guavate.toImmutableList());
}
@@ -285,7 +286,7 @@ public class ClusterConfiguration {
private final int replicationFactor;
private final int minDelay;
private final int maxRetry;
- private final QueryLoggerConfiguration queryLoggerConfiguration;
+ private final Optional<QueryLoggerConfiguration> queryLoggerConfiguration;
private final Optional<PoolingOptions> poolingOptions;
private final int readTimeoutMillis;
private final int connectTimeoutMillis;
@@ -295,7 +296,7 @@ public class ClusterConfiguration {
private final boolean durableWrites;
public ClusterConfiguration(List<Host> hosts, String keyspace, int replicationFactor, int minDelay, int maxRetry,
- QueryLoggerConfiguration queryLoggerConfiguration, Optional<PoolingOptions> poolingOptions,
+ Optional<QueryLoggerConfiguration> queryLoggerConfiguration, Optional<PoolingOptions> poolingOptions,
int readTimeoutMillis, int connectTimeoutMillis, boolean useSsl, Optional<String> username,
Optional<String> password, boolean durableWrites) {
this.hosts = hosts;
@@ -337,7 +338,7 @@ public class ClusterConfiguration {
return maxRetry;
}
- public QueryLoggerConfiguration getQueryLoggerConfiguration() {
+ public Optional<QueryLoggerConfiguration> getQueryLoggerConfiguration() {
return queryLoggerConfiguration;
}
@@ -353,7 +354,7 @@ public class ClusterConfiguration {
return connectTimeoutMillis;
}
- public boolean isUseSsl() {
+ public boolean useSsl() {
return useSsl;
}
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java
index 9a6d412..50c6099 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java
@@ -23,8 +23,7 @@ import java.util.Optional;
import org.apache.james.backends.cassandra.components.CassandraModule;
import org.apache.james.backends.cassandra.init.CassandraTableManager;
import org.apache.james.backends.cassandra.init.CassandraTypesProvider;
-import org.apache.james.backends.cassandra.init.ClusterBuilder;
-import org.apache.james.backends.cassandra.init.ClusterWithKeyspaceCreatedFactory;
+import org.apache.james.backends.cassandra.init.ClusterFactory;
import org.apache.james.backends.cassandra.init.SessionWithInitializedTablesFactory;
import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration;
import org.apache.james.util.Host;
@@ -57,16 +56,12 @@ public final class CassandraCluster implements AutoCloseable {
private CassandraCluster(CassandraModule module, Host host) throws RuntimeException {
this.module = module;
try {
- cluster = ClusterBuilder.builder()
- .servers(host)
- .build();
ClusterConfiguration clusterConfiguration = ClusterConfiguration.builder()
.host(host)
.keyspace(KEYSPACE)
- .replicationFactor(1)
.disableDurableWrites()
.build();
- ClusterWithKeyspaceCreatedFactory.createKeyspace(cluster, clusterConfiguration);
+ cluster = ClusterFactory.createWithKeyspace(clusterConfiguration);
session = new SessionWithInitializedTablesFactory(clusterConfiguration, cluster, module).get();
typesProvider = new CassandraTypesProvider(module, session);
} catch (Exception exception) {
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
index 58a9a08..99dce87 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
@@ -19,8 +19,6 @@
package org.apache.james.backends.cassandra;
-import java.util.function.Function;
-
import org.apache.james.util.Host;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,7 +27,6 @@ import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.images.builder.dockerfile.DockerfileBuilder;
-import org.testcontainers.images.builder.dockerfile.traits.RunStatementTrait;
import com.github.dockerjava.api.DockerClient;
import com.google.common.collect.ImmutableMap;
@@ -38,6 +35,13 @@ public class DockerCassandra {
private static final Logger logger = LoggerFactory.getLogger(DockerCassandra.class);
+ @FunctionalInterface
+ interface AdditionalDockerFileStep {
+ AdditionalDockerFileStep IDENTITY = builder -> builder;
+
+ DockerfileBuilder applyStep(DockerfileBuilder builder);
+ }
+
private static final int CASSANDRA_PORT = 9042;
private static final int CASSANDRA_MEMORY = 650;
@@ -49,16 +53,16 @@ public class DockerCassandra {
@SuppressWarnings("resource")
public DockerCassandra() {
- this("cassandra_3_11_3", Function.identity());
+ this("cassandra_3_11_3", AdditionalDockerFileStep.IDENTITY);
}
- public DockerCassandra(String imageName, Function<DockerfileBuilder, DockerfileBuilder> additionalSteps) {
+ public DockerCassandra(String imageName, AdditionalDockerFileStep additionalSteps) {
client = DockerClientFactory.instance().client();
boolean doNotDeleteImageAfterUsage = false;
cassandraContainer = new GenericContainer<>(
new ImageFromDockerfile(imageName,doNotDeleteImageAfterUsage)
.withDockerfileFromBuilder(builder ->
- additionalSteps.apply(builder
+ additionalSteps.applyStep(builder
.from("cassandra:3.11.3")
.env("ENV CASSANDRA_CONFIG", "/etc/cassandra")
.run("echo \"-Xms" + CASSANDRA_MEMORY + "M\" >> " + JVM_OPTIONS)
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/ClusterFactoryTest.java
similarity index 85%
rename from backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterBuilderTest.java
rename to backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/ClusterFactoryTest.java
index 4ad3db7..ce45523 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/ClusterFactoryTest.java
@@ -20,19 +20,20 @@ package org.apache.james.backends.cassandra.init;
import static org.assertj.core.api.Assertions.assertThat;
+import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration;
import org.apache.james.util.Host;
import org.junit.jupiter.api.Test;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ConsistencyLevel;
-class ClusterBuilderTest {
+class ClusterFactoryTest {
@Test
void consistencyLevelShouldBeEqualToQuorum() {
- Cluster cluster = ClusterBuilder.builder()
- .servers(Host.from("localhost", ClusterBuilder.DEFAULT_CASSANDRA_PORT))
- .build();
+ Cluster cluster = ClusterFactory.create(ClusterConfiguration.builder()
+ .host(Host.from("localhost", ClusterConfiguration.DEFAULT_CASSANDRA_PORT))
+ .build());
ConsistencyLevel consistencyLevel = cluster.getConfiguration()
.getQueryOptions()
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
index ea6fd49..f3e6dd9 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
@@ -121,17 +121,13 @@ class SessionWithInitializedTablesFactoryTest {
}
private static Supplier<Session> createSession(DockerCassandraExtension.DockerCassandra cassandraServer) {
- Host host = cassandraServer.getHost();
- Cluster cluster = ClusterBuilder.builder()
- .servers(host)
- .build();
ClusterConfiguration clusterConfiguration = ClusterConfiguration.builder()
- .host(host)
+ .host(cassandraServer.getHost())
.keyspace(KEYSPACE)
.replicationFactor(1)
.disableDurableWrites()
.build();
- ClusterWithKeyspaceCreatedFactory.createKeyspace(cluster, clusterConfiguration);
+ Cluster cluster = ClusterFactory.createWithKeyspace(clusterConfiguration);
return () -> new SessionWithInitializedTablesFactory(
clusterConfiguration,
cluster,
diff --git a/src/site/xdoc/server/config-cassandra.xml b/src/site/xdoc/server/config-cassandra.xml
index 3511c87..ad9a400 100644
--- a/src/site/xdoc/server/config-cassandra.xml
+++ b/src/site/xdoc/server/config-cassandra.xml
@@ -47,8 +47,8 @@
required if <strong>cassandra.user</strong> is supplied</dd>
<dt><strong>cassandra.ssl</strong></dt>
- <dd>Wether SSL should be enabled on the communications with Cassandra cluster. Optional, defaults to false.<br/>
- The keystore used for trusting SLL server socket can be set via JSSE system properties as explained on
+ <dd>Whether SSL should be enabled on the communications with Cassandra cluster. Optional, defaults to false.<br/>
+ The keystore used for trusting SSL server socket can be set via JSSE system properties as explained on
<a href="https://docs.datastax.com/en/developer/java-driver/3.7/manual/ssl/">Cassandra driver manual</a>.</dd>
<dt><strong>cassandra.replication.factor</strong></dt>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org