<commit_before>Stocator - Storage Connector for Apache Spark
==============================
Apache Spark can work with multiple data sources that include object stores like Amazon S3, OpenStack Swift, IBM SoftLayer, and more. To access an object store, Spark uses Hadoop modules that contain drivers to the various object stores. 

Spark needs only small set of object store functionalities. Specifically, Spark requires object listing, objects creation, read objects, and getting data partitions. Hadoop drivers, however, must be compliant with the Hadoop eco system. This means they support many more operations, such as shell operations on directories, including move, copy, rename, etc. (these are not native object store operations). Moreover, Hadoop Map Reduce Client is designed to work with file systems and not object stores. The temp files and folders it uses for every write operation are renamed, copied, and deleted. This leads to dozens of useless requests targeted at the object store. It’s clear that Hadoop is designed to work with file systems and not object stores.

Stocator is implicitly designed for the object stores, it has very a different architecture from the existing Hadoop driver. It doesn’t depends on robust Hadoop modules and interacts directly with object stores. 

Stocator is a generic connector, that may contain various implementations for object stores. It initially provided with complete Swift driver, based on the JOSS package. Stocator can be very easily extended with more object store implementations, like support for Amazon S3.

## Major features
* Implements HDFS interface
* No need to change or recompile Spark
* Doesn’t create any temporary folders or files for write operations. Each Spark's task generates only one object in the object store
* There are no notions of directories (usually defined as empty files)
* Object's name may contain "/"
* Containers / buckets are automatically created
* (Swift Driver) Uses streaming for object uploads, without knowing object size. This is unique to OpenStack Swift
* (Swift Driver) Tested to read large objects (over 16GB)

## Build procedure

Checkout the Stocator source `https://github.com/SparkTC/stocator.git`

### JOSS and Keystone V3 API
Swift driver uses JOSS to access OpenStack Swift. Currently JOSS supports Keystone V2 and Swift auth models. 
Some object store providers expose Keystone V3 API (for example IBM Bluemix Object Store). The patch extending JOSS with Keystone V3 support exists, but is not yet merged into JOSS.
Below are instructions how to install JOSS locally and compile with Keystone V3 support

* git clone https://github.com/javaswift/joss
* cd joss
* copy `keystone-v3-0.9.10-0001.patch` from `../stocator/additions/joss/patch` to `joss`
* git apply keystone-v3-0.9.10-0001.patch
* mvn clean install

This will compile JOSS and install it into local maven repository. 
You are now ready to compile Stocator.

### How to build Stocator
* Change directory to `stocator`
* Execute `mvn install`

## Usage with Apache Spark
New Swift's driver can be accessed via new schema `swift2d://`.
The configuration template located under `conf/core-site.xml.template`.

### Reference the new driver in the core-site.xml
Add driver reference in the `conf/core-site.xml` of Spark

	<property>
   		<name>fs.swift2d.impl</name>
   		<value>com.ibm.stocator.fs.ObjectStoreFileSystem</value>
	</property>

#### Swift Driver configuration
The following is the list of the configuration keys.

| Key | Info | Default value |
| --- | ------------ | ------------- |
|fs.swift2d.service.lvm.auth.url | Mandatory |
|fs.swift2d.service.lvm.public | Optional. Values: true, false | false | 
|fs.swift2d.service.lvm.tenant | Mandatory |
|fs.swift2d.service.lvm.password |  Mandatory |
|fs.swift2d.service.lvm.username | Mandatory |
|fs.swift2d.service.lvm.region | Mandatory for Keystone V3 | dallas
|fs.swift2d.service.lvm.auth.method | Optional. Values: keystone, swiftauth, keystoneV3| keystoneV3

Below is the internal Keystone V3 mapping

| Driver configuration key | Keystone V3 key |
| ------------------------ | --------------- |
| fs.swift2d.service.lvm.username | user id |
| fs.swift2d.service.lvm.tenant | project id |<commit_msg>added block.size configuration entry<commit_after>Stocator - Storage Connector for Apache Spark
==============================
Apache Spark can work with multiple data sources that include object stores like Amazon S3, OpenStack Swift, IBM SoftLayer, and more. To access an object store, Spark uses Hadoop modules that contain drivers to the various object stores. 

