无法在IDE中访问Alluxio文件系统API

时间:2019-03-07 05:03:06

标签: scala maven apache-spark alluxio

我正在尝试在IDE中以Scala代码访问alluxio中的文件,并且出现此错误Exception in thread "main" java.io.IOException: No FileSystem for scheme: alluxio 我的代码如下,

package com.example.sparkalliuxiodemo

import org.apache.spark.sql.SparkSession

object TestMain {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().config("spark.master", "local[2]")
      .getOrCreate()

    var df = spark.read.parquet("alluxio://localhost:19998/sample-df")
    df.printSchema()

  }
}

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>spark-alluxio-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.12</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.12</artifactId>
            <version>2.4.0</version>
        </dependency>

        <dependency>
            <groupId>org.alluxio</groupId>
            <artifactId>alluxio-core-client</artifactId>
            <version>1.8.1</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.alluxio</groupId>
            <artifactId>alluxio-core-server</artifactId>
            <version>1.8.1</version>
            <type>pom</type>
        </dependency>


        <dependency>
            <groupId>org.alluxio</groupId>
            <artifactId>alluxio-core-common</artifactId>
            <version>1.8.1</version>
        </dependency>


        <dependency>
            <groupId>org.alluxio</groupId>
            <artifactId>alluxio-core-client-fs</artifactId>
            <version>1.8.1</version>
        </dependency>


    </dependencies>
</project>

我能够通过Shell访问Spark Installed目录中的alluxio文件系统。如果我尝试通过IDE访问同一文件,包括POM.xml中的上述alluxio依赖项,则会收到上述错误。

如果将这个jar`alluxio-1.8.1-client.jar'手动放置到我的构建路径中,我将能够在alluxio中访问文件,而IDE本身没有任何错误。

我需要直接在eclipse或scala-ide中访问alluxio中的文件。

有人可以建议我将正确的alluxio依赖项包含在maven依赖项中吗?

1 个答案:

答案 0 :(得分:1)

尝试添加

    <dependency>
        <groupId>org.alluxio</groupId>
        <artifactId>alluxio-core-client-hdfs</artifactId>
        <version>1.8.1</version>
    </dependency>