Package alluxio.cli

Class CommandUtils


  • @ThreadSafe
    public final class CommandUtils
    extends java.lang.Object
    Class for convenience methods used by instances of Command.
    • 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 of Command 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 of Command in a sub-package called "command" the given package.
        Parameters:
        pkgName - package prefix to look in
        classArgs - type of args to instantiate the class
        objectArgs - 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 instance
        cl - parsed commandline arguments
        n - 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 instance
        cl - parsed commandline arguments
        n - 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 instance
        cl - parsed commandline arguments
        n - 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 configuration
        fileName - name of a file that contains the list of the nodes
        Returns:
        list of the node names, null when file fails to read