Package alluxio.cli

Class 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.
    • 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 of AbstractShell.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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 of AbstractShell.
        Parameters:
        commandAlias - replacements for commands
        unstableAlias - set of unstable aliases which may be removed in the future
        conf - 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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.