cacheadmin
On the command-line, you can interact with cache pools and directives via the hdfs cacheadmin
subcommand.
Cache directives are identified by a unique, non-repeating 64-bit integer ID. IDs will not be reused even if a cache directive is later removed. Cache pools are identified by a unique string name.
Cache directive commands
addDirective
Adds a new cache directive.
$ hdfs cacheadmin -addDirective -path <path> -pool <pool-name> [-force] [-replication <replication>] [-ttl <time-to-live>]
<path> |
A path to the cache. A path can be a directory or a file |
<pool-name> |
A pool to which the directive will be added. The user should have the write permission on the cache pool in order to add new directives |
-force |
Skips checking of cache pool resource limits |
<replication> |
The cache replication factor to use |
<time-to-live> |
Specifies the time period for the directive to be valid.
Can be specified in minutes, hours, and days, e.g. |
removeDirective
Removes every cache directive with the specified path.
$ hdfs cacheadmin -removeDirective <id>
<path> |
The path of the cache directives to remove. You must have the write permission on the pool of the directive in order to remove it |
listDirectives
Lists cache directives.
$ hdfs cacheadmin -listDirectives [-stats] [-path <path>] [-pool <pool>]
<path> |
Lists only cache directives with this path. If there is a cache directive for a path in a cache pool that the user doesn’t have read access for, it will not be listed |
<pool> |
Lists only path cache directives in that pool |
-stats |
Lists path-based cache directive statistics |
Cache pool commands
addPool
Adds a new cache pool.
$ hdfs cacheadmin -addPool <name> [-owner <owner>] [-group <group>] [-mode <mode>] [-limit <limit>] [-maxTtl <maxTtl>]
<name> |
A name for the new pool. |
<owner> |
The pool owner’s username. Defaults to the current user |
<group> |
The group of the pool. Defaults to the primary group name of the current user |
<mode> |
UNIX-style permissions for the pool.
Permissions are specified in octal, e.g. |
<limit> |
The maximum number of bytes that can be cached by directives in this pool, in aggregate. By default, no limit is set |
<maxTtl> |
The maximum allowed time-to-live for directives being added to the pool.
Can be specified in seconds, minutes, hours, and days, e.g. |
modifyPool
Modifies the metadata of an existing cache pool.
$ hdfs cacheadmin -modifyPool <name> [-owner <owner>] [-group <group>] [-mode <mode>] [-limit <limit>] [-maxTtl <maxTtl>]
<name> |
The name of the pool to modify |
<owner> |
The pool owner’s username |
<group> |
The name of the group of the pool |
<mode> |
Unix-style permissions of the pool in octal |
<limit> |
The maximum number of bytes that can be cached by this pool |
<maxTtl> |
The maximum allowed time-to-live for directives being added to the pool |
removePool
Removes a cache pool. This also uncaches paths associated with the pool.
$ hdfs cacheadmin -removePool <name>
<name> |
The name of the cache pool to remove |