Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Java spark port number

Tags:

java

My java spark web application using the embedded jetty web server uses port number 4567. Unfortunately this port number is blocked on my computer and don't wish to unblock it. If looked at the spark documentation but it doesn't contain how to change the port number of the embedded Jetty server to 8080.

like image 665
Rick Dellman Avatar asked Aug 31 '16 23:08

Rick Dellman


People also ask

How do I change my Spark port?

You can optionally configure the cluster further by setting environment variables in conf/spark-env.sh. Create this file by starting with the conf/spark-env. sh. template, and copy it to all your worker machines for the settings to take effect.

How do I set a Spark UI port?

If you are running the Spark application locally, Spark UI can be accessed using the http://localhost:4040/ . Spark UI by default runs on port 4040 and below are some of the additional UI's that would be helpful to track Spark application. Note: To access these URLs, Spark application should in running state.

How do I find my Spark port?

Once started, the master will print out a spark://HOST:PORT URL for itself, which you can use to connect workers to it, or pass as the “master” argument to SparkContext . You can also find this URL on the master's web UI, which is http://localhost:8080 by default.


1 Answers

You can set the port number in your java spark web application using the function port(). This has to be done before using routes and filters

official documentation link: http://sparkjava.com/documentation.html#port

Example

port(8080);
// Routes of your endpoint...
like image 167
Francesco Ventura Avatar answered Sep 20 '22 18:09

Francesco Ventura