org.apache.nutch.fs
Class LocalFileSystem

java.lang.Object
  extended byorg.apache.nutch.fs.NutchFileSystem
      extended byorg.apache.nutch.fs.LocalFileSystem

public class LocalFileSystem
extends NutchFileSystem

Implement the NutchFileSystem interface for the local disk. This is pretty easy. The interface exists so we can use either remote or local Files very easily.

Author:
Mike Cafarella

Field Summary
 
Fields inherited from class org.apache.nutch.fs.NutchFileSystem
LOG
 
Constructor Summary
LocalFileSystem()
           
 
Method Summary
 void close()
          Shut down the FS.
 void completeLocalInput(File localFile)
          We're done reading.
 void completeLocalOutput(File nfsWorkingFile, File tmpLocalFile)
          It's in the right place - nothing to do.
 void copyFromLocalFile(File src, File dst)
          Similar to moveFromLocalFile(), except the source is kept intact.
 void copyToLocalFile(File src, File dst)
          We can't delete the src file in this case.
 NFSOutputStream create(File f)
          Create the file at f.
 NFSOutputStream create(File f, boolean overwrite)
           
 boolean delete(File f)
          Get rid of File f, whether a true file or dir.
 boolean exists(File f)
          Check if exists
 long getLength(File f)
           
 String getName()
          Returns a name for this filesystem, suitable to pass to NutchFileSystem.getNamed(String).
 boolean isDirectory(File f)
           
 File[] listFiles(File f)
           
 void lock(File f, boolean shared)
          Obtain a filesystem lock at File f.
 void mkdirs(File f)
          Make the given file and all non-existent parents into directories.
 void moveFromLocalFile(File src, File dst)
          In the case of the local filesystem, we can just rename the file.
 NFSInputStream open(File f)
          Open the file at f
 void release(File f)
          Release a held lock
 boolean rename(File src, File dst)
          Rename files/dirs
 File startLocalInput(File nfsInputFile, File tmpLocalFile)
          We can read directly from the real local fs.
 File startLocalOutput(File nfsOutputFile, File tmpLocalFile)
          We can write output directly to the final location
 String toString()
           
 
Methods inherited from class org.apache.nutch.fs.NutchFileSystem
createNewFile, get, getNamed, isFile, listFiles, parseArgs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalFileSystem

public LocalFileSystem()
                throws IOException
Method Detail

getName

public String getName()
Description copied from class: NutchFileSystem
Returns a name for this filesystem, suitable to pass to NutchFileSystem.getNamed(String).

Specified by:
getName in class NutchFileSystem

open

public NFSInputStream open(File f)
                    throws IOException
Open the file at f

Specified by:
open in class NutchFileSystem
Throws:
IOException

create

public NFSOutputStream create(File f)
                       throws IOException
Create the file at f.

Specified by:
create in class NutchFileSystem
Throws:
IOException

create

public NFSOutputStream create(File f,
                              boolean overwrite)
                       throws IOException
Specified by:
create in class NutchFileSystem
Throws:
IOException

rename

public boolean rename(File src,
                      File dst)
               throws IOException
Rename files/dirs

Specified by:
rename in class NutchFileSystem
Throws:
IOException

delete

public boolean delete(File f)
               throws IOException
Get rid of File f, whether a true file or dir.

Specified by:
delete in class NutchFileSystem
Throws:
IOException

exists

public boolean exists(File f)
               throws IOException
Description copied from class: NutchFileSystem
Check if exists

Specified by:
exists in class NutchFileSystem
Throws:
IOException

isDirectory

public boolean isDirectory(File f)
                    throws IOException
Specified by:
isDirectory in class NutchFileSystem
Throws:
IOException

getLength

public long getLength(File f)
               throws IOException
Specified by:
getLength in class NutchFileSystem
Throws:
IOException

listFiles

public File[] listFiles(File f)
                 throws IOException
Specified by:
listFiles in class NutchFileSystem
Throws:
IOException

mkdirs

public void mkdirs(File f)
            throws IOException
Description copied from class: NutchFileSystem
Make the given file and all non-existent parents into directories.

Specified by:
mkdirs in class NutchFileSystem
Throws:
IOException

lock

public void lock(File f,
                 boolean shared)
          throws IOException
Obtain a filesystem lock at File f.

Specified by:
lock in class NutchFileSystem
Throws:
IOException

release

public void release(File f)
             throws IOException
Release a held lock

Specified by:
release in class NutchFileSystem
Throws:
IOException

moveFromLocalFile

public void moveFromLocalFile(File src,
                              File dst)
                       throws IOException
In the case of the local filesystem, we can just rename the file.

Specified by:
moveFromLocalFile in class NutchFileSystem
Throws:
IOException

copyFromLocalFile

public void copyFromLocalFile(File src,
                              File dst)
                       throws IOException
Similar to moveFromLocalFile(), except the source is kept intact.

Specified by:
copyFromLocalFile in class NutchFileSystem
Throws:
IOException

copyToLocalFile

public void copyToLocalFile(File src,
                            File dst)
                     throws IOException
We can't delete the src file in this case. Too bad.

Specified by:
copyToLocalFile in class NutchFileSystem
Throws:
IOException

startLocalOutput

public File startLocalOutput(File nfsOutputFile,
                             File tmpLocalFile)
                      throws IOException
We can write output directly to the final location

Specified by:
startLocalOutput in class NutchFileSystem
Throws:
IOException

completeLocalOutput

public void completeLocalOutput(File nfsWorkingFile,
                                File tmpLocalFile)
                         throws IOException
It's in the right place - nothing to do.

Specified by:
completeLocalOutput in class NutchFileSystem
Throws:
IOException

startLocalInput

public File startLocalInput(File nfsInputFile,
                            File tmpLocalFile)
                     throws IOException
We can read directly from the real local fs.

Specified by:
startLocalInput in class NutchFileSystem
Throws:
IOException

completeLocalInput

public void completeLocalInput(File localFile)
                        throws IOException
We're done reading. Nothing to clean up.

Specified by:
completeLocalInput in class NutchFileSystem
Throws:
IOException

close

public void close()
           throws IOException
Shut down the FS. Not necessary for regular filesystem.

Specified by:
close in class NutchFileSystem
Throws:
IOException

toString

public String toString()


Copyright © 2006 The Apache Software Foundation