@Private
public class HAUtil
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Modifier and Type | Method | Description |
|---|---|---|
static java.net.InetSocketAddress |
getAddressOfActive(org.apache.hadoop.fs.FileSystem fs) |
Get the internet address of the currently-active NN.
|
static java.util.List<org.apache.hadoop.conf.Configuration> |
getConfForOtherNodes(org.apache.hadoop.conf.Configuration myConf) |
Given the configuration for this node, return a list of configurations
for the other nodes in an HA setup.
|
static java.lang.String |
getNameNodeId(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId) |
Get the namenode Id by matching the
addressKey
with the the address of the local node. |
static java.lang.String |
getNameNodeIdFromAddress(org.apache.hadoop.conf.Configuration conf,
java.net.InetSocketAddress address,
java.lang.String... keys) |
|
static java.util.List<java.lang.String> |
getNameNodeIdOfOtherNodes(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId) |
Get the NN ID of the other nodes in an HA setup.
|
static java.util.List<org.apache.hadoop.hdfs.protocol.ClientProtocol> |
getProxiesForAllNameNodesInNameservice(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId) |
Get an RPC proxy for each NN in an HA nameservice.
|
static <T> java.util.List<org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<T>> |
getProxiesForAllNameNodesInNameservice(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId,
java.lang.Class<T> xface) |
Get an RPC proxy for each NN in an HA nameservice.
|
static boolean |
isAtLeastOneActive(java.util.List<org.apache.hadoop.hdfs.protocol.ClientProtocol> namenodes) |
Used to ensure that at least one of the given HA NNs is currently in the
active state..
|
static boolean |
isHAEnabled(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId) |
Returns true if HA for namenode is configured for the given nameservice
|
static void |
setAllowStandbyReads(org.apache.hadoop.conf.Configuration conf,
boolean val) |
|
static boolean |
shouldAllowStandbyReads(org.apache.hadoop.conf.Configuration conf) |
This is used only by tests at the moment.
|
static boolean |
useLogicalUri(org.apache.hadoop.conf.Configuration conf,
java.net.URI nameNodeUri) |
Check whether logical URI is needed for the namenode and
the corresponding failover proxy provider in the config.
|
static boolean |
usesSharedEditsDir(org.apache.hadoop.conf.Configuration conf) |
Returns true if HA is using a shared edits directory.
|
public static boolean isHAEnabled(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId)
conf - ConfigurationnsId - nameservice, or null if no federated NS is configuredpublic static boolean usesSharedEditsDir(org.apache.hadoop.conf.Configuration conf)
conf - Configurationpublic static java.lang.String getNameNodeId(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId)
addressKey
with the the address of the local node.
If DFSConfigKeys.DFS_HA_NAMENODE_ID_KEY is not specifically
configured, this method determines the namenode Id by matching the local
node's address with the configured addresses. When a match is found, it
returns the namenode Id from the corresponding configuration key.conf - Configurationorg.apache.hadoop.HadoopIllegalArgumentException - on errorpublic static java.lang.String getNameNodeIdFromAddress(org.apache.hadoop.conf.Configuration conf,
java.net.InetSocketAddress address,
java.lang.String... keys)
public static java.util.List<java.lang.String> getNameNodeIdOfOtherNodes(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId)
conf - the configuration of this nodepublic static java.util.List<org.apache.hadoop.conf.Configuration> getConfForOtherNodes(org.apache.hadoop.conf.Configuration myConf)
myConf - the configuration of this nodepublic static boolean shouldAllowStandbyReads(org.apache.hadoop.conf.Configuration conf)
public static void setAllowStandbyReads(org.apache.hadoop.conf.Configuration conf,
boolean val)
public static boolean useLogicalUri(org.apache.hadoop.conf.Configuration conf,
java.net.URI nameNodeUri)
throws java.io.IOException
conf - ConfigurationnameNodeUri - The URI of namenodejava.io.IOException - most likely due to misconfiguration.public static java.net.InetSocketAddress getAddressOfActive(org.apache.hadoop.fs.FileSystem fs)
throws java.io.IOException
fs - the file system to get the active address of.java.io.IOException - if an error occurs while resolving the active NN.public static java.util.List<org.apache.hadoop.hdfs.protocol.ClientProtocol> getProxiesForAllNameNodesInNameservice(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId)
throws java.io.IOException
conf - configurationnsId - the nameservice to get all of the proxies for.java.io.IOException - in the event of error.public static <T> java.util.List<org.apache.hadoop.hdfs.NameNodeProxiesClient.ProxyAndInfo<T>> getProxiesForAllNameNodesInNameservice(org.apache.hadoop.conf.Configuration conf,
java.lang.String nsId,
java.lang.Class<T> xface)
throws java.io.IOException
conf - configurationnsId - the nameservice to get all of the proxies for.xface - the protocol class.java.io.IOException - in the event of error.public static boolean isAtLeastOneActive(java.util.List<org.apache.hadoop.hdfs.protocol.ClientProtocol> namenodes)
throws java.io.IOException
namenodes - list of RPC proxies for each NN to check.java.io.IOException - in the event of error.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.