Package alluxio.cli
Class CommandUtils
- java.lang.Object
-
- alluxio.cli.CommandUtils
-
@ThreadSafe public final class CommandUtils extends java.lang.Object
Class for convenience methods used by instances ofCommand
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkNumOfArgsEquals(Command cmd, org.apache.commons.cli.CommandLine cl, int n)
Checks the number of non-option arguments equals n for command.static void
checkNumOfArgsNoLessThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n)
Checks the number of non-option arguments is no less than n for command.static void
checkNumOfArgsNoMoreThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n)
Checks the number of non-option arguments is no more than n for command.static java.util.Map<java.lang.String,Command>
loadCommands(java.lang.String pkgName, java.lang.Class[] classArgs, java.lang.Object[] objectArgs)
Get instances of all subclasses ofCommand
in a sub-package called "command" the given package.static java.util.Set<java.lang.String>
readNodeList(java.lang.String confDir, java.lang.String fileName)
Reads a list of nodes from given file name ignoring comments and empty lines.
-
-
-
Method Detail
-
loadCommands
public static java.util.Map<java.lang.String,Command> loadCommands(java.lang.String pkgName, java.lang.Class[] classArgs, java.lang.Object[] objectArgs)
Get instances of all subclasses ofCommand
in a sub-package called "command" the given package.- Parameters:
pkgName
- package prefix to look inclassArgs
- type of args to instantiate the classobjectArgs
- args to instantiate the class- Returns:
- a mapping from command name to command instance
-
checkNumOfArgsEquals
public static void checkNumOfArgsEquals(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
Checks the number of non-option arguments equals n for command.- Parameters:
cmd
- command instancecl
- parsed commandline argumentsn
- an integer- Throws:
InvalidArgumentException
- if the number does not equal n
-
checkNumOfArgsNoLessThan
public static void checkNumOfArgsNoLessThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
Checks the number of non-option arguments is no less than n for command.- Parameters:
cmd
- command instancecl
- parsed commandline argumentsn
- an integer- Throws:
InvalidArgumentException
- if the number is smaller than n
-
checkNumOfArgsNoMoreThan
public static void checkNumOfArgsNoMoreThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
Checks the number of non-option arguments is no more than n for command.- Parameters:
cmd
- command instancecl
- parsed commandline argumentsn
- an integer- Throws:
InvalidArgumentException
- if the number is greater than n
-
readNodeList
@Nullable public static java.util.Set<java.lang.String> readNodeList(java.lang.String confDir, java.lang.String fileName)
Reads a list of nodes from given file name ignoring comments and empty lines. Can be used to read conf/workers or conf/masters.- Parameters:
confDir
- directory that holds the configurationfileName
- name of a file that contains the list of the nodes- Returns:
- list of the node names, null when file fails to read
-
-