From 6f953456502a058e4eb75dd8849a8a61b43b3a91 Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Wed, 15 Nov 2023 15:34:13 -0800 Subject: [PATCH] Add clusterModeEnabled to the ConnectionSettings Signed-off-by: Andrew Carbonetto --- .../main/java/javababushka/benchmarks/BenchmarkingApp.java | 2 +- .../javababushka/benchmarks/babushka/JniNettyClient.java | 4 ++-- .../javababushka/benchmarks/lettuce/LettuceAsyncClient.java | 5 ++++- .../benchmarks/lettuce/LettuceAsyncClusterClient.java | 5 ++++- .../java/javababushka/benchmarks/lettuce/LettuceClient.java | 2 +- .../java/javababushka/benchmarks/utils/Benchmarking.java | 4 +++- .../javababushka/benchmarks/utils/ConnectionSettings.java | 4 +++- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/BenchmarkingApp.java b/java/benchmarks/src/main/java/javababushka/benchmarks/BenchmarkingApp.java index 1a42a0e475..eedd0af7d7 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/BenchmarkingApp.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/BenchmarkingApp.java @@ -264,7 +264,7 @@ public RunConfiguration() { new ClientName[] { // ClientName.BABUSHKA_ASYNC, ClientName.JNI_NETTY - // ClientName.LETTUCE_ASYNC + // ClientName.LETTUCE_ASYNC }; host = "localhost"; port = 6379; diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/babushka/JniNettyClient.java b/java/benchmarks/src/main/java/javababushka/benchmarks/babushka/JniNettyClient.java index f002485273..ccf7a14606 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/babushka/JniNettyClient.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/babushka/JniNettyClient.java @@ -133,7 +133,7 @@ public String getName() { @Override public void connectToRedis() { - connectToRedis(new ConnectionSettings("localhost", 6379, false)); + connectToRedis(new ConnectionSettings("localhost", 6379, false, false)); } @Override @@ -381,7 +381,7 @@ public Future asyncConnectToRedis(ConnectionSettings connectionSetting connectionSettings.useSsl // TODO: secure or insecure TLS? ? TlsMode.SecureTls : TlsMode.NoTls) - .setClusterModeEnabled(false) + .setClusterModeEnabled(connectionSettings.clusterModeEnabled) // In millis .setResponseTimeout(250) // In millis diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClient.java b/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClient.java index 583f5e488f..c9464488c4 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClient.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClient.java @@ -20,11 +20,14 @@ public class LettuceAsyncClient implements AsyncClient { @Override public void connectToRedis() { - connectToRedis(new ConnectionSettings("localhost", 6379, false)); + connectToRedis(new ConnectionSettings("localhost", 6379, false, false)); } @Override public void connectToRedis(ConnectionSettings connectionSettings) { + assert connectionSettings.clusterModeEnabled == false + : "LettuceAsyncClient invalid with clusterModeEnabled, use LettuceAsyncClusterClient" + + " instead"; client = RedisClient.create( String.format( diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClusterClient.java b/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClusterClient.java index 84e48eb691..dc3a9342cf 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClusterClient.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceAsyncClusterClient.java @@ -18,11 +18,14 @@ public class LettuceAsyncClusterClient extends LettuceAsyncClient { @Override public void connectToRedis() { - connectToRedis(new ConnectionSettings("localhost", 6379, false)); + connectToRedis(new ConnectionSettings("localhost", 6379, false, true)); } @Override public void connectToRedis(ConnectionSettings connectionSettings) { + assert connectionSettings.clusterModeEnabled == false + : "LettuceAsyncClusterClient invalid with clusterModeEnabled disabled, use" + + " LettuceAsyncClient instead"; RedisURI uri = RedisURI.builder() .withHost(connectionSettings.host) diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceClient.java b/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceClient.java index e4e1830bda..b9215f4f78 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceClient.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/lettuce/LettuceClient.java @@ -17,7 +17,7 @@ public class LettuceClient implements SyncClient { @Override public void connectToRedis() { - connectToRedis(new ConnectionSettings("localhost", 6379, false)); + connectToRedis(new ConnectionSettings("localhost", 6379, false, false)); } @Override diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java b/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java index 1d3d842b35..cc10754c92 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java @@ -144,7 +144,9 @@ public static void testClientSetGet( List clients = new LinkedList<>(); for (int cc = 0; cc < clientCount; cc++) { Client newClient = clientCreator.get(); - newClient.connectToRedis(new ConnectionSettings(config.host, config.port, config.tls)); + newClient.connectToRedis( + new ConnectionSettings( + config.host, config.port, config.tls, config.clusterModeEnabled)); clients.add(newClient); } diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/utils/ConnectionSettings.java b/java/benchmarks/src/main/java/javababushka/benchmarks/utils/ConnectionSettings.java index 2989d8b3b3..082d696a3a 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/utils/ConnectionSettings.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/utils/ConnectionSettings.java @@ -4,10 +4,12 @@ public class ConnectionSettings { public String host; public int port; public boolean useSsl; + public boolean clusterModeEnabled; - public ConnectionSettings(String host, int port, boolean useSsl) { + public ConnectionSettings(String host, int port, boolean useSsl, boolean clusterModeEnabled) { this.host = host; this.port = port; this.useSsl = useSsl; + this.clusterModeEnabled = clusterModeEnabled; } }