Spark needs only small set of object store functionalities. Specifically, Spark requires object listing, objects creation, read objects, and getting data partitions. Hadoop drivers, however, must be compliant with the Hadoop eco system. This means they support many more operations, such as shell operations on directories, including move, copy, rename, etc. (these are not native object store operations). Moreover, Hadoop Map Reduce Client is designed to work with file systems and not object stores. The temp files and folders it uses for every write operation are renamed, copied, and deleted. This leads to dozens of useless requests targeted at the object store. It’s clear that Hadoop is designed to work with file systems and not object stores.

Stocator is implicitly designed for the object stores, it has very a different architecture from the existing Hadoop driver. It doesn’t depends on robust Hadoop modules and interacts directly with object stores. 

Stocator is a generic connector, that may contain various implementations for object stores. It initially provided with complete Swift driver, based on the JOSS package. Stocator can be very easily extended with more object store implementations, like support for Amazon S3.

## Major features
* Implements HDFS interface
* No need to change or recompile Spark
* Doesn’t create any temporary folders or files for write operations. Each Spark's task generates only one object in the object store
* There are no notions of directories (usually defined as empty files)
* Object's name may contain "/"
* Containers / buckets are automatically created
* (Swift Driver) Uses streaming for object uploads, without knowing object size. This is unique to OpenStack Swift
* (Swift Driver) Tested to read large objects (over 16GB)

## Build procedure

Checkout the Stocator source `https://github.com/SparkTC/stocator.git`

### JOSS and Keystone V3 API
Swift driver uses JOSS to access OpenStack Swift. Currently JOSS supports Keystone V2 and Swift auth models. 
Some object store providers expose Keystone V3 API (for example IBM Bluemix Object Store). The patch extending JOSS with Keystone V3 support exists, but is not yet merged into JOSS.
Below are instructions how to install JOSS locally and compile with Keystone V3 support

* git clone https://github.com/javaswift/joss
* cd joss
* copy `keystone-v3-0.9.10-0001.patch` from `../stocator/additions/joss/patch` to `joss`
* git apply keystone-v3-0.9.10-0001.patch
* mvn clean install

This will compile JOSS and install it into local maven repository. 
You are now ready to compile Stocator.

### How to build Stocator
* Change directory to `stocator`
* Execute `mvn install`

## Usage with Apache Spark
New Swift's driver can be accessed via new schema `swift2d://`.
The configuration template located under `conf/core-site.xml.template`.

### Reference the new driver in the core-site.xml
Add driver reference in the `conf/core-site.xml` of Spark

	<property>
   		<name>fs.swift2d.impl</name>
   		<value>com.ibm.stocator.fs.ObjectStoreFileSystem</value>
	</property>

#### Swift Driver configuration
The following is the list of the configuration keys.

| Key | Info | Default value |
| --- | ------------ | ------------- |
|fs.swift2d.service.lvm.auth.url | Mandatory |
|fs.swift2d.service.lvm.public | Optional. Values: true, false | false | 
|fs.swift2d.service.lvm.tenant | Mandatory |
|fs.swift2d.service.lvm.password |  Mandatory |
|fs.swift2d.service.lvm.username | Mandatory |
|fs.swift2d.service.lvm.block.size | Block size in MB | 128MB |
|fs.swift2d.service.lvm.region | Mandatory for Keystone V3 | dallas
|fs.swift2d.service.lvm.auth.method | Optional. Values: keystone, swiftauth, keystoneV3| keystoneV3

Below is the internal Keystone V3 mapping

| Driver configuration key | Keystone V3 key |
| ------------------------ | --------------- |
| fs.swift2d.service.lvm.username | user id |
| fs.swift2d.service.lvm.tenant | project id |
{'fraction_non_alphanumeric': 0.08907543430103766, 'fraction_numerical': 0.01049317943336831, 'mean_word_length': 4.183081570996979, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1101086', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2250, 'n_words': 1075}