Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object ConnectionPool {
poolConfig.setMinEvictableIdleTimeMillis(60000)
poolConfig.setTimeBetweenEvictionRunsMillis(30000)
poolConfig.setNumTestsPerEvictionRun(-1)
new JedisPool(poolConfig, re.host, re.port, re.timeout, re.auth, re.dbNum)
new JedisPool(poolConfig, re.host, re.port, re.timeout, re.auth, re.dbNum, re.ssl)
}
)
var sleepTime: Int = 4
Expand Down
19 changes: 11 additions & 8 deletions src/main/scala/com/redislabs/provider/redis/RedisConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ import scala.collection.JavaConversions._

/**
* RedisEndpoint represents a redis connection endpoint info: host, port, auth password
* db number, and timeout
* db number, timeout and ssl mode
*
* @param host the redis host or ip
* @param port the redis port
* @param auth the authentication password
* @param dbNum database number (should be avoided in general)
* @param ssl true to enable SSL connection. Defaults to false
*/
case class RedisEndpoint(host: String = Protocol.DEFAULT_HOST,
port: Int = Protocol.DEFAULT_PORT,
auth: String = null,
dbNum: Int = Protocol.DEFAULT_DATABASE,
timeout: Int = Protocol.DEFAULT_TIMEOUT)
timeout: Int = Protocol.DEFAULT_TIMEOUT,
ssl: Boolean = false)
extends Serializable {

/**
* Constructor from spark config. set params with spark.redis.host, spark.redis.port, spark.redis.auth and
* spark.redis.db
* Constructor from spark config. set params with spark.redis.host, spark.redis.port, spark.redis.auth, spark.redis.db and spark.redis.ssl
*
* @param conf spark context config
*/
Expand All @@ -37,23 +38,25 @@ case class RedisEndpoint(host: String = Protocol.DEFAULT_HOST,
conf.getInt("spark.redis.port", Protocol.DEFAULT_PORT),
conf.get("spark.redis.auth", null),
conf.getInt("spark.redis.db", Protocol.DEFAULT_DATABASE),
conf.getInt("spark.redis.timeout", Protocol.DEFAULT_TIMEOUT)
conf.getInt("spark.redis.timeout", Protocol.DEFAULT_TIMEOUT),
conf.getBoolean("spark.redis.ssl", false)
)
}

/**
* Constructor with Jedis URI
*
* @param uri connection URI in the form of redis://:$password@$host:$port/[dbnum]
* @param uri connection URI in the form of redis://:$password@$host:$port/[dbnum]. Use "rediss://" scheme for redis SSL
*/
def this(uri: URI) {
this(uri.getHost, uri.getPort, JedisURIHelper.getPassword(uri), JedisURIHelper.getDBIndex(uri))
this(uri.getHost, uri.getPort, JedisURIHelper.getPassword(uri), JedisURIHelper.getDBIndex(uri),
Protocol.DEFAULT_TIMEOUT, uri.getScheme == RedisSslScheme)
}

/**
* Constructor with Jedis URI from String
*
* @param uri connection URI in the form of redis://:$password@$host:$port/[dbnum]
* @param uri connection URI in the form of redis://:$password@$host:$port/[dbnum]. Use "rediss://" scheme for redis SSL
*/
def this(uri: String) {
this(URI.create(uri))
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/redislabs/provider/redis/package.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.redislabs.provider

package object redis extends RedisFunctions {

val RedisSslScheme: String = "rediss"
val RedisDataTypeHash: String = "hash"
val RedisDataTypeString: String = "string"
}