Using Stocator to Connect Object Stores to Apache Spark™ 2.0

In a previous blog post, Gil Vernik gave a high-level overview of Stocator, a driver to access data in an object store. After the release of Apache Spark™ 2.0, we tested the process of connecting to object storage and Spark using the Stocator driver — and found that it works seamlessly with Spark 2.0.

This blog will cover the three basic steps to use the Stocator driver in Spark 2.0 to access object storage, in the case that the Spark is not recompiled with Stocator.

First, after building the Stocator project and generating a jar file, make sure the jar file appears in the Spark classpath. You can do this in either of three ways:

  1. Include the package of Stocator in your Spark application using --packages, e.g. $SPARK_HOME/bin/spark-shell --packages
  2. Specify the path to the jar file as the --jars argument, for example when using spark-submit or pyspark.
  3. Specify the path to the jar file as the two parameters, spark.driver.extraClassPath and
    spark.executor.extraClassPath in the $SPARK_HOME/conf/spark-defaults.conf file.

Second, you'll need to configure several parameters for Spark 2.0. Here again, you have two options:

  1. Use the hadoopConfiguration() method of SparkContext in the application.
  2. Add the dependency to Stocator in conf/core-site.xml of Hadoop.

For example, if you're using the Bluemix Object Service and thus the SERVICE_NAME is bmv3, the parameters are...

"fs.swift2d.impl" : ""
"fs.swift2d.service.bmv3.auth.url" : ""
"fs.swift2d.service.bmv3.public" : "true"
"fs.swift2d.service.bmv3.tenant" : "projectId on Bluemix"
"fs.swift2d.service.bmv3.password" : "password on Bluemix"
"fs.swift2d.service.bmv3.username" : "userId on Bluemix"
"fs.swift2d.service.bmv3.auth.method" : "keystoneV3"
"fs.swift2d.service.bmv3.region" : "dallas"

Third, provide the target object path as swift2d://CONTAINER.SERVICE/OBJECT, for instance CONTAINER could be test and OBJECT could be data1.json. SERVICE would be bmv3 if you're using Bluemix. So the object’s path should be swift2d://test.bmv3/data1.json.

We also ran a basic comparison of object access performance between the Hadoop Openstack and the Stocator driver via Spark 2.0. As mentioned in Gil’s blog, here again we found that Stocator has a performance gain when writing data over the Hadoop Openstack driver.

For more details about the Stocator project on Git, see:

For more about IBM Bluemix Object Storage services, see:

For more about Stocator in spark-packages, see:


You Might Also Enjoy

Kevin Bates
Kevin Bates
9 months ago

Limit Notebook Resource Consumption by Culling Kernels

There’s no denying that data analytics is the next frontier on the computational landscape. Companies are scrambling to establish teams of data scientists to better understand their clientele and how best to evolve product solutions to the ebb and flow of today’s business ecosystem. With Apache Hadoop and Apache Spark entrenched as the analytic engine and coupled with a trial-and-error model to... Read More

Gidon Gershinsky
Gidon Gershinsky
a year ago

How Alluxio is Accelerating Apache Spark Workloads

Alluxio is fast virtual storage for Big Data. Formerly known as Tachyon, it’s an open-source memory-centric virtual distributed storage system (yes, all that!), offering data access at memory speed and persistence to a reliable storage. This technology accelerates analytic workloads in certain scenarios, but doesn’t offer any performance benefits in other scenarios. The purpose of this blog is to... Read More