Class FsShell

All Implemented Interfaces:
Configurable, Tool

@Private public class FsShell extends Configured implements Tool
Provide command line access to a FileSystem.
  • Field Details

  • Constructor Details

    • FsShell

      public FsShell()
      Default ctor with no configuration. Be sure to invoke Configured.setConf(Configuration) with a valid configuration prior to running commands.
    • FsShell

      public FsShell(Configuration conf)
      Construct a FsShell with the given configuration. Commands can be executed via run(String[])
      Parameters:
      conf - the hadoop configuration
  • Method Details

    • getFS

      protected FileSystem getFS() throws IOException
      Throws:
      IOException
    • getTrash

      protected Trash getTrash() throws IOException
      Throws:
      IOException
    • getHelp

      protected FsShell.Help getHelp() throws IOException
      Throws:
      IOException
    • init

      protected void init()
    • registerCommands

      protected void registerCommands(CommandFactory factory)
    • getCurrentTrashDir

      public Path getCurrentTrashDir() throws IOException
      Returns the Trash object associated with this shell.
      Returns:
      Path to the trash
      Throws:
      IOException - upon error
    • getCurrentTrashDir

      public Path getCurrentTrashDir(Path path) throws IOException
      Returns the current trash location for the path specified
      Parameters:
      path - to be deleted
      Returns:
      path to the trash
      Throws:
      IOException - raised on errors performing I/O.
    • getUsagePrefix

      protected String getUsagePrefix()
    • run

      public int run(String[] argv)
      run
      Specified by:
      run in interface Tool
      Parameters:
      argv - command specific arguments.
      Returns:
      exit code.
    • close

      public void close() throws IOException
      Performs any necessary cleanup
      Throws:
      IOException - upon error
    • main

      public static void main(String[] argv) throws Exception
      main() has some simple utility methods
      Parameters:
      argv - the command and its arguments
      Throws:
      Exception - upon error
    • newShellInstance

      protected static FsShell newShellInstance()