Package alluxio.cli.fs
Class FileSystemShellUtils
- java.lang.Object
-
- alluxio.cli.fs.FileSystemShellUtils
-
@ThreadSafe public final class FileSystemShellUtils extends java.lang.ObjectClass for convenience methods used byFileSystemShell.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<alluxio.AlluxioURI>getAlluxioURIs(alluxio.client.file.FileSystem alluxioClient, alluxio.AlluxioURI inputURI)Gets all theAlluxioURIs that match inputURI.static booleangetBoolArg(org.apache.commons.cli.CommandLine cl, org.apache.commons.cli.Option option, boolean defaultValue)Gets the value of an option from the command line.static java.lang.StringgetFilePath(java.lang.String path, alluxio.conf.AlluxioConfiguration alluxioConf)RemovesConstants.HEADERand hostname:port information from a path, leaving only the local file path.static java.util.List<java.io.File>getFiles(java.lang.String inputPath)Gets the files (on the local filesystem) that match the given input path.static intgetIntArg(org.apache.commons.cli.CommandLine cl, org.apache.commons.cli.Option option, int defaultValue)Gets the value of an option from the command line.static longgetMs(java.lang.String time)Converts the input time into millisecond unit.static longgetMsArg(org.apache.commons.cli.CommandLine cl, org.apache.commons.cli.Option option, long defaultValue)Gets the value of an option from the command line.static java.util.Map<java.lang.String,alluxio.cli.Command>loadCommands(alluxio.client.file.FileSystemContext fsContext)Gets allCommandinstances in the same package asFileSystemShelland load them into a map.static booleanmatch(java.lang.String filePath, java.lang.String patternPath)Returns whether or not filePath matches patternPath.static java.lang.StringvalidatePath(java.lang.String path, alluxio.conf.AlluxioConfiguration alluxioConf)Validates the path, verifying that it contains theConstants.HEADERand a hostname:port specified.
-
-
-
Method Detail
-
getFilePath
public static java.lang.String getFilePath(java.lang.String path, alluxio.conf.AlluxioConfiguration alluxioConf) throws java.io.IOExceptionRemovesConstants.HEADERand hostname:port information from a path, leaving only the local file path.- Parameters:
path- the path to obtain the local path fromalluxioConf- Alluxio configuration- Returns:
- the local path in string format
- Throws:
java.io.IOException
-
validatePath
public static java.lang.String validatePath(java.lang.String path, alluxio.conf.AlluxioConfiguration alluxioConf) throws java.io.IOExceptionValidates the path, verifying that it contains theConstants.HEADERand a hostname:port specified.- Parameters:
path- the path to be verifiedalluxioConf- Alluxio configuration- Returns:
- the verified path in a form like alluxio://host:port/dir. If only the "/dir" or "dir" part is provided, the host and port are retrieved from property, alluxio.master.hostname and alluxio.master.rpc.port, respectively.
- Throws:
java.io.IOException
-
getAlluxioURIs
public static java.util.List<alluxio.AlluxioURI> getAlluxioURIs(alluxio.client.file.FileSystem alluxioClient, alluxio.AlluxioURI inputURI) throws java.io.IOExceptionGets all theAlluxioURIs that match inputURI. If the path is a regular path, the returned list only contains the corresponding URI; Else if the path contains wildcards, the returned list contains all the matched URIs It supports any number of wildcards in inputURI- Parameters:
alluxioClient- the client used to fetch information of Alluxio filesinputURI- the input URI (could contain wildcards)- Returns:
- a list of
AlluxioURIs that matches the inputURI - Throws:
java.io.IOException
-
getFiles
public static java.util.List<java.io.File> getFiles(java.lang.String inputPath)
Gets the files (on the local filesystem) that match the given input path. If the path is a regular path, the returned list only contains the corresponding file; Else if the path contains wildcards, the returned list contains all the matched Files.- Parameters:
inputPath- The input file path (could contain wildcards)- Returns:
- a list of files that matches inputPath
-
getBoolArg
public static boolean getBoolArg(org.apache.commons.cli.CommandLine cl, org.apache.commons.cli.Option option, boolean defaultValue)Gets the value of an option from the command line.- Parameters:
cl- command line objectoption- the option to check for in the command linedefaultValue- default value for the option- Returns:
- argument from command line or default if not present
-
getIntArg
public static int getIntArg(org.apache.commons.cli.CommandLine cl, org.apache.commons.cli.Option option, int defaultValue)Gets the value of an option from the command line.- Parameters:
cl- command line objectoption- the option to check for in the command linedefaultValue- default value for the option- Returns:
- argument from command line or default if not present
-
getMsArg
public static long getMsArg(org.apache.commons.cli.CommandLine cl, org.apache.commons.cli.Option option, long defaultValue)Gets the value of an option from the command line.- Parameters:
cl- command line objectoption- the option to check for in the command linedefaultValue- default value for the option- Returns:
- argument from command line or default if not present
-
loadCommands
public static java.util.Map<java.lang.String,alluxio.cli.Command> loadCommands(alluxio.client.file.FileSystemContext fsContext)
Gets allCommandinstances in the same package asFileSystemShelland load them into a map. Provides a way to gain these commands information by their CommandName.- Parameters:
fsContext- theFileSystemContextinstance to construct the command- Returns:
- a mapping from command name to command instance
-
getMs
public static long getMs(java.lang.String time)
Converts the input time into millisecond unit.- Parameters:
time- the time to be converted into milliseconds- Returns:
- the time in millisecond unit
-
match
public static boolean match(java.lang.String filePath, java.lang.String patternPath)Returns whether or not filePath matches patternPath.- Parameters:
filePath- path of a given filepatternPath- path that can contain wildcards- Returns:
- true if matches; false if not
-
-