Client Virtual Path Mapping
Overview
Alluxio supports mapping one path to another. All read/write and metadata operation requests will not be performed on the original path, but will instead be redirected to the mapped path.
The current client virtual path mapping is only applicable to Alluxio Fuse and the Alluxio CLI.
Enable Virtual Path Mapping
The path_mapping.json
file is a JSON file that describes the mapping relationships between paths.
Here is a simple example: suppose you want to map /a/b/c/xxx
to /b/c/d/xxx
, you can configure it like this:
Here, src
is a regular expression matching the original path. Parentheses are used to capture values, which can then be used in the dst
using var
placeholders:
var1
refers to the first captured group,var2
to the second, and so on.varN
represents the N-th captured group.
As another example, suppose we want the following path mappings:
The configuration file can be written as follows. Note: when writing the \
character in a JSON file, it must be escaped as \\
because \
is a JSON escape character:
Note: Mapping rules are matched from top to bottom. Only the first matching rule takes effect. If no rule matches a given path, the original path is used as the mapped path.
Path Mapping Validation Tool
A command-line tool is provided to verify that your path mapping rules behave as expected. It is strongly recommended to use this tool before deploying:
The Output
field shows the mapped path. If no rule matches the input path, the value of Output
will be null
.
The meaning of the Virtual Directory
field is explained in the following section.
Fuse Path Mapping (Important)
The virtual path mapping configuration uses Alluxio's cluster paths. When applied to local paths through Alluxio Fuse, the Fuse mount path must be taken into account.
Take the following rule as an example:
The following commands are equivalent, since /a/b/c
is mapped to /a1/b1/c
:
Assuming Alluxio Fuse is mounted locally at /mnt/alluxio/alluxio-fuse
, then the above rule effectively maps
/mnt/alluxio/alluxio-fuse/a/b/c
to /mnt/alluxio/alluxio-fuse/a1/b1/c
.
Therefore, the following commands are equivalent in this context:
Virtual Directories
When accessing a file via Alluxio Fuse, Alluxio will check if the file’s parent directories exist. If a parent directory is missing, an error is thrown.
Consider this rule:
When reading /a/b/c
, Alluxio Fuse will check whether the parent path /a/b
exists. If /a/b
is missing, an error will occur.
This check is unrelated to whether the mapped path /a1/b1
exists. To avoid such errors, you can configure virtual directories:
The virtualDirectories
field can contain multiple regex expressions, which are matched in order.
Paths matching virtualDirectories
are always treated as existing directories.
You can validate virtual directories using the command-line tool:
The Virtual Directory
field in the output indicates whether the path matches a virtual directory.
Limitations
Number of Rules
Virtual path mapping is not suitable for scenarios with a large number of rules, as matching each rule with a regular expression can affect performance.
ls
Limitations
ls
LimitationsWhen listing a directory using ls
, not all matched sub-paths will be visible.
For example, with the following mapping rules:
Running ls /foo/bar
will not show:
However, you can still access content directly under /foo/bar
, such as:
Last updated