Skip to content
Merged
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 @@ -54,6 +54,19 @@ class RedisSinkRelation(override val sqlContext: SQLContext, config: SparkRedisC

val sparkConf: SparkConf = sqlContext.sparkContext.getConf

lazy val endpoint: RedisEndpoint = RedisEndpoint(
host = sparkConf.get("spark.redis.host"),
port = sparkConf.get("spark.redis.port").toInt,
password = sparkConf.get("spark.redis.password", "")
)

lazy val properties: RedisWriteProperties = RedisWriteProperties(
maxJitterSeconds = sparkConf.get("spark.redis.properties.maxJitter").toInt,
pipelineSize = sparkConf.get("spark.redis.properties.pipelineSize").toInt
)

lazy val isClusterMode: Boolean = checkIfInClusterMode(endpoint)

def newJedisClient(endpoint: RedisEndpoint): Jedis = {
val jedis = new Jedis(endpoint.host, endpoint.port)
if (endpoint.password.nonEmpty) {
Expand All @@ -78,18 +91,6 @@ class RedisSinkRelation(override val sqlContext: SQLContext, config: SparkRedisC
.localCheckpoint()
else data

val endpoint = RedisEndpoint(
host = sparkConf.get("spark.redis.host"),
port = sparkConf.get("spark.redis.port").toInt,
password = sparkConf.get("spark.redis.password", "")
)
val properties = RedisWriteProperties(
maxJitterSeconds = sparkConf.get("spark.redis.properties.maxJitter").toInt,
pipelineSize = sparkConf.get("spark.redis.properties.pipelineSize").toInt
)

val isClusterMode = checkIfInClusterMode(endpoint)

dataToStore.foreachPartition { partition: Iterator[Row] =>
java.security.Security.setProperty("networkaddress.cache.ttl", "3");
java.security.Security.setProperty("networkaddress.cache.negative.ttl", "0");
Expand Down