2

我正在尝试在基于 spark-sql java 的应用程序中从 Redis 缓存加载/写入数据。这是我的代码:

SparkSession sprk = SparkSession.builder().appName("Bulk processing").master("local").config("spark.redis.host", "127.0.0.1")
                .config("spark.redis.port", "57855").getOrCreate();

Dataset<Row> employeeDF = sprk.read().format("org.apache.spark.sql.redis").
                option("table","employees").load();

employeeDF.show();

这是我得到的例外:

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Connection reset
    at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:205)
    at redis.clients.jedis.util.RedisInputStream.readByte(RedisInputStream.java:43)
    at redis.clients.jedis.Protocol.process(Protocol.java:155)
    at redis.clients.jedis.Protocol.read(Protocol.java:220)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:318)
    at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:255)
    at redis.clients.jedis.Connection.getBulkReply(Connection.java:245)
    at redis.clients.jedis.BinaryJedis.info(BinaryJedis.java:2972)
    at com.redislabs.provider.redis.RedisConfig.clusterEnabled(RedisConfig.scala:194)
    at com.redislabs.provider.redis.RedisConfig.getNodes(RedisConfig.scala:317)
    at com.redislabs.provider.redis.RedisConfig.getHosts(RedisConfig.scala:233)
    at com.redislabs.provider.redis.RedisConfig.<init>(RedisConfig.scala:132)
    at org.apache.spark.sql.redis.RedisSourceRelation.<init>(RedisSourceRelation.scala:34)
    at org.apache.spark.sql.redis.DefaultSource.createRelation(DefaultSource.scala:13)
    at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:318)
    at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:223)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:211)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:167)
    at com.apps.employees.spark.Main.main(Main.java:41)

Caused by: java.net.SocketException: Connection reset
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:126)
    at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:199)
    ... 18 more

我已经在 Windows 机器上使用 docker 和 kubectl 启动了 redis。 在此处输入图像描述

我不确定是什么导致了这个问题。有人可以帮我解决这个问题

4

0 回答 0