0

I have a java program which runs separate small spark programs so How could I make my java program to run small spark modules/programs on cluster?

for example: I have a program name executor(java program).

and some spark programs --add two numbers --subtract two numbers

So how could I run those spark programs on Cluster from my java program i.e. executor in this case.

Thanks!!!

3 Answers 3

1

Check spark job server Project, let you create a shared contex and execute jobs from a rest interface: https://github.com/spark-jobserver/spark-jobserver Hope this Will be usefull

Sign up to request clarification or add additional context in comments.

2 Comments

This would probably be better as a comment than an answer, it does not really answer the question. If the spark job server project has something that would be useful, link to it.
Please improve this answer with a reference or a code snippet blocked-off. Thanks. Oh, and don't make an answer look like a comment or a question. Have it authoritative, not wishy-washy :P
0

Possible solution could be:

  1. Write a bash script and sequentially execute Spark program.

  2. Write all the operations in a single program, and call each operation in a single program and print respective results.

  3. Write a single program but use principle of parallel programming. It means, execute such operation in parallel. Well, it depend on what type of data you have and what you would like to achieve, hard to comment.

Comments

0

You could use SparkLauncher this way:

import org.apache.spark.launcher.SparkLauncher
import scala.collection.JavaConverters._


val env = Map(
  "HADOOP_CONF_DIR" -> hadoopConfDir,
  "YARN_CONF_DIR" -> yarnConfDir
)

println(env.asJava)
val process = new SparkLauncher(env.asJava)
  .setSparkHome(sparkHome)
  .setAppResource(jarPath)
  .setAppName(appName)
  .setMainClass(className) //Main class in your uber spark JAR 
  .setMaster(master)
  //.setConf("spark.driver.memory", "2g") example additional conf prop
  .setVerbose(true)
  .launch()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.