The APIs for establishing connections to MapR-FS and returning filesystem handles are:
hadoop-0.20.2 and hadoop-2.x:
This API ignores the impersonation request and therefore is equivalent to hdfsConnect().
hdfsConnectAsNewUserInstance() is not supported for connections to MapR-FS fileservers.
These APIs behave in the same way:.
- If “
default” is specified for the
hostparameter, the APIs connect to the first cluster listed in the file
MAPR_HOMEdefaults to /opt/mapr.)
- If a hostname or IP address is specified for the
- Look in
MAPR_HOME/conf/mapr-clusters.confon the client node to match the specified hostname or IP address to a CLDB host and port.
- If they find a match, they try to connect to the cluster and all standard features for connections to MapR clusters are available. These features include high availability across CLDBs and secure connections.
- If they do not find a match or if they cannot locate a
mapr-clusters.conffile, they try to connect to the CLDB host specified in the call to create the connection. However, the standard features for connections to MapR clusters are not available. For example, if the cluster is secured, the connection will fail.
- Look in
It is possible to have more than one open connection at a time. For each connection, simply return the filesystem handle to a different instance of
hdfsFS, as in this example:
You can then obtain file handles for files in each connected cluster, as in this example. For each cluster, this example code calls
hdfsOpenFile(), passing in the handle to the filesystem, the absolute path to a file (and the file is created before being opened, if it doesn’t already exist) and a file-access flag that specifies to open the file in write-only mode. This mode truncates existing files to offset 0, deleting their content.
Ignore the last three parameters for this example.
hdfsOpenFile() returns a handle to the file or an error message, if the open operation fails.
After working with the files, close them and disconnect from the filesystems, as in this example: