org.apache.hadoop.hdfs.protocol
Class Block

java.lang.Object
  extended by org.apache.hadoop.hdfs.protocol.Block
All Implemented Interfaces:
Comparable<Block>, org.apache.hadoop.io.Writable
Direct Known Subclasses:
ReplicaInfo, ReplicaRecoveryInfo

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class Block
extends Object
implements org.apache.hadoop.io.Writable, Comparable<Block>

A Block is a Hadoop FS primitive, identified by a long.


Field Summary
static String BLOCK_FILE_PREFIX
           
static Pattern blockFilePattern
           
static String METADATA_EXTENSION
           
static Pattern metaFilePattern
           
 
Constructor Summary
Block()
           
Block(Block blk)
           
Block(File f, long len, long genstamp)
          Find the blockid from the given filename
Block(long blkid)
           
Block(long blkid, long len, long generationStamp)
           
 
Method Summary
 int compareTo(Block b)
           
 boolean equals(Object o)
           
static long filename2id(String name)
           
 long getBlockId()
           
static long getBlockId(String metaFile)
          Get the blockId from the name of the metafile name
 String getBlockName()
           
 long getGenerationStamp()
           
static long getGenerationStamp(String metaFile)
          Get generation stamp from the name of the metafile name
 long getNumBytes()
           
 int hashCode()
           
static boolean isBlockFilename(File f)
           
static boolean isMetaFilename(String name)
           
 void readFields(DataInput in)
           
 void set(long blkid, long len, long genStamp)
           
 void setBlockId(long bid)
           
 void setGenerationStamp(long stamp)
           
 void setNumBytes(long len)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BLOCK_FILE_PREFIX

public static final String BLOCK_FILE_PREFIX
See Also:
Constant Field Values

METADATA_EXTENSION

public static final String METADATA_EXTENSION
See Also:
Constant Field Values

blockFilePattern

public static final Pattern blockFilePattern

metaFilePattern

public static final Pattern metaFilePattern
Constructor Detail

Block

public Block()

Block

public Block(long blkid,
             long len,
             long generationStamp)

Block

public Block(long blkid)

Block

public Block(Block blk)

Block

public Block(File f,
             long len,
             long genstamp)
Find the blockid from the given filename

Method Detail

isBlockFilename

public static boolean isBlockFilename(File f)

filename2id

public static long filename2id(String name)

isMetaFilename

public static boolean isMetaFilename(String name)

getGenerationStamp

public static long getGenerationStamp(String metaFile)
Get generation stamp from the name of the metafile name


getBlockId

public static long getBlockId(String metaFile)
Get the blockId from the name of the metafile name


set

public void set(long blkid,
                long len,
                long genStamp)

getBlockId

public long getBlockId()

setBlockId

public void setBlockId(long bid)

getBlockName

public String getBlockName()

getNumBytes

public long getNumBytes()

setNumBytes

public void setNumBytes(long len)

getGenerationStamp

public long getGenerationStamp()

setGenerationStamp

public void setGenerationStamp(long stamp)

toString

public String toString()
Overrides:
toString in class Object

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

compareTo

public int compareTo(Block b)
Specified by:
compareTo in interface Comparable<Block>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2009 The Apache Software Foundation