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中 ...
随机推荐
- LogUtils.java
package com.xdsjs.save.utils; /** * 日志相关管理类 * Created by xdsjs on 2015/10/13. */ import android.util ...
- yml 配置文件注入
配置文件 JavaBean 自动提示 测试
- This Handler class should be static or leaks might occur,Handler和Context使用的注意事项!
Android中.在使用到Handler的时候,假设按例如以下代码编写: private Handler handler; @Override public void onCreate(Bundle ...
- SettingsJDK
迁移时间:2017年5月20日23:38:40 Author:Marydon 1.双击安装,更改安装路径为D:\ProgramFiles\Java\jdk1.7.0_55: 注意事项: 1.1 将 ...
- CSS3制作Freebie标签
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- 【php】实现多个一维数组转换成二维循环数组
1.目的:将下面类型数组转换成模板循环打印二维数组 数组库一维数组: 模板要求循环二维数组: 2.代码: header("Content-type: text/html; charset=u ...
- Appirater激励用户为你的app评分
如果你此前开发过app,那么你会知道获得用户积极的评分并不是一件简单的事情.不幸的是,用户往往给他们不喜欢的东西负面评价,而不怎么倾向于给喜欢的内容留下积极评价. 所以,你作为一个开发者如何激励用 ...
- ubuntu(14.04) remote access(远程连接数据库)
1.修改mysql的配置文件. /etc/mysql/my.cnf 把 bind-address 的那行代码注释掉,保存退出,重启mysql
- Hadoop Archives
原文地址:http://hadoop.apache.org/docs/r1.0.4/cn/hadoop_archives.html 什么是Hadoop archives? 如何创建archive? 如 ...
- jQuery on() 方法问题
<!DOCTYPE html><html><head><script src="https://cdn.bootcss.com/jquery/1.1 ...