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:
- Include the package of Stocator in your Spark application using
$SPARK_HOME/bin/spark-shell --packages com.ibm.stocator:stocator:1.0.6
- Specify the path to the jar file as the
--jarsargument, for example when using spark-submit or pyspark.
- Specify the path to the jar file as the two parameters,
Second, you'll need to configure several parameters for Spark 2.0. Here again, you have two options:
- Use the
hadoopConfiguration()method of SparkContext in the application.
- 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
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
OBJECT could be
SERVICE would be
bmv3 if you're using Bluemix. So the object’s path should be
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: