From ad10c52f38f82650dddf1a97738997a1f15b0f96 Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Mon, 12 Feb 2024 21:35:00 -0800 Subject: [PATCH] Simplify ExampleApp Signed-off-by: Andrew Carbonetto --- .../main/java/glide/examples/ExamplesApp.java | 53 +++++-------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/java/examples/src/main/java/glide/examples/ExamplesApp.java b/java/examples/src/main/java/glide/examples/ExamplesApp.java index 4110fc1e0e..9df91d4dbd 100644 --- a/java/examples/src/main/java/glide/examples/ExamplesApp.java +++ b/java/examples/src/main/java/glide/examples/ExamplesApp.java @@ -2,9 +2,8 @@ package glide.examples; import glide.api.RedisClient; -import glide.api.RedisClusterClient; -import glide.examples.clients.GlideClient; -import glide.examples.clients.GlideClusterClient; +import glide.api.models.configuration.NodeAddress; +import glide.api.models.configuration.RedisClientConfiguration; import java.util.concurrent.ExecutionException; public class ExamplesApp { @@ -12,16 +11,21 @@ public class ExamplesApp { // main application entrypoint public static void main(String[] args) { runGlideExamples(); - - // uncomment to test against a Redis instance with cluster-mode enabled - // runGlideClusterModeExamples(); } private static void runGlideExamples() { - ConnectionSettings settings = new ConnectionSettings("localhost", 6379, false, false); + String host = "localhost"; + Integer port = 6379; + boolean useSsl = false; + + RedisClientConfiguration config = + RedisClientConfiguration.builder() + .address(NodeAddress.builder().host(host).port(port).build()) + .useTLS(useSsl) + .build(); try { - RedisClient client = GlideClient.connectToGlide(settings); + RedisClient client = RedisClient.CreateClient(config).get(); System.out.println("Glide PING: " + client.ping().get()); System.out.println("Glide PING: " + client.ping("found you").get()); @@ -31,37 +35,4 @@ private static void runGlideExamples() { e.printStackTrace(); } } - - private static void runGlideClusterModeExamples() { - ConnectionSettings settings = new ConnectionSettings("localhost", 8000, false, true); - - try { - RedisClusterClient client = GlideClusterClient.connectToGlide(settings); - - System.out.println("Glide PING: "); - System.out.println(">>>> " + client.ping().get()); - - System.out.println("Glide PING(msg): "); - System.out.println(">>>> " + client.ping("msg").get()); - - } catch (ExecutionException | InterruptedException e) { - System.out.println("Glide example failed with an exception: "); - e.printStackTrace(); - } - } - - /** Redis-client settings */ - public static class ConnectionSettings { - public final String host; - public final int port; - public final boolean useSsl; - public final boolean clusterMode; - - public ConnectionSettings(String host, int port, boolean useSsl, boolean clusterMode) { - this.host = host; - this.port = port; - this.useSsl = useSsl; - this.clusterMode = clusterMode; - } - } }