Monospaced | Used for commands, HTTP request and responses and code blocks. |
<Monospaced> | User entered values. |
[Monospaced] | Optional values. When the value is not specified, the default value is used. |
Italics | Important phrases and words. |
+ The HTTP REST API supports the complete FileSystem interface for HDFS. + The operations and the corresponding FileSystem methods are shown in the next section. + The Section HTTP Query Parameter Dictionary specifies the parameter details + such as the defaults and the valid values. +
+OPEN
+ (see DistributedFileSystem.open)
+ GETFILESTATUS
+ (see DistributedFileSystem.getFileStatus)
+ LISTSTATUS
+ (see DistributedFileSystem.listStatus)
+ GETCONTENTSUMMARY
+ (see DistributedFileSystem.getContentSummary)
+ GETFILECHECKSUM
+ (see DistributedFileSystem.getFileChecksum)
+ GETHOMEDIRECTORY
+ (see DistributedFileSystem.getHomeDirectory)
+ GETDELEGATIONTOKEN
+ (see DistributedFileSystem.getDelegationToken)
+ CREATE
+ (see DistributedFileSystem.create)
+ MKDIRS
+ (see DistributedFileSystem.mkdirs)
+ RENAME
+ (see DistributedFileSystem.rename)
+ SETREPLICATION
+ (see DistributedFileSystem.setReplication)
+ SETOWNER
+ (see DistributedFileSystem.setOwner)
+ SETPERMISSION
+ (see DistributedFileSystem.setPermission)
+ SETTIMES
+ (see DistributedFileSystem.setTimes)
+ RENEWDELEGATIONTOKEN
+ (see DistributedFileSystem.renewDelegationToken)
+ CANCELDELEGATIONTOKEN
+ (see DistributedFileSystem.cancelDelegationToken)
+ APPEND
+ (see DistributedFileSystem.append)
+ DELETE
+ (see DistributedFileSystem.delete)
+
+ The FileSystem scheme of WebHDFS is "webhdfs://
".
+ A WebHDFS FileSystem URI has the following format.
+
+ The above WebHDFS URI corresponds to the below HDFS URI. +
+ +
+ In the REST API, the prefix "/webhdfs/v1
" is inserted in the path and a query is appended at the end.
+ Therefore, the corresponding HTTP URL has the following format.
+
+ When security is off, the authenticated user is the username specified in the user.name
query parameter.
+ If the user.name
parameter is not set,
+ the server may either set the authenticated user to a default web user, if there is any, or return error response.
+
+ When security is on, authentication is performed by either Hadoop delegation token or Kerberos SPNEGO.
+ If a token is set in the delegation
query parameter, the authenticated user is the user encoded in the token.
+ If the delegation
parameter is not set, the user is authenticated by Kerberos SPNEGO.
+
+Below are examples using the curl
command tool.
+
+ When the proxy user feature is enabled, a proxy user P may submit a request on behalf of another user U.
+ The username of U must be specified in the doas
query parameter unless a delegation token is presented in authentication.
+ In such case, the information of both users P and U must be encoded in the delegation token.
+
Location
header with the file data to be written.
+
+The client receives a 201 Created
response with zero content length
+and the WebHDFS URI of the file in the Location
header:
+
+
+ Note that the reason of having two-step create/append is
+ for preventing clients to send out data before the redirect.
+ This issue is addressed by the "Expect: 100-continue
" header in HTTP/1.1;
+ see RFC 2616, Section 8.2.3.
+ Unfortunately, there are software library bugs (e.g. Jetty 6 HTTP server and Java 6 HTTP client),
+ which do not correctly implement "Expect: 100-continue
".
+ The two-step create/append is a temporary workaround for the software library bugs.
+
+ See also:
+ overwrite
,
+ blocksize
,
+ replication
,
+ permission
,
+ buffersize
,
+ DistributedFileSystem.create
+
Location
header with the file data to be appended.
+
+The client receives a response with zero content length:
+
+ + See the note in the previous section for the description of why this operation requires two steps. +
+
+ See also:
+ buffersize
,
+ DistributedFileSystem.append
+
+ See also:
+ offset
,
+ length
,
+ buffersize
,
+ DistributedFileSystem.open
+
boolean
JSON object:
+
+
+ See also:
+ permission
,
+ DistributedFileSystem.mkdirs
+
boolean
JSON object:
+
+
+ See also:
+ destination
,
+ DistributedFileSystem.rename
+
boolean
JSON object:
+
+
+ See also:
+ recursive
,
+ DistributedFileSystem.delete
+
FileStatus
JSON object:
+
+ + See also: + DistributedFileSystem.getFileStatus +
+FileStatuses
JSON object:
+
+ + See also: + DistributedFileSystem.listStatus +
+ContentSummary
JSON object:
+
+ + See also: + DistributedFileSystem.getContentSummary +
+FileChecksum
JSON object:
+
+ + See also: + DistributedFileSystem.getFileChecksum +
+Path
JSON object:
+
+ + See also: + DistributedFileSystem.getHomeDirectory +
+
+ See also:
+ permission
,
+ DistributedFileSystem.setPermission
+
+ See also:
+ owner
,
+ group
,
+ DistributedFileSystem.setOwner
+
boolean
JSON object:
+
+
+ See also:
+ replication
,
+ DistributedFileSystem.setReplication
+
+ See also:
+ modificationtime
,
+ accesstime
,
+ DistributedFileSystem.setTimes
+
Token
JSON object:
+
+
+ See also:
+ renewer
,
+ DistributedFileSystem.getDelegationToken
+
long
JSON object:
+
+
+ See also:
+ token
,
+ DistributedFileSystem.renewDelegationToken
+
+ See also:
+ token
,
+ DistributedFileSystem.cancelDelegationToken
+
+ When an operation fails, the server may throw an exception.
+ The JSON schema of error responses is defined in RemoteException
JSON schema.
+ The table below shows the mapping from exceptions to HTTP response codes.
+
Exceptions | HTTP Response Codes |
---|---|
IllegalArgumentException | 400 Bad Request |
UnsupportedOperationException | 400 Bad Request |
SecurityException | 401 Unauthorized |
IOException | 403 Forbidden |
FileNotFoundException | 404 Not Found |
RumtimeException | 500 Internal Server Error |
+ Below are examples of exception response. +
+ ++All operations, except for OPEN, +either return a zero-length response or a JSON response . +For OPEN, the response is an octet-stream. +The JSON schemas are shown below. +See draft-zyp-json-schema-03 +for the syntax definitions of the JSON schemas. +
+
+ See also:
+ MKDIRS
,
+ RENAME
,
+ DELETE
,
+ SETREPLICATION
+
+ See also:
+ GETCONTENTSUMMARY
+
+ See also:
+ GETFILECHECKSUM
+
+ See also:
+ GETFILESTATUS
,
+ FileStatus
+
+ JavaScript syntax is used to define fileStatusProperties
+ so that it can be referred in both FileStatus
and FileStatuses
JSON schemas.
+
+ A FileStatuses
JSON object represents an array of FileStatus
JSON objects.
+
+ See also:
+ LISTSTATUS
,
+ FileStatus
+
+ See also:
+ RENEWDELEGATIONTOKEN
,
+
+ See also:
+ GETHOMEDIRECTORY
,
+ Path
+
+ See also:
+ GETDELEGATIONTOKEN
,
+ the note in Delegation.
+
Name | accesstime |
Description | The access time of a file/directory. |
Type | long |
Default Value | -1 (means keeping it unchanged) |
Valid Values | -1 or a timestamp |
Syntax | Any integer. |
+ See also:
+ SETTIMES
+
Name | blocksize |
Description | The block size of a file. |
Type | long |
Default Value | Specified in the configuration. |
Valid Values | > 0 |
Syntax | Any integer. |
+ See also:
+ CREATE
+
Name | buffersize |
Description | The size of the buffer used in transferring data. |
Type | int |
Default Value | Specified in the configuration. |
Valid Values | > 0 |
Syntax | Any integer. |
Name | delegation |
Description | The delegation token used for authentication. |
Type | String |
Default Value | <empty> |
Valid Values | An encoded token. |
Syntax | See the note below. |
+ Note that delegation tokens are encoded as a URL safe string;
+ see encodeToUrlString()
+ and decodeFromUrlString(String)
+ in org.apache.hadoop.security.token.Token
for the details of the encoding.
+
+ See also: + Authentication +
+Name | destination |
Description | The destination path used in RENAME. |
Type | Path |
Default Value | <empty> (an invalid path) |
Valid Values | An absolute FileSystem path without scheme and authority. |
Syntax | Any path. |
+ See also:
+ RENAME
+
Name | doas |
Description | Allowing a proxy user to do as another user. |
Type | String |
Default Value | null |
Valid Values | Any valid username. |
Syntax | Any string. |
+ See also: + Proxy Users +
+Name | group |
Description | The name of a group. |
Type | String |
Default Value | <empty> (means keeping it unchanged) |
Valid Values | Any valid group name. |
Syntax | Any string. |
+ See also:
+ SETOWNER
+
Name | length |
Description | The number of bytes to be processed. |
Type | long |
Default Value | null (means the entire file) |
Valid Values | >= 0 or null |
Syntax | Any integer. |
+ See also:
+ OPEN
+
Name | modificationtime |
Description | The modification time of a file/directory. |
Type | long |
Default Value | -1 (means keeping it unchanged) |
Valid Values | -1 or a timestamp |
Syntax | Any integer. |
+ See also:
+ SETTIMES
+
Name | offset |
Description | The starting byte position. |
Type | long |
Default Value | 0 |
Valid Values | >= 0 |
Syntax | Any integer. |
+ See also:
+ OPEN
+
Name | op |
Description | The name of the operation to be executed. |
Type | enum |
Default Value | null (an invalid value) |
Valid Values | Any valid operation name. |
Syntax | Any string. |
+ See also: + Operations +
+Name | overwrite |
Description | If a file already exists, should it be overwritten? |
Type | boolean |
Default Value | false |
Valid Values | true | false |
Syntax | true | false |
+ See also:
+ CREATE
+
Name | owner |
Description | The username who is the owner of a file/directory. |
Type | String |
Default Value | <empty> (means keeping it unchanged) |
Valid Values | Any valid username. |
Syntax | Any string. |
+ See also:
+ SETOWNER
+
Name | permission |
Description | The permission of a file/directory. |
Type | Octal |
Default Value | 755 |
Valid Values | 0 - 1777 |
Syntax | Any radix-8 integer (leading zeros may be omitted.) |
+ See also:
+ CREATE
,
+ MKDIRS
,
+ SETPERMISSION
+
Name | recursive |
Description | Should the operation act on the content in the subdirectories? |
Type | boolean |
Default Value | false |
Valid Values | true | false |
Syntax | true | false |
+ See also:
+ RENAME
+
Name | renewer |
Description | The username of the renewer of a delegation token. |
Type | String |
Default Value | <empty> (means the current user) |
Valid Values | Any valid username. |
Syntax | Any string. |
+ See also:
+ GETDELEGATIONTOKEN
+
Name | replication |
Description | The number of replications of a file. |
Type | short |
Default Value | Specified in the configuration. |
Valid Values | > 0 |
Syntax | Any integer. |
+ See also:
+ CREATE
,
+ SETREPLICATION
+
Name | token |
Description | The delegation token used for the operation. |
Type | String |
Default Value | <empty> |
Valid Values | An encoded token. |
Syntax | See the note in Delegation. |
+ See also:
+ RENEWDELEGATIONTOKEN
,
+ CANCELDELEGATIONTOKEN
+
Name | user.name |
Description | The authenticated user; see Authentication. |
Type | String |
Default Value | null |
Valid Values | Any valid username. |
Syntax | Any string. |
+ See also: + Authentication +
+