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 com.ibm.stocator:stocator:1.0.6
  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" : "com.ibm.stocator.fs.ObjectStoreFileSystem"
"fs.swift2d.service.bmv3.auth.url" : "https://identity.open.softlayer.com/v3/auth/tokens"
"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: https://github.com/SparkTC/stocator.

For more about IBM Bluemix Object Storage services, see: https://console.ng.bluemix.net/catalog/services/object-storage

For more about Stocator in spark-packages, see:
https://spark-packages.org/package/SparkTC/stocator

Newsletter

You Might Also Enjoy

James Spyker
James Spyker
2 months ago

Streaming Transformations as Alternatives to ETL

The strategy of extracting, transforming and then loading data (ETL) to create a version of your data optimized for analytics has been around since the 1970s and its challenges are well understood. The time it takes to run an ETL job is dependent on the total data volume so that the time and resource costs rise as an enterprise’s data volume grows. The requirement for analytics databases to be mo... Read More

Seth Dobrin
Seth Dobrin
2 months ago

Non-Obvious Application of Spark™ as a Cloud-Sync Tool

When most people think about Apache Spark™, they think about analytics and machine learning. In my upcoming talk at Spark Summit East, I'll talk about leveraging Spark in conjunction with Kafka, in a hybrid cloud environment, to apply the batch and micro-batch analytic capabilities to transactional data in place of performing traditional ETL. This application of these two open source tools is a no... Read More