Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Making a call from Servlet to Spark Cache

 
Greenhorn
Posts: 4
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application which manipulates large data sets, I have decided to cache them in a seprate cache to make it even more scalable for future, I found Apache Spark to be most relevant, I went through its samples and now I am in phase of using it in one of my own servlet so that I can get the context of the Spark master node which is running on same workstation so that I can create a cache there.

I am using this piece of code in my servlet to get a hook of Spark context from its Master node:


so when this code is executed to get a hook it throws this exception:



I am using Apache Spark 1.1.0 using pre-built package for Hadoop 2.4 (spark-assembly-1.1.0-hadoop2.4.0.jar)

Help required in this, as I am stucked.
 
Vicky Twolaw
Greenhorn
Posts: 4
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still struggling...

not a single reply ...
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty new to Spark as well, but I think you might be mixing apples and oranges here. Your Spark master is the "controller" machine for your Spark cluster, so where is your Spark master running? If it's not on the same machine as your Java server, then it won't be "localhost" for the servlet, so you'll need to provide the appropriate URL when you request the Spark context. Also, it looks like your Spark libraries are not available to your servlet - I don't use Java with Spark, so you'll need to check up which JARs etc you need on your application server e.g. http://stackoverflow.com/questions/23752425/how-to-use-the-spark-cluster-computing-function-in-servlets

More generally, my understanding is that the point of Spark is to distribute processing over multiple machines, so what benefits do you hope to gain from caching your data on your app server? Spark has its own caching mechanism via RDD persistence so would this be more relevant to your needs?

One thing you really want to avoid with Spark and/or Hadoop is moving lots of data around e.g. in/out of cache. Process the data in situ where possible, and only move (or cache) the results.
 
Vicky Twolaw
Greenhorn
Posts: 4
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,

thanks for replying, I am using the same machine and I checked if spark is avialble on "LocalHost" it is listening and If I run a standalon java class using main mathod to get its context it is avaialble and I can access the cache.

the problem occurs when I try to acces the same Spark context from with my web app which is hosted on JettyServer in same machine.




chris webster wrote:I'm pretty new to Spark as well, but I think you might be mixing apples and oranges here. Your Spark master is the "controller" machine for your Spark cluster, so where is your Spark master running? If it's not on the same machine as your Java server, then it won't be "localhost" for the servlet, so you'll need to provide the appropriate URL when you request the Spark context. Also, it looks like your Spark libraries are not available to your servlet - I don't use Java with Spark, so you'll need to check up which JARs etc you need on your application server e.g. http://stackoverflow.com/questions/23752425/how-to-use-the-spark-cluster-computing-function-in-servlets

More generally, my understanding is that the point of Spark is to distribute processing over multiple machines, so what benefits do you hope to gain from caching your data on your app server? Spark has its own caching mechanism via RDD persistence so would this be more relevant to your needs?

One thing you really want to avoid with Spark and/or Hadoop is moving lots of data around e.g. in/out of cache. Process the data in situ where possible, and only move (or cache) the results.

 
chris webster
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the Spark JARs available to your Jetty server? It may not be using your default classpath.
 
Vicky Twolaw
Greenhorn
Posts: 4
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the jar file "spark-assemply-2.10-0.9.1-hadoop2.2.0.jar" is on class path of my src and is avaialble to use in any source file.

but when I call from my servlet:



this error occurs:



chris webster wrote:Are the Spark JARs available to your Jetty server? It may not be using your default classpath.

 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic