org.apache.nutch.ndfs
Class FSDirectory

java.lang.Object
  extended byorg.apache.nutch.ndfs.FSDirectory
All Implemented Interfaces:
FSConstants

public class FSDirectory
extends Object
implements FSConstants

FSDirectory stores the filesystem directory state. It handles writing/loading values to disk, and logging changes as we go. It keeps the filename->blockset mapping always-current and logged to disk.

Author:
Mike Cafarella

Field Summary
 
Fields inherited from interface org.apache.nutch.ndfs.FSConstants
BLOCK_SIZE, BLOCKREPORT_INTERVAL, CHUNKED_ENCODING, COMPLETE_SUCCESS, DATANODE_STARTUP_PERIOD, EXPIRE_INTERVAL, HEARTBEAT_INTERVAL, LEASE_PERIOD, OBSOLETE_INTERVAL, OP_ACK, OP_BLOCKRECEIVED, OP_BLOCKREPORT, OP_CLIENT_ABANDONBLOCK, OP_CLIENT_ABANDONBLOCK_ACK, OP_CLIENT_ADDBLOCK, OP_CLIENT_ADDBLOCK_ACK, OP_CLIENT_COMPLETEFILE, OP_CLIENT_COMPLETEFILE_ACK, OP_CLIENT_DATANODE_HINTS, OP_CLIENT_DATANODE_HINTS_ACK, OP_CLIENT_DATANODEREPORT, OP_CLIENT_DATANODEREPORT_ACK, OP_CLIENT_DELETE, OP_CLIENT_DELETE_ACK, OP_CLIENT_EXISTS, OP_CLIENT_EXISTS_ACK, OP_CLIENT_ISDIR, OP_CLIENT_ISDIR_ACK, OP_CLIENT_LISTING, OP_CLIENT_LISTING_ACK, OP_CLIENT_MKDIRS, OP_CLIENT_MKDIRS_ACK, OP_CLIENT_OBTAINLOCK, OP_CLIENT_OBTAINLOCK_ACK, OP_CLIENT_OPEN, OP_CLIENT_OPEN_ACK, OP_CLIENT_RAWSTATS, OP_CLIENT_RAWSTATS_ACK, OP_CLIENT_RELEASELOCK, OP_CLIENT_RELEASELOCK_ACK, OP_CLIENT_RENAMETO, OP_CLIENT_RENAMETO_ACK, OP_CLIENT_RENEW_LEASE, OP_CLIENT_RENEW_LEASE_ACK, OP_CLIENT_STARTFILE, OP_CLIENT_STARTFILE_ACK, OP_CLIENT_TRYAGAIN, OP_ERROR, OP_FAILURE, OP_HEARTBEAT, OP_INVALIDATE_BLOCKS, OP_READ_BLOCK, OP_READSKIP_BLOCK, OP_TRANSFERBLOCKS, OP_TRANSFERDATA, OP_WRITE_BLOCK, OPERATION_FAILED, RUNLENGTH_ENCODING, STILL_WAITING, SYSTEM_STARTUP_PERIOD, WRITE_COMPLETE
 
Constructor Summary
FSDirectory(File dir)
          Create a FileSystem directory, and load its info from the indicated place.
 
Method Summary
 boolean addFile(UTF8 src, Block[] blocks)
          Add the given filename to the fs.
 void close()
          Shutdown the filestore
 Block[] delete(UTF8 src)
          Remove the file from management, return blocks
 Block[] getFile(UTF8 src)
          Get the blocks associated with the file
 NDFSFileInfo[] getListing(UTF8 src)
          Get a listing of files given path 'src' This function is admittedly very inefficient right now.
 boolean isDir(UTF8 src)
          Check whether it's a directory
 boolean isValidBlock(Block b)
          Returns whether the given block is one pointed-to by a file.
 boolean isValidToCreate(UTF8 src)
          Check whether the filepath could be created
 boolean mkdirs(UTF8 src)
          Create the given directory and all its parent dirs.
 int obtainLock(UTF8 src, UTF8 holder, boolean exclusive)
           
 int releaseLock(UTF8 src, UTF8 holder)
           
 boolean renameTo(UTF8 src, UTF8 dst)
          Change the filename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSDirectory

public FSDirectory(File dir)
            throws IOException
Create a FileSystem directory, and load its info from the indicated place.

Method Detail

close

public void close()
           throws IOException
Shutdown the filestore

Throws:
IOException

addFile

public boolean addFile(UTF8 src,
                       Block[] blocks)
Add the given filename to the fs.


renameTo

public boolean renameTo(UTF8 src,
                        UTF8 dst)
Change the filename


delete

public Block[] delete(UTF8 src)
Remove the file from management, return blocks


obtainLock

public int obtainLock(UTF8 src,
                      UTF8 holder,
                      boolean exclusive)

releaseLock

public int releaseLock(UTF8 src,
                       UTF8 holder)

getListing

public NDFSFileInfo[] getListing(UTF8 src)
Get a listing of files given path 'src' This function is admittedly very inefficient right now. We'll make it better later.


getFile

public Block[] getFile(UTF8 src)
Get the blocks associated with the file


isValidToCreate

public boolean isValidToCreate(UTF8 src)
Check whether the filepath could be created


isDir

public boolean isDir(UTF8 src)
Check whether it's a directory


mkdirs

public boolean mkdirs(UTF8 src)
Create the given directory and all its parent dirs.


isValidBlock

public boolean isValidBlock(Block b)
Returns whether the given block is one pointed-to by a file.



Copyright © 2006 The Apache Software Foundation