Package alluxio.cli
Class AbstractShell
- java.lang.Object
-
- alluxio.cli.AbstractShell
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
@NotThreadSafe public abstract class AbstractShell extends java.lang.Object implements java.io.Closeable
Abstract class for handling command line inputs.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.common.io.Closer
mCloser
protected AlluxioConfiguration
mConfiguration
-
Constructor Summary
Constructors Constructor Description AbstractShell(java.util.Map<java.lang.String,java.lang.String[]> commandAlias, java.util.Set<java.lang.String> unstableAlias, AlluxioConfiguration conf)
Creates a new instance ofAbstractShell
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
java.util.Collection<Command>
getCommands()
protected abstract java.lang.String
getShellName()
protected abstract java.util.Map<java.lang.String,Command>
loadCommands()
Map structure: Command name =>Command
instance.protected void
printUsage()
Prints usage for all commands.int
run(java.lang.String... argv)
Handles the specified shell command request, displaying usage if the command format is invalid.
-
-
-
Field Detail
-
mConfiguration
protected final AlluxioConfiguration mConfiguration
-
mCloser
protected final com.google.common.io.Closer mCloser
-
-
Constructor Detail
-
AbstractShell
public AbstractShell(java.util.Map<java.lang.String,java.lang.String[]> commandAlias, java.util.Set<java.lang.String> unstableAlias, AlluxioConfiguration conf)
Creates a new instance ofAbstractShell
.- Parameters:
commandAlias
- replacements for commandsunstableAlias
- set of unstable aliases which may be removed in the futureconf
- Alluxio configuration
-
-
Method Detail
-
run
public int run(java.lang.String... argv)
Handles the specified shell command request, displaying usage if the command format is invalid.- Parameters:
argv
- [] Array of arguments given by the user's input from the terminal- Returns:
- 0 if command is successful, -1 if an error occurred
-
getCommands
public java.util.Collection<Command> getCommands()
- Returns:
- all commands provided by this shell
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
getShellName
protected abstract java.lang.String getShellName()
- Returns:
- name of the shell
-
loadCommands
protected abstract java.util.Map<java.lang.String,Command> loadCommands()
Map structure: Command name =>Command
instance.- Returns:
- a set of commands which can be executed under this shell
-
printUsage
protected void printUsage()
Prints usage for all commands.
-
-