Redis on Spark:Task not serializable
We use Redis on Spark to cache our key-value pairs.This is the code:
But compiler gave me feedback like this:
Could somebody tell me how to serialize the data get from Redis.Thanks a lot. |
||
In Spark, the functions on The Redis connection here is not serializable as it opens TCP connections to the target DB that are bound to the machine where it's created. The solution is to create those connections on the executors, in the local execution context. There're few ways to do that. Two that pop to mind are:
A singleton connection manager can be modeled with an object that holds a lazy reference to a connection (note: a mutable ref will also work).
This object can then be used to instantiate 1 connection per worker JVM and is used as a
The advantage of using the singleton object is less overhead as connections are created only once by JVM (as opposed to 1 per RDD partition) There're also some disadvantages:
(*) code provided for illustration purposes. Not compiled or tested. |
|||||||||||||
|
You're trying to serialize the client. You have one |
|||||||||||||
|
Redis on Spark:Task not serializable的更多相关文章
- spark2.1注册内部函数spark.udf.register("xx", xxx _),运行时抛出异常:Task not serializable
函数代码: class MySparkJob{ def entry(spark:SparkSession):Unit={ def getInnerRsrp(outer_rsrp: Double, we ...
- spark出现task不能序列化错误的解决方法 org.apache.spark.SparkException: Task not serializable
import org.elasticsearch.cluster.routing.Murmur3HashFunction; import org.elasticsearch.common.math.M ...
- Spark运行程序异常信息: org.apache.spark.SparkException: Task not serializable 解决办法
错误信息: 17/05/20 18:51:39 ERROR JobScheduler: Error running job streaming job 1495277499000 ms.0 org.a ...
- 【原创】大叔问题定位分享(19)spark task在executors上分布不均
最近提交一个spark应用之后发现执行非常慢,点开spark web ui之后发现卡在一个job的一个stage上,这个stage有100000个task,但是绝大部分task都分配到两个execut ...
- Hadoop MapReduce Task的进程模型与Spark Task的线程模型
Hadoop的MapReduce的Map Task和Reduce Task都是进程级别的:而Spark Task则是基于线程模型的. 多进程模型和多线程模型 所谓的多进程模型和多线程模型,指的是同一个 ...
- Kafka Topic ISR不全,个别Spark task处理时间长
现象 Spark streaming读kafka数据做业务处理时,同一个stage的task,有个别task的运行时间比多数task时间都长,造成业务延迟增大. 查看业务对应的topic发现当topi ...
- Spark Task 概述
Task的执行流程: 1. Driver端中的 CoarseGrainSchedulerBackend 给 CoarseGrainExecutorBacken 发送 LaunchTask 消息 2. ...
- 大数据学习day34---spark14------1 redis的事务(pipeline)测试 ,2. 利用redis的pipeline实现数据统计的exactlyonce ,3 SparkStreaming中数据写入Hbase实现ExactlyOnce, 4.Spark StandAlone的执行模式,5 spark on yarn
1 redis的事务(pipeline)测试 Redis本身对数据进行操作,单条命令是原子性的,但事务不保证原子性,且没有回滚.事务中任何命令执行失败,其余的命令仍会被执行,将Redis的多个操作放到 ...
- 【原】 Spark中Task的提交源码解读
版权声明:本文为原创文章,未经允许不得转载. 复习内容: Spark中Stage的提交 http://www.cnblogs.com/yourarebest/p/5356769.html Spark中 ...
随机推荐
- 用 Eclipse 插件提高代码质量
如果能在构建代码前发现代码中潜在的问题会怎么样呢?很有趣的是,Eclipse 插件中就有这样的工具,比如 JDepend 和 CheckStyle,它们能帮您在软件问题暴露前发现这些问题.在 让开发自 ...
- Linux 小知识点
1:当前目录比较重要的几个文件 . .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc install ...
- Linux必看书籍
<鸟哥的Linux私房菜:基础学习篇(第三版)> <鸟哥的Linux私房菜——服务器架设篇> <高性能Linux服务器构建实战> <实战Nginx:取代 Ap ...
- filezilla
中文网站:https://www.filezilla.cn/ 英文网站:https://filezilla-project.org/ FileZilla 客户端是一个快速可靠的.跨平台的FTP,FTP ...
- 【Android开发经验】Cannot generate texture from bitmap异常的解决方式
异常现象: 今天在处理用户头像的过程中,由于头像的处理比較复杂,由于,没有使用afinal自带的自己主动载入.而是自己依据头像的下载路径.手动进行下载和使用.可是在手动回收bitmap对象的过程中,会 ...
- Lua 字符串库函数总结
字符串库 注:字符串在Lua中是不可变的.不论什么的string操作都不会去改变原有的字符串.都是返回新的字符串 一.一般函数 1. 求长度 s = "Hello LUA "; p ...
- idea 设置黑色背景
idea 设置黑色背景 CreateTime--2018年4月26日10:32:38 Author:Marydon 设置-->Appearance-->Theme调为:Darcula- ...
- &和&&的一点区别
&两边的语句都会执行,&&有可能只执行左边的语句. &做位运算与的时候可以更高效的判断一个数字是不是奇数. 1&1 = 1 0&1 = 0 所以和1与结 ...
- Android 5.0 + IDA 6.8 调试经验分享
如今升级快.网上的资料仅仅能做參考. 学到了NDK逆向这一块,昨天为了能让IDA 能动态调试SO,瞎折腾了非常久,这里分享一下我的经验. 工具: IDA pro 6.8 Android 5.x IDA ...
- TCP Socket 粘包
这两天看csdn有一些关于socket粘包,socket缓冲区设置的问题.发现自己不是非常清楚,所以查资料了解记录一下: 一两个简单概念长连接与短连接: 1.长连接 Client方与Server ...