spark 3.x Plugin Framework

简介: spark 3.x Plugin Framework

背景


该文基于spark 3.0.1

spark 3.0引入了一个新的插件框架,其实这个插件在spark 2.x就已经存在了,只不过spark 3.0对该插件进行了重构。因为在之前该插件是不支持driver端的,具体可以见SPARK-29396。至于为什么引入这么一个插件 是为了更好的监控和定制一些指标,以便更好的进行spark调优。


插件功能


支持自定义的指标

用户可以写代码进行自定义指标的编写,而这些指标和spark的指标结合, 这样就能通过sinks进行收集,具体参见metrics


executor和driver可以定制listener发送事件

因为在driverPluginContainer 中我们可以获取到sparkcontext,从而可以注册对应的listener进行处理。

而在executor端,ExecutorPluginContainer中我们可以实现TaskCompletionListener和TaskFailureListener接口,通过TaskContext.get 注册对应的回调


executor 插件和 driver插件可以通过RPC进行交互


源码实现


关于源码实现其实还是比较好理解的,自行参考源码PluginContainer,SparkPlugin,DriverPluginContainer,ExecutorPluginContainer


Demo


SparkPlugins

该例子自定义了操作系统级别的指标以及HDFS级别的metrics等

spark-memory

注意该实现是基于spark 2.x的,但是我们可以基于此进行改造能够集成到spark 3.x中,但是在spark 3.x中,spark.metrics.executorMetricsSource.enabled默认为true,也就是该spark-memory暴露出来的指标已经集成到了spark中了,在此可以作为一个参考。

参考


spark-plugin

spark-internals


相关文章
|
Java Maven Android开发
eclipse 中 maven的pom.xml文件发生错误:CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven...
eclipse 中 maven的pom.xml文件发生错误:CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven...
620 0
eclipse 中 maven的pom.xml文件发生错误:CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven...
|
1月前
|
Java Maven Spring
SpringBoot 系列之 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
这篇文章描述了在使用Maven构建Spring Boot项目时遇到的`maven-resources-plugin`插件版本问题导致的编译失败,并提供了通过修改插件版本至3.1.0来解决这个问题的方法。
SpringBoot 系列之 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
|
4月前
|
Java
springboot打包错误:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
springboot打包错误:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
66 0
|
2月前
|
Java Maven
Cannot resolve plugin org.apache.maven.plugins:maven-site-plugin:3.3
Cannot resolve plugin org.apache.maven.plugins:maven-site-plugin:3.3
|
10月前
|
Java Maven
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4
|
11月前
|
存储 缓存 分布式计算
Spark-Core
Spark-Core
38 0
Spark-Core
|
Scala
Idea中创建scala项目中Cannot resolve plugin org.scala-tools:maven-scala-plugin: unknown
Idea中创建scala项目中Cannot resolve plugin org.scala-tools:maven-scala-plugin: unknown
131 0
|
Java Maven
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compil
maven-compliler-plugin版本与maven版本不一致,Maven版本太低或maven-compiler-plugin版本过高
3798 0
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compil
|
Java Maven Windows
解决 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
解决 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
2383 0
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test
121 0
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test