Class LsCommand

  • All Implemented Interfaces:
    alluxio.cli.Command, java.io.Closeable, java.lang.AutoCloseable

    @ThreadSafe
    @PublicApi
    public final class LsCommand
    extends AbstractFileSystemCommand
    Displays information for the path specified in args. Depends on different options, this command can also display the information for all directly children under the path, or recursively.
    • Field Detail

      • IN_ALLUXIO_STATE_DIR

        public static final java.lang.String IN_ALLUXIO_STATE_DIR
        See Also:
        Constant Field Values
      • IN_ALLUXIO_STATE_FILE_FORMAT

        public static final java.lang.String IN_ALLUXIO_STATE_FILE_FORMAT
        See Also:
        Constant Field Values
      • LS_FORMAT_PERMISSION

        public static final java.lang.String LS_FORMAT_PERMISSION
        See Also:
        Constant Field Values
      • LS_FORMAT_FILE_SIZE

        public static final java.lang.String LS_FORMAT_FILE_SIZE
        See Also:
        Constant Field Values
      • LS_FORMAT_TIMESTAMP

        public static final java.lang.String LS_FORMAT_TIMESTAMP
        See Also:
        Constant Field Values
      • LS_FORMAT_ALLUXIO_STATE

        public static final java.lang.String LS_FORMAT_ALLUXIO_STATE
        See Also:
        Constant Field Values
      • LS_FORMAT_PERSISTENCE_STATE

        public static final java.lang.String LS_FORMAT_PERSISTENCE_STATE
        See Also:
        Constant Field Values
      • LS_FORMAT_USER_NAME

        public static final java.lang.String LS_FORMAT_USER_NAME
        See Also:
        Constant Field Values
      • LS_FORMAT_GROUP_NAME

        public static final java.lang.String LS_FORMAT_GROUP_NAME
        See Also:
        Constant Field Values
      • LS_FORMAT_FILE_PATH

        public static final java.lang.String LS_FORMAT_FILE_PATH
        See Also:
        Constant Field Values
      • LS_FORMAT_NO_ACL

        public static final java.lang.String LS_FORMAT_NO_ACL
        See Also:
        Constant Field Values
    • Constructor Detail

      • LsCommand

        public LsCommand​(alluxio.client.file.FileSystemContext fsContext)
        Constructs a new instance to display information for all directories and files directly under the path specified in args.
        Parameters:
        fsContext - the filesystem of Alluxio
    • Method Detail

      • formatLsString

        public static java.lang.String formatLsString​(boolean hSize,
                                                      boolean acl,
                                                      boolean isFolder,
                                                      java.lang.String permission,
                                                      java.lang.String userName,
                                                      java.lang.String groupName,
                                                      long size,
                                                      long timestamp,
                                                      int inAlluxioPercentage,
                                                      java.lang.String persistenceState,
                                                      java.lang.String path,
                                                      java.lang.String dateFormatPattern)
        Formats the ls result string.
        Parameters:
        hSize - print human-readable format sizes
        acl - whether security is enabled
        isFolder - whether this path is a file or a folder
        permission - permission string
        userName - user name
        groupName - group name
        size - size of the file in bytes
        timestamp - the epoch time in ms
        inAlluxioPercentage - whether the file is in Alluxio
        persistenceState - the persistence state of the file
        path - path of the file or folder
        dateFormatPattern - the format to follow when printing dates
        Returns:
        the formatted string according to acl and isFolder
      • getCommandName

        public java.lang.String getCommandName()
      • getOptions

        public org.apache.commons.cli.Options getOptions()
      • runPlainPath

        protected void runPlainPath​(alluxio.AlluxioURI path,
                                    org.apache.commons.cli.CommandLine cl)
                             throws alluxio.exception.AlluxioException,
                                    java.io.IOException
        Description copied from class: AbstractFileSystemCommand
        Runs the command for a particular URI that does not contain wildcard in its path.
        Overrides:
        runPlainPath in class AbstractFileSystemCommand
        Parameters:
        path - an AlluxioURI that does not contain wildcard
        cl - object containing the original commandLine
        Throws:
        alluxio.exception.AlluxioException
        java.io.IOException
      • run

        public int run​(org.apache.commons.cli.CommandLine cl)
                throws alluxio.exception.AlluxioException,
                       java.io.IOException
        Throws:
        alluxio.exception.AlluxioException
        java.io.IOException
      • getUsage

        public java.lang.String getUsage()
      • getDescription

        public java.lang.String getDescription()
      • validateArgs

        public void validateArgs​(org.apache.commons.cli.CommandLine cl)
                          throws alluxio.exception.status.InvalidArgumentException
        Throws:
        alluxio.exception.status.InvalidArgumentException