@InterfaceAudience.Private public class NameNode extends Object
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
FileSystem
class.
NameNode also implements the
DatanodeProtocol
interface,
used by DataNodes that actually store DFS data blocks. These
methods are invoked repeatedly and automatically by all the
DataNodes in a DFS deployment.
NameNode also implements the
NamenodeProtocol
interface,
used by secondary namenodes or rebalancing processes to get partial
NameNode state, for example partial blocksMap etc.Modifier and Type | Class and Description |
---|---|
protected class |
NameNode.NameNodeHAContext
|
static class |
NameNode.OperationCategory
Categories of operations supported by the namenode.
|
Modifier and Type | Field and Description |
---|---|
static HAState |
ACTIVE_STATE |
protected boolean |
allowStaleStandbyReads |
static org.apache.commons.logging.Log |
blockStateChangeLog |
protected Configuration |
conf |
static int |
DEFAULT_PORT |
protected NameNodeHttpServer |
httpServer
httpServer
|
static org.apache.commons.logging.Log |
LOG |
static String[] |
NAMENODE_SPECIFIC_KEYS
HDFS configuration can have three types of parameters:
Parameters that are common for all the name services in the cluster.
Parameters that are specific to a name service.
|
static String[] |
NAMESERVICE_SPECIFIC_KEYS |
protected FSNamesystem |
namesystem |
protected NamenodeRegistration |
nodeRegistration
Registration information of this name-node
|
protected HdfsServerConstants.NamenodeRole |
role |
static HAState |
STANDBY_STATE |
static org.apache.commons.logging.Log |
stateChangeLog |
protected boolean |
stopRequested
only used for testing purposes
|
Modifier | Constructor and Description |
---|---|
|
NameNode(Configuration conf)
Start NameNode.
|
protected |
NameNode(Configuration conf,
HdfsServerConstants.NamenodeRole role) |
Modifier and Type | Method and Description |
---|---|
static void |
checkAllowFormat(Configuration conf) |
protected HAContext |
createHAContext() |
protected HAState |
createHAState() |
static NameNode |
createNameNode(String[] argv,
Configuration conf) |
protected org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer |
createRpcServer(Configuration conf)
Create the RPC server implementation.
|
protected void |
doImmediateShutdown(Throwable t)
Shutdown the NN immediately in an ungraceful way.
|
static void |
format(Configuration conf)
Format a new filesystem.
|
static InetSocketAddress |
getAddress(Configuration conf) |
static InetSocketAddress |
getAddress(String address) |
static InetSocketAddress |
getAddress(URI filesystemURI)
TODO:FEDERATION
|
FSImage |
getFSImage()
get FSImage
|
InetSocketAddress |
getHttpAddress() |
static InetSocketAddress |
getHttpAddress(Configuration conf) |
protected InetSocketAddress |
getHttpServerAddress(Configuration conf) |
InetSocketAddress |
getNameNodeAddress() |
String |
getNameNodeAddressHostPortString() |
static NameNodeMetrics |
getNameNodeMetrics() |
protected String |
getNameServiceId(Configuration conf)
Get the name service Id for the node
|
FSNamesystem |
getNamesystem()
Return the
FSNamesystem object. |
long |
getProtocolVersion(String protocol,
long clientVersion) |
static UserGroupInformation |
getRemoteUser() |
HdfsServerConstants.NamenodeRole |
getRole() |
NamenodeProtocols |
getRpcServer() |
protected InetSocketAddress |
getRpcServerAddress(Configuration conf) |
protected String |
getRpcServerBindHost(Configuration conf)
Given a configuration get the bind host of the client rpc server
If the bind host is not configured returns null.
|
static InetSocketAddress |
getServiceAddress(Configuration conf,
boolean fallback)
Fetches the address for services to use when connecting to namenode
based on the value of fallback returns null if the special
address is not specified or returns the default namenode address
to be used by both clients and services.
|
InetSocketAddress |
getServiceRpcAddress() |
protected InetSocketAddress |
getServiceRpcServerAddress(Configuration conf)
Given a configuration get the address of the service rpc server
If the service rpc is not configured returns null
|
protected String |
getServiceRpcServerBindHost(Configuration conf)
Given a configuration get the bind host of the service rpc server
If the bind host is not configured returns null.
|
static StartupProgress |
getStartupProgress()
Returns object used for reporting namenode startup progress.
|
static URI |
getUri(InetSocketAddress namenode) |
protected void |
initialize(Configuration conf)
Initialize name-node.
|
static void |
initializeGenericKeys(Configuration conf,
String nameserviceId,
String namenodeId)
In federation configuration is set for a set of
namenode and secondary namenode/backup/checkpointer, which are
grouped under a logical nameservice ID.
|
static boolean |
initializeSharedEdits(Configuration conf) |
static boolean |
initializeSharedEdits(Configuration conf,
boolean force) |
boolean |
isInSafeMode()
Is the cluster currently in safe mode?
|
boolean |
isStandbyState() |
void |
join()
Wait for service to finish.
|
protected void |
loadNamesystem(Configuration conf) |
static void |
main(String[] argv) |
protected void |
setHttpServerAddress(Configuration conf) |
protected void |
setRpcServerAddress(Configuration conf,
InetSocketAddress rpcAddress) |
protected void |
setRpcServiceServerAddress(Configuration conf,
InetSocketAddress serviceRPCAddress)
Modifies the configuration passed to contain the service rpc address setting
|
static void |
setServiceAddress(Configuration conf,
String address)
Set the configuration property for the service rpc address
to address
|
void |
stop()
Stop all NameNode threads and wait for all to finish.
|
protected void |
validateConfigurationSettings(Configuration conf)
Verifies that the final Configuration Settings look ok for the NameNode to
properly start up
Things to check for include:
- HTTP Server Port does not equal the RPC Server Port
|
public static final String[] NAMENODE_SPECIFIC_KEYS
public static final String[] NAMESERVICE_SPECIFIC_KEYS
public static final int DEFAULT_PORT
public static final org.apache.commons.logging.Log LOG
public static final org.apache.commons.logging.Log stateChangeLog
public static final org.apache.commons.logging.Log blockStateChangeLog
public static final HAState ACTIVE_STATE
public static final HAState STANDBY_STATE
protected FSNamesystem namesystem
protected final Configuration conf
protected HdfsServerConstants.NamenodeRole role
protected boolean allowStaleStandbyReads
protected NameNodeHttpServer httpServer
protected boolean stopRequested
protected NamenodeRegistration nodeRegistration
public NameNode(Configuration conf) throws IOException
The name-node can be started with one of the following startup options:
REGULAR
- normal name node startupFORMAT
- format name nodeBACKUP
- start backup nodeCHECKPOINT
- start checkpoint nodeUPGRADE
- start the cluster
upgrade and create a snapshot of the current file system stateRECOVERY
- recover name node
metadataROLLBACK
- roll the
cluster back to the previous stateFINALIZE
- finalize
previous upgradeIMPORT
- import checkpointzero
in the conf.conf
- confirgurationIOException
protected NameNode(Configuration conf, HdfsServerConstants.NamenodeRole role) throws IOException
IOException
public long getProtocolVersion(String protocol, long clientVersion) throws IOException
IOException
public static void format(Configuration conf) throws IOException
IOException
public FSNamesystem getNamesystem()
FSNamesystem
object.FSNamesystem
object.public NamenodeProtocols getRpcServer()
public static NameNodeMetrics getNameNodeMetrics()
public static StartupProgress getStartupProgress()
public static InetSocketAddress getAddress(String address)
public static void setServiceAddress(Configuration conf, String address)
public static InetSocketAddress getServiceAddress(Configuration conf, boolean fallback)
public static InetSocketAddress getAddress(Configuration conf)
public static InetSocketAddress getAddress(URI filesystemURI)
filesystemURI
- public static URI getUri(InetSocketAddress namenode)
public HdfsServerConstants.NamenodeRole getRole()
protected InetSocketAddress getServiceRpcServerAddress(Configuration conf)
protected InetSocketAddress getRpcServerAddress(Configuration conf)
protected String getServiceRpcServerBindHost(Configuration conf)
protected String getRpcServerBindHost(Configuration conf)
protected void setRpcServiceServerAddress(Configuration conf, InetSocketAddress serviceRPCAddress)
protected void setRpcServerAddress(Configuration conf, InetSocketAddress rpcAddress)
protected InetSocketAddress getHttpServerAddress(Configuration conf)
public static InetSocketAddress getHttpAddress(Configuration conf)
protected void setHttpServerAddress(Configuration conf)
protected void loadNamesystem(Configuration conf) throws IOException
IOException
public static UserGroupInformation getRemoteUser() throws IOException
IOException
protected void initialize(Configuration conf) throws IOException
conf
- the configurationIOException
protected org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer createRpcServer(Configuration conf) throws IOException
IOException
protected void validateConfigurationSettings(Configuration conf) throws IOException
conf
- IOException
protected HAState createHAState()
protected HAContext createHAContext()
public void join()
public void stop()
public boolean isInSafeMode()
public FSImage getFSImage()
public InetSocketAddress getNameNodeAddress()
public String getNameNodeAddressHostPortString()
public InetSocketAddress getServiceRpcAddress()
public InetSocketAddress getHttpAddress()
public static void checkAllowFormat(Configuration conf) throws IOException
IOException
public static boolean initializeSharedEdits(Configuration conf) throws IOException
IOException
public static boolean initializeSharedEdits(Configuration conf, boolean force) throws IOException
IOException
public static NameNode createNameNode(String[] argv, Configuration conf) throws IOException
IOException
public static void initializeGenericKeys(Configuration conf, String nameserviceId, String namenodeId)
conf
- Configuration object to lookup specific key and to set the value
to the key passed. Note the conf object is modifiednameserviceId
- name service Id (to distinguish federated NNs)namenodeId
- the namenode ID (to distinguish HA NNs)DFSUtil.setGenericConf(Configuration, String, String, String...)
protected String getNameServiceId(Configuration conf)
protected void doImmediateShutdown(Throwable t) throws ExitUtil.ExitException
t
- exception which warrants the shutdown. Printed to the NN log
before exit.ExitUtil.ExitException
- thrown only for testing.public boolean isStandbyState()
Copyright © 2013 Apache Software Foundation. All rights reserved.