| Hadoop Distributed File System (HDFS) | `hdfs://` | All HDFS versions are supported |
| Amazon S3 | `s3://` | Support through Hadoop file system implementation (see below) |
| MapR file system | `maprfs://` | The user has to manually place the required jar files in the `lib/` dir |
| Tachyon | `tachyon://` | Support through Hadoop file system implementation (see below) |
### Using Hadoop file system implementations
Apache Flink allows users to use any file system implementing the `org.apache.hadoop.fs.FileSystem`
interface. There are Hadoop `FileSystem` implementations for
-[S3](https://aws.amazon.com/s3/)(tested)
-[Google Cloud Storage Connector for Hadoop](https://cloud.google.com/hadoop/google-cloud-storage-connector)(tested)
-[Tachyon](http://tachyon-project.org/)(tested)
-[XtreemFS](http://www.xtreemfs.org/)(tested)
- FTP via [Hftp](http://hadoop.apache.org/docs/r1.2.1/hftp.html)(not tested)
- and many more.
In order to use a Hadoop file system with Flink, make sure that
- the `flink-conf.yaml` has set the `fs.hdfs.hadoopconf` property set to the Hadoop configuration directory.
- the Hadoop configuration (in that directory) has an entry for the required file system. Examples for S3 and Tachyon are shown below.
- the required classes for using the file system are available in the `lib/` folder of the Flink installation (on all machines running Flink). If putting the files into the directory is not possible, Flink is also respecting the `HADOOP_CLASSPATH` environment variable to add Hadoop jar files to the classpath.
#### Amazon S3
For Amazon S3 support add the following entries into the `core-site.xml` file:
Note that `User` is a POJO generated by Avro. Flink also allows to perform string-based key selection of these POJOs. For example:
~~~java
usersDS.groupBy("name")
~~~
Note that using the `GenericData.Record` type is possible with Flink, but not recommended. Since the record contains the full schema, its very data intensive and thus probably slow to use.
Flink's POJO field selection also works with POJOs generated from Avro. However, the usage is only possible if the field types are written correctly to the generated class. If a field is of type `Object` you can not use the field as a join or grouping key.
Specifying a field in Avro like this `{"name": "type_double_test", "type": "double"},` works fine, however specifying it as a UNION-type with only one field (`{"name": "type_double_test", "type": ["double"]},`) will generate a field of type `Object`. Note that specifying nullable types (`{"name": "type_double_test", "type": ["null", "double"]},`) is possible!
### Access Microsoft Azure Table Storage
_Note: This example works starting from Flink 0.6-incubating_
This example is using the `HadoopInputFormat` wrapper to use an existing Hadoop input format implementation for accessing [Azure's Table Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-introduction/).
1. Download and compile the `azure-tables-hadoop` project. The input format developed by the project is not yet available in Maven Central, therefore, we have to build the project ourselves.
`flink-hadoop-compatibility` is a Flink package that provides the Hadoop input format wrappers.
`microsoft-hadoop-azure` is adding the project we've build before to our project.
The project is now prepared for starting to code. We recommend to import the project into an IDE, such as Eclipse or IntelliJ. (Import as a Maven project!).
Browse to the code of the `Job.java` file. Its an empty skeleton for a Flink job.
System.err.println("key="+prop.getKey()+" ; value (asString)="+prop.getValue().getValueAsString());
}
returnarg0.f0.toString();
}
});
// emit result (this works only locally)
fin.print();
// execute program
env.execute("Azure Example");
}
}
~~~
The example shows how to access an Azure table and turn data into Flink's `DataSet` (more specifically, the type of the set is `DataSet<Tuple2<Text, WritableEntity>>`). With the `DataSet`, you can apply all known transformations to the DataSet.
## Access MongoDB
This [GitHub repository documents how to use MongoDB with Apache Flink (starting from 0.7-incubating)](https://github.com/okkam-it/flink-mongodb-test).