将 Apache Spark 连接到不同的数据存储 [已弃用]
*Disclaimer: As of 01/06/2015 this project has been deprecated. Thank you for your understanding and continued help throughout the project's life.
Deep is a thin integration layer between Apache Spark and several NoSQL datastores. We actually support Apache Cassandra, MongoDB, Elastic Search, Aerospike, HDFS, S3 and any database accessible through JDBC, but in the near future we will add support for sever other datastores.
In order to compile the deep-jdbc module is necessary to add the Oracle ojdbc driver into your local repository. You can download it from the URL: http://www.oracle.com/technetwork/database/features/jdbc/default-2280470.html. When you are on the web you must click in "Accept License Agreement" and later downlad ojdbc7.jar library. You need a free oracle account to download the official driver.
To install the ojdbc driver in your local repository you must execute the command below:
mvn install:install-file -Dfile= -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar
After that you can compile Deep executing the following steps:
cd deep-parent
mvn clean install
If you want to create a Deep distribution you must execute the following steps:
cd deep-scripts
make-distribution-deep.sh
During the creation you'll see the following question:
What tag want to use for Aerospike native repository?
You must type 0.7.0 and press enter.
The integration is not based on the Cassandra's Hadoop interface.
Deep comes with an user friendly API that lets developers create Spark RDDs mapped to Cassandra column families. We provide two different interfaces:
The first one will let developers map Cassandra tables to plain old java objects (POJOs), just like if you were using any other ORM. We call this API the 'entity objects' API. This abstraction is quite handy, it will let you work on RDD (under the hood Deep will transparently map Cassandra's columns to entity properties). Your domain entities must be correctly annotated using Deep annotations (take a look at deep-core example entities in package com.stratio.deep.core.entity).
The second one is a more generic 'cell' API, that will let developerss work on RDD where a 'Cells' object is a collection of com.stratio.deep.entity.Cell objects. Column metadata is automatically fetched from the data store. This interface is a little bit more cumbersome to work with (see the example below), but has the advantage that it doesn't require the definition of additional entity classes. Example: you have a table called 'users' and you decide to use the 'Cells' interface. Once you get an instance 'c' of the Cells object, to get the value of column 'address' you can issue a c.getCellByName("address").getCellValue(). Please, refer to the Deep API documentation to know more about the Cells and Cell objects.
We encourage you to read the more comprehensive documentation hosted on the Openstratio website.
Deep comes with an example sub project called 'deep-examples' containing a set of working examples, both in Java and Scala. Please, refer to the deep-example project README for further information on how to setup a working environment.
Spark-MongoDB connector is based on Hadoop-mongoDB.
Support for MongoDB has been added in version 0.3.0.
We provide two different interfaces:
ORM API, you just have to annotate your POJOs with Deep annotations and magic will begin, you will be able to connect MongoDB with Spark using your own model entities.
Generic cell API, you do not need to specify the collection's schema or add anything to your POJOs, each document will be transform to an object "Cells".
We added a few working examples for MongoDB in deep-examples subproject, take a look at:
Entities:
Cells:
You can check out our first steps guide here:
We are working on further improvements!
Support for ElasticSearch has been added in version 0.5.0.
Support for Aerospike has been added in version 0.6.0.
Examples:
Entities:
Cells:
Support for JDBC has been added in version 0.7.0.
Examples:
Entities:
Cells:
Clone the project
To configure a development environment in Eclipse: import as Maven project. In IntelliJ: open the project by selecting the deep-parent POM file
Install the project in you local maven repository. Enter deep-parent subproject and perform: mvn clean install (add -DskipTests to skip tests)
Put Deep to work on a working cassandra + spark cluster. You have several options:
Download a pre-configured Stratio platform VM Stratio's BigData platform (SDS). This VM will work on both Virtualbox and VMWare, and comes with a fully configured distribution that also includes Stratio Deep. We also distribute the VM with several preloaded datasets in Cassandra. This distribution will include Stratio's customized Cassandra distribution containing our powerful open-source lucene-based secondary indexes, see Stratio documentation for further information. Once your VM is up and running you can test Deep using the shell. Enter /opt/sds and run bin/stratio-deep-shell.
Install a new cluster using the Stratio installer. Please refer to Stratio's website to download the installer and its documentation.
You already have a working Cassandra server on your development machine: you need a spark+deep bundle, we suggest to create one by running:
cd deep-scripts
./make-distribution-deep.sh
this will build a Spark distribution package with StratioDeep and Cassandra's jars included (depending on your machine this script could take a while, since it will compile Spark from sources).
The package will be called spark-deep-distribution-X.Y.Z.tgz, untar it to a folder of your choice, enter that folder and issue a ./stratio-deep-shell, this will start an interactive shell where you can test StratioDeep (you may have noticed this is will start a development cluster started with MASTER="local").
You already have a working installation os Cassandra and Spark on your development machine: this is the most difficult way to start testing Deep, but you know what you're doing you will have to
$SPARK_HOME/jars).import com.stratio.deep.commons.annotations._
import com.stratio.deep.commons.config._
import com.stratio.deep.commons.entity._
import com.stratio.deep.core.context._
import com.stratio.deep.cassandra.config._
import com.stratio.deep.cassandra.extractor._
import com.stratio.deep.mongodb.config._
import com.stratio.deep.mongodb.extractor._
import com.stratio.deep.es.config._
import com.stratio.deep.es.extractor._
import com.stratio.deep.aerospike.config._
import com.stratio.deep.aerospike.extractor._
import org.apache.spark.rdd._
import org.apache.spark.SparkContext._
import org.apache.spark.sql.api.java.JavaSQLContext
import org.apache.spark.sql.api.java.JavaSchemaRDD
import org.apache.spark.sql.api.java.Row
import scala.collection.JavaConversions._
Once you have a working development environment you can finally start testing Deep. This are the basic steps you will always have to perform in order to use Deep:
暂无开放 Issues,或尚未同步最近议题。