|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.dfs.NameNode
NameNode serves as both directory namespace manager and "inode table" for the Hadoop DFS. There is a single NameNode running in any DFS deployment. (Well, except when there is a second backup/failover NameNode.) The NameNode controls two critical tables: 1) filename->blocksequence (namespace) 2) block->machinelist ("inodes") The first table is stored on disk and is very precious. The second table is rebuilt every time the NameNode comes up. 'NameNode' refers to both this class as well as the 'NameNode server'. The 'FSNamesystem' class actually performs most of the filesystem management. The majority of the 'NameNode' class itself is concerned with exposing the IPC interface to the outside world, plus some configuration management. NameNode implements the ClientProtocol interface, which allows clients to ask for DFS services. ClientProtocol is not designed for direct use by authors of DFS client code. End-users should instead use the org.apache.nutch.hadoop.fs.FileSystem class. NameNode also implements the DatanodeProtocol interface, used by DataNode programs that actually store DFS data blocks. These methods are invoked repeatedly and automatically by all the DataNodes in a DFS deployment.
Field Summary | |
static int |
DISK_ERROR
|
static int |
INVALID_BLOCK
|
static org.apache.commons.logging.Log |
LOG
|
static org.apache.commons.logging.Log |
stateChangeLog
|
Constructor Summary | |
NameNode(Configuration conf)
Create a NameNode at the default location |
|
NameNode(File dir,
int port,
Configuration conf)
Create a NameNode at the specified location and start it. |
Method Summary | |
void |
abandonBlock(org.apache.hadoop.dfs.Block b,
String src)
The client needs to give up on the block. |
void |
abandonFileInProgress(String src,
String holder)
A client that wants to abandon writing to the current file should call abandonFileInProgress(). |
org.apache.hadoop.dfs.LocatedBlock |
addBlock(String src,
String clientName)
A client that wants to write an additional block to the indicated filename (which must currently be open for writing) should call addBlock(). |
void |
blockReceived(org.apache.hadoop.dfs.DatanodeRegistration nodeReg,
org.apache.hadoop.dfs.Block[] blocks)
blockReceived() allows the DataNode to tell the NameNode about recently-received block data. |
org.apache.hadoop.dfs.Block[] |
blockReport(org.apache.hadoop.dfs.DatanodeRegistration nodeReg,
org.apache.hadoop.dfs.Block[] blocks)
blockReport() tells the NameNode about all the locally-stored blocks. |
boolean |
complete(String src,
String clientName)
The client is done writing data to the given filename, and would like to complete it. |
org.apache.hadoop.dfs.LocatedBlock |
create(String src,
String clientName,
String clientMachine,
boolean overwrite,
short replication,
long blockSize)
Create a new file. |
boolean |
delete(String src)
Remove the given filename from the filesystem |
void |
errorReport(org.apache.hadoop.dfs.DatanodeRegistration nodeReg,
int errorCode,
String msg)
errorReport() tells the NameNode about something that has gone awry. |
boolean |
exists(String src)
Check whether the given file exists |
static void |
format(Configuration conf)
Format a new filesystem. |
long |
getBlockSize(String filename)
Get the block size for the given file. |
DatanodeInfo[] |
getDatanodeReport()
Get a full report on the system's current datanodes. |
String[][] |
getHints(String src,
long start,
long len)
getHints() returns a list of hostnames that store data for a specific file region. |
org.apache.hadoop.dfs.DFSFileInfo[] |
getListing(String src)
Get a listing of the indicated directory |
long[] |
getStats()
Get a set of statistics about the filesystem. |
boolean |
isDir(String src)
Check whether the given filename is a directory or not. |
void |
join()
Wait for service to finish. |
static void |
main(String[] argv)
|
boolean |
mkdirs(String src)
Create a directory (or hierarchy of directories) with the given name. |
boolean |
obtainLock(String src,
String clientName,
boolean exclusive)
obtainLock() is used for lock managemnet. |
org.apache.hadoop.dfs.LocatedBlock[] |
open(String src)
Open an existing file, at the given name. |
org.apache.hadoop.dfs.DatanodeRegistration |
register(org.apache.hadoop.dfs.DatanodeRegistration nodeReg)
Register Datanode. |
boolean |
releaseLock(String src,
String clientName)
releaseLock() is called if the client would like to release a held lock. |
boolean |
rename(String src,
String dst)
Rename an item in the fs namespace |
void |
renewLease(String clientName)
Client programs can cause stateful changes in the NameNode that affect other clients. |
void |
reportWrittenBlock(org.apache.hadoop.dfs.LocatedBlock lb)
The client can report in a set written blocks that it wrote. |
org.apache.hadoop.dfs.BlockCommand |
sendHeartbeat(org.apache.hadoop.dfs.DatanodeRegistration nodeReg,
long capacity,
long remaining,
int xmitsInProgress)
Data node notify the name node that it is alive Return a block-oriented command for the datanode to execute. |
boolean |
setReplication(String src,
short replication)
Set replication for an existing file. |
void |
verifyRequest(org.apache.hadoop.dfs.DatanodeRegistration nodeReg)
Verify request. |
void |
verifyVersion(int version)
Verify version. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final org.apache.commons.logging.Log LOG
public static final org.apache.commons.logging.Log stateChangeLog
public static final int DISK_ERROR
public static final int INVALID_BLOCK
Constructor Detail |
public NameNode(Configuration conf) throws IOException
public NameNode(File dir, int port, Configuration conf) throws IOException
Method Detail |
public static void format(Configuration conf) throws IOException
IOException
public void join()
public org.apache.hadoop.dfs.LocatedBlock[] open(String src) throws IOException
org.apache.hadoop.dfs.ClientProtocol
open
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public org.apache.hadoop.dfs.LocatedBlock create(String src, String clientName, String clientMachine, boolean overwrite, short replication, long blockSize) throws IOException
org.apache.hadoop.dfs.ClientProtocol
create
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean setReplication(String src, short replication) throws IOException
org.apache.hadoop.dfs.ClientProtocol
setReplication
in interface org.apache.hadoop.dfs.ClientProtocol
src
- file namereplication
- new replication
IOException
public org.apache.hadoop.dfs.LocatedBlock addBlock(String src, String clientName) throws IOException
org.apache.hadoop.dfs.ClientProtocol
addBlock
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public void reportWrittenBlock(org.apache.hadoop.dfs.LocatedBlock lb) throws IOException
reportWrittenBlock
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public void abandonBlock(org.apache.hadoop.dfs.Block b, String src) throws IOException
abandonBlock
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public void abandonFileInProgress(String src, String holder) throws IOException
org.apache.hadoop.dfs.ClientProtocol
abandonFileInProgress
in interface org.apache.hadoop.dfs.ClientProtocol
src
- The filenameholder
- The datanode holding the lease
IOException
public boolean complete(String src, String clientName) throws IOException
org.apache.hadoop.dfs.ClientProtocol
complete
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public String[][] getHints(String src, long start, long len) throws IOException
org.apache.hadoop.dfs.ClientProtocol
getHints
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public long getBlockSize(String filename) throws IOException
org.apache.hadoop.dfs.ClientProtocol
getBlockSize
in interface org.apache.hadoop.dfs.ClientProtocol
filename
- The name of the file
IOException
public boolean rename(String src, String dst) throws IOException
org.apache.hadoop.dfs.ClientProtocol
rename
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean delete(String src) throws IOException
org.apache.hadoop.dfs.ClientProtocol
delete
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean exists(String src) throws IOException
org.apache.hadoop.dfs.ClientProtocol
exists
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean isDir(String src) throws IOException
org.apache.hadoop.dfs.ClientProtocol
isDir
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean mkdirs(String src) throws IOException
org.apache.hadoop.dfs.ClientProtocol
mkdirs
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean obtainLock(String src, String clientName, boolean exclusive) throws IOException
org.apache.hadoop.dfs.ClientProtocol
obtainLock
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public boolean releaseLock(String src, String clientName) throws IOException
org.apache.hadoop.dfs.ClientProtocol
releaseLock
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public void renewLease(String clientName) throws IOException
org.apache.hadoop.dfs.ClientProtocol
renewLease
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public org.apache.hadoop.dfs.DFSFileInfo[] getListing(String src) throws IOException
org.apache.hadoop.dfs.ClientProtocol
getListing
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public long[] getStats() throws IOException
org.apache.hadoop.dfs.ClientProtocol
getStats
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public DatanodeInfo[] getDatanodeReport() throws IOException
org.apache.hadoop.dfs.ClientProtocol
getDatanodeReport
in interface org.apache.hadoop.dfs.ClientProtocol
IOException
public org.apache.hadoop.dfs.DatanodeRegistration register(org.apache.hadoop.dfs.DatanodeRegistration nodeReg) throws IOException
org.apache.hadoop.dfs.DatanodeProtocol
register
in interface org.apache.hadoop.dfs.DatanodeProtocol
DatanodeRegistration
, which contains
new storageID if the datanode did not have one and
registration ID for further communication.
IOException
DataNode#register()
,
FSNamesystem#registerDatanode(DatanodeRegistration)
public org.apache.hadoop.dfs.BlockCommand sendHeartbeat(org.apache.hadoop.dfs.DatanodeRegistration nodeReg, long capacity, long remaining, int xmitsInProgress) throws IOException
sendHeartbeat
in interface org.apache.hadoop.dfs.DatanodeProtocol
IOException
public org.apache.hadoop.dfs.Block[] blockReport(org.apache.hadoop.dfs.DatanodeRegistration nodeReg, org.apache.hadoop.dfs.Block[] blocks) throws IOException
org.apache.hadoop.dfs.DatanodeProtocol
blockReport
in interface org.apache.hadoop.dfs.DatanodeProtocol
IOException
public void blockReceived(org.apache.hadoop.dfs.DatanodeRegistration nodeReg, org.apache.hadoop.dfs.Block[] blocks) throws IOException
org.apache.hadoop.dfs.DatanodeProtocol
blockReceived
in interface org.apache.hadoop.dfs.DatanodeProtocol
IOException
public void errorReport(org.apache.hadoop.dfs.DatanodeRegistration nodeReg, int errorCode, String msg) throws IOException
org.apache.hadoop.dfs.DatanodeProtocol
errorReport
in interface org.apache.hadoop.dfs.DatanodeProtocol
IOException
public void verifyRequest(org.apache.hadoop.dfs.DatanodeRegistration nodeReg) throws IOException
nodeReg
- data node registration
IOException
public void verifyVersion(int version) throws IOException
version
-
IOException
public static void main(String[] argv) throws Exception
Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |