beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ieme...@apache.org
Subject [beam] branch master updated: [BEAM-4610] Add SSL support for RedisIO
Date Mon, 01 Apr 2019 13:54:36 GMT
This is an automated email from the ASF dual-hosted git repository.

iemejia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 9846021  [BEAM-4610] Add SSL support for RedisIO
     new a85ea07  Merge pull request #8161: [BEAM-4610] Add SSL support for RedisIO
9846021 is described below

commit 98460211083a85105196a49befa37c2ae490687a
Author: EdgarLGB <lgb_edgar@outlook.com>
AuthorDate: Thu Mar 28 17:07:27 2019 +0100

    [BEAM-4610] Add SSL support for RedisIO
---
 .../beam/sdk/io/redis/RedisConnectionConfiguration.java    | 14 +++++++++++++-
 .../java/org/apache/beam/sdk/io/redis/RedisIOTest.java     |  2 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisConnectionConfiguration.java
b/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisConnectionConfiguration.java
index 9090baa..6f5ff52 100644
--- a/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisConnectionConfiguration.java
+++ b/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisConnectionConfiguration.java
@@ -42,6 +42,8 @@ public abstract class RedisConnectionConfiguration implements Serializable
{
 
   abstract int timeout();
 
+  abstract boolean ssl();
+
   abstract Builder builder();
 
   @AutoValue.Builder
@@ -54,6 +56,8 @@ public abstract class RedisConnectionConfiguration implements Serializable
{
 
     abstract Builder setTimeout(int timeout);
 
+    abstract Builder setSsl(boolean ssl);
+
     abstract RedisConnectionConfiguration build();
   }
 
@@ -62,6 +66,7 @@ public abstract class RedisConnectionConfiguration implements Serializable
{
         .setHost(Protocol.DEFAULT_HOST)
         .setPort(Protocol.DEFAULT_PORT)
         .setTimeout(Protocol.DEFAULT_TIMEOUT)
+        .setSsl(false)
         .build();
   }
 
@@ -70,6 +75,7 @@ public abstract class RedisConnectionConfiguration implements Serializable
{
         .setHost(host)
         .setPort(port)
         .setTimeout(Protocol.DEFAULT_TIMEOUT)
+        .setSsl(false)
         .build();
   }
 
@@ -99,9 +105,14 @@ public abstract class RedisConnectionConfiguration implements Serializable
{
     return builder().setTimeout(timeout).build();
   }
 
+  /** Enable SSL connection to Redis server. */
+  public RedisConnectionConfiguration enableSSL() {
+    return builder().setSsl(true).build();
+  }
+
   /** Connect to the Redis instance. */
   public Jedis connect() {
-    Jedis jedis = new Jedis(host(), port(), timeout());
+    Jedis jedis = new Jedis(host(), port(), timeout(), ssl());
     if (auth() != null) {
       jedis.auth(auth());
     }
@@ -113,5 +124,6 @@ public abstract class RedisConnectionConfiguration implements Serializable
{
     builder.add(DisplayData.item("host", host()));
     builder.add(DisplayData.item("port", port()));
     builder.addIfNotNull(DisplayData.item("timeout", timeout()));
+    builder.add(DisplayData.item("ssl", ssl()));
   }
 }
diff --git a/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
b/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
index c33355c..585c238 100644
--- a/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
+++ b/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
@@ -249,6 +249,7 @@ public class RedisIOTest {
     Assert.assertEquals(111, read.connectionConfiguration().port());
     Assert.assertEquals("pass", read.connectionConfiguration().auth());
     Assert.assertEquals(5, read.connectionConfiguration().timeout());
+    Assert.assertEquals(false, read.connectionConfiguration().ssl());
   }
 
   @Test
@@ -258,6 +259,7 @@ public class RedisIOTest {
     Assert.assertEquals(111, write.connectionConfiguration().port());
     Assert.assertEquals("pass", write.connectionConfiguration().auth());
     Assert.assertEquals(5, write.connectionConfiguration().timeout());
+    Assert.assertEquals(false, write.connectionConfiguration().ssl());
     Assert.assertEquals(Method.APPEND, write.method());
   }
 


Mime
View raw message