yazabara
yazabara

Reputation: 1353

Spark app doesn't write to s3 bucket

The problem is:

I have spark application , which can't write data to s3. Reading is fine.

Spark configuration:

        SparkConf conf = new SparkConf();
        ...
        conf.set("spark.hadoop.fs.s3a.endpoint", getCredentialConfig().getS3Endpoint());
        System.setProperty("com.amazonaws.services.s3.enableV4", "true");// local works. enable aws v4 auth.

        conf.set("spark.hadoop.fs.s3a.impl", org.apache.hadoop.fs.s3a.S3AFileSystem.class.getName());
        conf.set("spark.hadoop.fs.s3a.access.key", getCredentialConfig().getS3Key());
        conf.set("spark.hadoop.fs.s3a.secret.key", getCredentialConfig().getS3Secret());


        conf.set("spark.hadoop.fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
        conf.set("spark.hadoop.fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
        ...

Write construction is:

String fileName = "s3a://" + getCredentialConfig().getS3Bucket() + "/s3-outputs/test/";
getSparkSession()
     .createDataset(list, Encoders.INT())
     .write()
     .format("com.databricks.spark.csv")
     .mode("overwrite")
     .csv(fileName);

Exception is:

10:35:01.914 [main] DEBUG org.apache.hadoop.fs.s3a.S3AFileSystem - Not Found: s3a://mybucket/s3-outputs/test/_temporary-39c4ebc3-61bd-47e0-9ac6-d047af1965f3
10:35:01.914 [main] DEBUG org.apache.hadoop.fs.s3a.S3AFileSystem - Couldn't delete s3a://mybucket/s3-outputs/test/_temporary-39c4ebc3-61bd-47e0-9ac6-d047af1965f3 - does not exist

It means, that spark can't find template folders on destination file system.

Current hadoop version: 2.7.3

Java 8

On Hadoop 2.8.1 - all works fine. But AWS EMR doesn't support hadoop 2.8.* version for this moment.

Upvotes: 1

Views: 1296

Answers (0)

Related Questions