spark 2.0 NettyStreamManager -- StreamManager的实现
来源:互联网 发布:unity3d 寻路算法 编辑:程序博客网 时间:2024/05/20 23:34
NettyStreamManager是StreamManager的一种实现,它从NettyRpcEnv中提供文件服务。
这个管理器可以有三种资源,背后都是物理文件。
第一种:“/files”: 文件列表,为SparkContext.addFile提供支持。
第二种:“/jars”: 一个文件列表,为SparkContexst.addJar提供支持。
第三种:任意目录,在这个目录下的所有的文件都会变得可用。
这个管理器只支持openStream操作。
/** * StreamManager implementation for serving files from a NettyRpcEnv. * * Three kinds of resources can be registered in this manager, all backed by actual files: * * - "/files": a flat list of files; used as the backend for [[SparkContext.addFile]]. * - "/jars": a flat list of files; used as the backend for [[SparkContext.addJar]]. * - arbitrary directories; all files under the directory become available through the manager, * respecting the directory's hierarchy. * * Only streaming (openStream) is supported. */private[netty] class NettyStreamManager(rpcEnv: NettyRpcEnv) extends StreamManager with RpcEnvFileServer { private val files = new ConcurrentHashMap[String, File]() private val jars = new ConcurrentHashMap[String, File]() private val dirs = new ConcurrentHashMap[String, File]() override def getChunk(streamId: Long, chunkIndex: Int): ManagedBuffer = { throw new UnsupportedOperationException() } override def openStream(streamId: String): ManagedBuffer = { val Array(ftype, fname) = streamId.stripPrefix("/").split("/", 2) val file = ftype match { case "files" => files.get(fname) case "jars" => jars.get(fname) case other => val dir = dirs.get(ftype) require(dir != null, s"Invalid stream URI: $ftype not found.") new File(dir, fname) } if (file != null && file.isFile()) { new FileSegmentManagedBuffer(rpcEnv.transportConf, file, 0, file.length()) } else { null } } override def addFile(file: File): String = { val existingPath = files.putIfAbsent(file.getName, file) require(existingPath == null || existingPath == file, s"File ${file.getName} was already registered with a different path " + s"(old path = $existingPath, new path = $file") s"${rpcEnv.address.toSparkURL}/files/${Utils.encodeFileNameToURIRawPath(file.getName())}" } override def addJar(file: File): String = { val existingPath = jars.putIfAbsent(file.getName, file) require(existingPath == null || existingPath == file, s"File ${file.getName} was already registered with a different path " + s"(old path = $existingPath, new path = $file") s"${rpcEnv.address.toSparkURL}/jars/${Utils.encodeFileNameToURIRawPath(file.getName())}" } override def addDirectory(baseUri: String, path: File): String = { val fixedBaseUri = validateDirectoryUri(baseUri) require(dirs.putIfAbsent(fixedBaseUri.stripPrefix("/"), path) == null, s"URI '$fixedBaseUri' already registered.") s"${rpcEnv.address.toSparkURL}$fixedBaseUri" }}
1 0
- spark 2.0 NettyStreamManager -- StreamManager的实现
- spark 2.0 StreamManager
- spark 的实现简介
- Spark的shuffle实现
- Spark下的PageRank实现
- Spark自定义累加器的实现
- spark实现简单的pagerank
- 基于spark的adaboost实现
- spark-knn的简易实现
- spark学习十六 spark为什么要实现自己的RPEL
- Spark SQL系列------2. Spark SQL Aggregate操作的实现
- spark-spark-SparkSQL的3种Join实现(转)
- 在Spark Streaming上使用Spark Mllib的思路实现
- spark(5)--spark模型中FIFO的实现
- Spark学习笔记8-搭建spark的HA(用zookeeper实现spark的高可用)
- Spark实现的hello world<转>
- 详细探究Spark的shuffle实现
- 详细探究Spark的shuffle实现
- sql函数
- P2P原理及UDP穿透简单说明
- MySQL监控模板说明-Percona MySQL Monitoring Template for Cacti
- UCINET软件使用简介——主菜单简介2
- SlidingMenu简单使用
- spark 2.0 NettyStreamManager -- StreamManager的实现
- 读取配置文件
- 同余定理(求余数)
- <转>《Hadoop基础教程》之初识Hadoop
- TortoiseSVN安装后在VS内不显示SVN
- JackSon学习笔记(二)
- autotools的使用详解
- 借助ChinaNet与xx-net上网
- 两点GPS经纬度计算