Support Multiple Arguments with WildCards for Alluxio Shell Commands

Description

In the high level, this JIRA aims to support taking multiple paths (with or without wildcards) as command argument.

Background

In order to support operations taking wildcard arguments, e.g., bin/alluxio fs rm files/to/rm/*, the current class hierarchy of individual Alluxio shell commands is "{Cat/Ls/Pin/...}Command extends WithWildCardPathCommand extends AbstractShellCommand".

The reason to have this extra WithWildCardPathCommand class in the middle between individual implementing classes and the abstract class, is because it provides the following abstraction to loop over all matching paths given wildcards, and invokes the implementation of the logic for each individual path on runCommand (each commands like Cat/Ls/Pin all implemented this runCommand method).

However, the limitation is that you can only support one argument as WithWildCardPathCommand requires a single argument of wildcard.
The limitation is that each command can only take one argument with wildcard (e.g., one can only run bin/alluxio fs rm files/to/rm/*, while bin/alluxio fs rm files/to/rm/* otherfiles/to/rm/* will not be able to run).

Suggested change:

In order to achieve our goal, here are suggested changes:

1.Instead of simply checking arguments alluxio.shell.command.AbstractShellCommand#validateArgs matches the expected getNumOfArgs() which is implemented by each individual classes with one constant number, we should let each command implement validateArgs as some may expect one single arg, one may expect multiple.

2. In WithWildCardPathCommand, change the following code to take more than one arg---currently it only takes args[0]

Requirement

In high level, we want to support multiple wildcard arguements. Remember, this JIRA is open ended, as long as we achieve clean code that is easy to understand and maintain.

Environment

None
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Xiaoyi Xin

Reporter

Bin Fan

Labels