azure - 使用 blobproperties.getcreatedtime 时 SparkHDInsights 集群不起作用

标签 azure apache-spark azure-blob-storage azure-hdinsight

我正在使用 SparkHDInsights 集群使用 Spark-submit 命令运行 jar。我用过

libraryDependencies += "com.microsoft.azure" % "azure-storage" % "8.1.0" 

在 sbt 文件中。

该程序在本地运行完全正常。仅当尝试在集群上运行时才会创建异常。我相信它使用的库 "com.microsoft.azure"% "azure-storage"% "5.3.0" 可能是 Azure HDI 集群中的默认选项。

程序片段是:

val blob = blobInDir.asInstanceOf[CloudBlockBlob]  
var blobtime = blob.getProperties.getCreatedTime().getTime

我收到如下错误:

Exception in thread "main" java.lang.NoSuchMethodError: com.microsoft.azure.storage.blob.BlobProperties.getCreatedTime()Ljava/util/Date;

最佳答案

根据您的错误信息,我尝试查看Azure Storage for Java的源代码以找出问题原因。然后,我发现当azure-storage版本低于v7.1.0-时,BlobProperties没有名为getCreatedTime的方法预览。同时,azure-storage库是hadoop-azure对HDInsight的依赖,其7.0.0版本需要最新版本3.2.0 hadoop-azure 如下。

enter image description here

因此,您无法通过升级HDInsight来解决该问题,但您可以通过设置以下配置选项来使用您的jar文件覆盖HDInsight中的相关jar文件来更改类路径加载的优先级,以使您的程序像在本地一样运行.

  1. 设置spark.driver.userClassPathFirst值为true,请查看下面的官方含义。

enter image description here

  • 设置spark.executor.userClassPathFirst值为true,请查看下面的官方含义。
  • enter image description here

    上面的选项可以在 spark.conf 文件中设置或通过 spark-submit 传递。

    关于azure - 使用 blobproperties.getcreatedtime 时 SparkHDInsights 集群不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55062204/

    相关文章:

    azure - WebChat - Direct Line 语音适配器错误 : WebSocket connection failed with 400

    hadoop - Spark : saveAsTextFile() only creating SUCCESS file and no part file when writing to local filesystem

    azure - 如何创建azure函数来访问多个azure blob存储帐户?

    c# - 无法让 Linux 容器在隔离进程中作为 Azure 函数运行

    asp.net - Dropbox.API SDK 无法在 Azure 服务器上运行

    apache-spark - 将数据帧写入 Spark 集群上的文件的速度非常慢

    python - 如何有效地将新 key 添加到 pyspark 中的 RDD

    azure - SqlBulkCopy Azure DataTable 比流传输更快

    azure - Azure Blob 存储是否有默认图像类型?

    azure - 如何在 Azure AD B2C 中添加已发布范围