def main()

in src/main/scala/com/aliyun/emr/example/spark/SparkOssDemo.scala [29:57]


  def main(args: Array[String]): Unit = {
    if (args.length < 2) {
      System.err.println(
        """Usage: bin/spark-submit --class com.aliyun.emr.example.spark.SparkOssDemo examples-1.0-SNAPSHOT-shaded.jar
          |
          |Arguments:
          |
          |    accessKeyId      OSS accessKeyId
          |    accessKeySecret  OSS accessKeySecret
          |    endpoint         OSS endpoint
          |    inputPath        Input OSS object path, like oss://bucket/input/a.txt
          |    outputPath       Output OSS object path, like oss://bucket/output/
          |    numPartitions    the number of RDD partitions.
          |
        """.stripMargin)
      System.exit(1)
    }

    accessKeyId = args(0)
    accessKeySecret = args(1)
    endpoint = args(2)
    val inputPath = args(3)
    val outputPath = args(4)
    val numPartitions = args(5).toInt
    val ossData = getSparkContext.hadoopFile(inputPath, classOf[TextInputFormat], classOf[LongWritable], classOf[Text], numPartitions)
    ossData.foreach(line => println(s"print: ${line}"))

    ossData.saveAsTextFile(outputPath)
  }