org.apache.hadoop.fs
Class FsShell

java.lang.Object
  extended by org.apache.hadoop.util.ToolBase
      extended by org.apache.hadoop.fs.FsShell
All Implemented Interfaces:
Configurable, Tool
Direct Known Subclasses:
DFSAdmin

public class FsShell
extends ToolBase

Provide command line access to a FileSystem.


Field Summary
protected  FileSystem fs
           
 
Fields inherited from class org.apache.hadoop.util.ToolBase
conf
 
Constructor Summary
FsShell()
           
 
Method Summary
static String byteDesc(long len)
          Return an abbreviated English-language desc of the byte length
 void copy(String srcf, String dstf, Configuration conf)
          Copy files that match the file pattern srcf to a destination file.
 void delete(String srcf, boolean recursive)
          Delete all files that match the file pattern srcf.
 void du(String src)
          Show the size of all files that match the file pattern src
 void dus(String src)
          Show the summary disk usage of each dir/file that matches the file pattern src
 void init()
           
static String limitDecimal(double d, int placesAfterDecimal)
           
 void ls(String srcf, boolean recursive)
          Get a listing of all files in that match the file pattern srcf.
static void main(String[] argv)
          main() has some simple utility methods
 void mkdir(String src)
          Create the given dir
 void printUsage(String cmd)
          Displays format of commands.
 void rename(String srcf, String dstf)
          Move files that match the file pattern srcf to a destination file.
 int run(String[] argv)
          run
 void setReplication(short newRep, String srcf, boolean recursive)
          Set the replication for files that match file pattern srcf if it's a directory and recursive is true, set replication for all the subdirs and those files too.
 
Methods inherited from class org.apache.hadoop.util.ToolBase
doMain, getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fs

protected FileSystem fs
Constructor Detail

FsShell

public FsShell()
Method Detail

init

public void init()
          throws IOException
Throws:
IOException

setReplication

public void setReplication(short newRep,
                           String srcf,
                           boolean recursive)
                    throws IOException
Set the replication for files that match file pattern srcf if it's a directory and recursive is true, set replication for all the subdirs and those files too.

Parameters:
newRep - new replication factor
srcf - a file pattern specifying source files
recursive - if need to set replication factor for files in subdirs
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

ls

public void ls(String srcf,
               boolean recursive)
        throws IOException
Get a listing of all files in that match the file pattern srcf.

Parameters:
srcf - a file pattern specifying source files
recursive - if need to list files in subdirs
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

du

public void du(String src)
        throws IOException
Show the size of all files that match the file pattern src

Parameters:
src - a file pattern specifying source files
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

dus

public void dus(String src)
         throws IOException
Show the summary disk usage of each dir/file that matches the file pattern src

Parameters:
src - a file pattern specifying source files
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

mkdir

public void mkdir(String src)
           throws IOException
Create the given dir

Throws:
IOException

rename

public void rename(String srcf,
                   String dstf)
            throws IOException
Move files that match the file pattern srcf to a destination file. When moving mutiple files, the destination must be a directory. Otherwise, IOException is thrown.

Parameters:
srcf - a file pattern specifying source files
dstf - a destination local file/directory
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

copy

public void copy(String srcf,
                 String dstf,
                 Configuration conf)
          throws IOException
Copy files that match the file pattern srcf to a destination file. When copying mutiple files, the destination must be a directory. Otherwise, IOException is thrown.

Parameters:
srcf - a file pattern specifying source files
dstf - a destination local file/directory
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

delete

public void delete(String srcf,
                   boolean recursive)
            throws IOException
Delete all files that match the file pattern srcf.

Parameters:
srcf - a file pattern specifying source files
recursive - if need to delete subdirs
Throws:
IOException
See Also:
FileSystem.globPaths(Path)

byteDesc

public static String byteDesc(long len)
Return an abbreviated English-language desc of the byte length


limitDecimal

public static String limitDecimal(double d,
                                  int placesAfterDecimal)

printUsage

public void printUsage(String cmd)
Displays format of commands.


run

public int run(String[] argv)
        throws Exception
run

Parameters:
argv - command specific arguments
Returns:
exit code
Throws:
Exception

main

public static void main(String[] argv)
                 throws Exception
main() has some simple utility methods

Throws:
Exception


Copyright © 2006 The Apache Software Foundation