You can install E-MapReduce SDK using one of the methods below.
Method 1: Directly use the JAR package in the Eclipse, and the steps are as follows:
Download E-MapReduce SDK from Alibaba Cloud official website.
Unzip the package and copy “emr-sdk_2.10-22.214.171.124.jar” and “emr-core-126.96.36.199.jar” to your project folder.
In the Eclipse, right click the project name and click Properties > Java Build Path > Add JARs.
Select the SDK you downloaded.
Thus, you can read and write data of OSS, LogService, MNS, ONS and ODPS in the project.
Method 2: Follow the Maven project method and add the dependency below:
<!-- Support OSS data source -->
<!-- Support MNS, ONS, LogService and ODPS data source -->
Note: The configuration item of “spark.hadoop.mapreduce.job.run-local” only applies to the scenario where local debugging of Spark code for reading/writing OSS data is required. For other scenarios, you only need to apply the default settings.
For local debugging of Spark code for reading/writing OSS data, you need to configure the SparkConf and set “spark.hadoop.mapreduce.job.run-local” to “true”, such as the code below:
val conf = new SparkConf().setAppName(getAppName).setMaster("local")
val sc = new SparkContext(conf)
val data = sc.textFile("oss://...")
To support operations on Alibaba data sources (including OSS and ODPS) on E-MapReduce, your job may need to be dependent on some third-party packages.
You can refer to this pom file to add or delete the required third-party dependency packages.
If a Spark job fails, the generated data cannot be cleared automatically. In case of a failed Spark job, check whether the OSS output directory contains files. You also need to check the OSS Fragment Management to see whether there are any uncommitted fragments. If yes, clear the fragments in a timely manner.