Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 度量系统无法识别应用程序jar中的自定义源/接收器_Apache Spark_Spark Streaming - Fatal编程技术网

Apache spark 度量系统无法识别应用程序jar中的自定义源/接收器

Apache spark 度量系统无法识别应用程序jar中的自定义源/接收器,apache-spark,spark-streaming,Apache Spark,Spark Streaming,后续行动 我在我的应用程序jar中添加了自定义源和接收器,并找到了一种在独立集群节点上获取静态固定metrics.properties的方法。当我想启动我的应用程序时,我给出了静态路径-spark.metrics.conf=“/fixed path/to/metrics.properties”。尽管我的自定义源/接收器在我的代码/fat jar中,但我在CustomSink上得到ClassNotFoundException 我的胖jar(其中包含自定义源代码/接收器代码)位于hdfs上,具有对所

后续行动

我在我的应用程序jar中添加了自定义源和接收器,并找到了一种在独立集群节点上获取静态固定metrics.properties的方法。当我想启动我的应用程序时,我给出了静态路径-spark.metrics.conf=“/fixed path/to/metrics.properties”。尽管我的自定义源/接收器在我的代码/fat jar中,但我在CustomSink上得到ClassNotFoundException

我的胖jar(其中包含自定义源代码/接收器代码)位于hdfs上,具有对所有源代码的读取权限

下面是我已经尝试设置的内容(因为执行者无法在我的应用程序fat jar中找到自定义源/接收器):

  • spark.executor.extraClassPath=hdfs://path/to/fat-jar
  • spark.executor.extraClassPath=fat-jar-name.jar
  • spark.executor.extraClassPath=./fat-jar-name.jar
  • spark.executor.extraClassPath=/
  • spark.executor.extraClassPath=/dir/on/cluster/*(虽然*不在文件级别,但还有更多目录-在启动应用程序之前,我无法知道随机应用程序id或驱动程序id以给出绝对名称)
  • 似乎这就是执行者在这个案例中初始化的方式(如果我错了,请纠正我)——

  • 驱动程序告诉我们这是jar的位置-hdfs://../fat-jar.jar 这里有一些属性,比如spark.executor.memory等
  • N群集上的执行器启动数(取决于配置)
  • 开始下载hdfs://../fat-jar.jar 但同时初始化度量系统(?-不确定此步骤)
  • Metrics系统寻找自定义接收器/源文件——因为Metrics.properties中提到了它——甚至在下载fat jar(实际上它包含所有这些文件)之前(这是我的假设)
  • ClassNotFoundException-未找到CustomSink
    我的理解正确吗?此外,还有什么我可以试试的吗?如果任何人有定制源/接收器的经验,将不胜感激。

    为了使用定制源/接收器,必须使用spark submit--files分发它,并通过spark.executor.extraClassPath设置它当我需要扩展现有的
    GraphiteSink
    类时,我偶然发现了相同的ClassNotFoundException,下面是我如何解决它的

    首先,我在
    org.apache.spark.metrics.sink
    包中创建了一个
    CustomGraphiteSink
    类:

    package org.apache.spark.metrics.sink;
    公共类CustomGraphiteSink扩展了GraphiteSink{}
    
    然后我在
    metrics.properties
    *.sink.graphite.class=org.apache.spark.metrics.sink.CustomGraphiteSink

    并通过以下方式将此文件传递给spark submit:
    --conf spark.metrics.conf=metrics.properties