forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-529] allow for application args to have arguments withou equal…
…s sign, test (apache#182) * allow for application args to have arguments withou equals sign, test * change setup and teardown back, oops
- Loading branch information
Arthur Rand
authored
Sep 12, 2017
1 parent
5e22577
commit bab1e12
Showing
5 changed files
with
82 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
import scopt.OptionParser | ||
import org.apache.spark.SparkContext | ||
import org.apache.spark.SparkContext._ | ||
import org.apache.spark.SparkConf | ||
|
||
object S3Job { | ||
def main(args: Array[String]): Unit = { | ||
val conf = new SparkConf().setAppName("S3 Test") | ||
val sc = new SparkContext(conf) | ||
object config { | ||
var readurl: String = null | ||
var writeurl: String = null | ||
var countonly: Boolean = false | ||
} | ||
|
||
val readURL = args(0) | ||
val writeURL = args(1) | ||
println(s"Reading from ${readURL}. Writing to ${writeURL}.") | ||
val parser = new OptionParser[Unit]("S3 Job") { | ||
opt[String]("readUrl").action((x, _) => config.readurl = x) | ||
opt[String]("writeUrl").action((x, _) => config.writeurl = x) | ||
opt[Unit]("countOnly").action((_, _) => config.countonly = true) | ||
} | ||
|
||
val textRDD = sc.textFile(readURL) | ||
println(s"Read ${textRDD.count()} lines from${readURL}.") | ||
if (parser.parse(args)) { | ||
println("RUNNING S3 JOB") | ||
val conf = new SparkConf().setAppName("S3 Test") | ||
val sc = new SparkContext(conf) | ||
|
||
textRDD.map(_.length).saveAsTextFile(writeURL) | ||
println(s"Wrote ${textRDD.count()} lines to ${writeURL}.") | ||
val readURL = config.readurl | ||
val writeURL = config.writeurl | ||
|
||
sc.stop() | ||
println(s"Reading from ${readURL}. Writing to ${writeURL}.") | ||
|
||
val textRDD = sc.textFile(readURL) | ||
println(s"Read ${textRDD.count()} lines from ${readURL}.") | ||
|
||
textRDD.map(_.length).saveAsTextFile(writeURL) | ||
println(s"Wrote ${textRDD.count()} lines to ${writeURL}.") | ||
|
||
sc.stop() | ||
} else { | ||
println("Error bad arguments") | ||
System.exit(1) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters