public class HAUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Text |
buildTokenServiceForLogicalUri(URI uri)
Get the service name used in the delegation token for the given logical
HA service.
|
static void |
cloneDelegationTokenForLogicalUri(UserGroupInformation ugi,
URI haUri,
Collection<InetSocketAddress> nnAddrs)
Locate a delegation token associated with the given HA cluster URI, and if
one is found, clone it to also represent the underlying namenode address.
|
static InetSocketAddress |
getAddressOfActive(FileSystem fs)
Get the internet address of the currently-active NN.
|
static Configuration |
getConfForOtherNode(Configuration myConf)
Given the configuration for this node, return a Configuration object for
the other node in an HA setup.
|
static String |
getNameNodeId(Configuration conf,
String nsId)
Get the namenode Id by matching the
addressKey
with the the address of the local node. |
static String |
getNameNodeIdFromAddress(Configuration conf,
InetSocketAddress address,
String... keys)
|
static String |
getNameNodeIdOfOtherNode(Configuration conf,
String nsId)
Get the NN ID of the other node in an HA setup.
|
static URI |
getServiceUriFromToken(Token<DelegationTokenIdentifier> token)
Parse the HDFS URI out of the provided token.
|
static boolean |
isHAEnabled(Configuration conf,
String nsId)
Returns true if HA for namenode is configured for the given nameservice
|
static boolean |
isLogicalUri(Configuration conf,
URI nameNodeUri) |
static boolean |
isTokenForLogicalUri(Token<DelegationTokenIdentifier> token) |
static void |
setAllowStandbyReads(Configuration conf,
boolean val) |
static boolean |
shouldAllowStandbyReads(Configuration conf)
This is used only by tests at the moment.
|
static boolean |
usesSharedEditsDir(Configuration conf)
Returns true if HA is using a shared edits directory.
|
public static boolean isHAEnabled(Configuration conf, String nsId)
conf
- ConfigurationnsId
- nameservice, or null if no federated NS is configuredpublic static boolean usesSharedEditsDir(Configuration conf)
conf
- Configurationpublic static String getNameNodeId(Configuration conf, 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
- ConfigurationHadoopIllegalArgumentException
- on errorpublic static String getNameNodeIdFromAddress(Configuration conf, InetSocketAddress address, String... keys)
public static String getNameNodeIdOfOtherNode(Configuration conf, String nsId)
conf
- the configuration of this nodepublic static Configuration getConfForOtherNode(Configuration myConf)
myConf
- the configuration of this nodepublic static boolean shouldAllowStandbyReads(Configuration conf)
public static void setAllowStandbyReads(Configuration conf, boolean val)
public static boolean isLogicalUri(Configuration conf, URI nameNodeUri)
public static URI getServiceUriFromToken(Token<DelegationTokenIdentifier> token) throws IOException
IOException
- if the token is invalidpublic static Text buildTokenServiceForLogicalUri(URI uri)
uri
- the logical URI of the clusterpublic static boolean isTokenForLogicalUri(Token<DelegationTokenIdentifier> token)
public static void cloneDelegationTokenForLogicalUri(UserGroupInformation ugi, URI haUri, Collection<InetSocketAddress> nnAddrs)
ugi
- the UGI to modifyhaUri
- the logical URI for the clusternnAddrs
- collection of NNs in the cluster to which the token
appliespublic static InetSocketAddress getAddressOfActive(FileSystem fs) throws IOException
fs
- the file system to get the active address of.IOException
- if an error occurs while resolving the active NN.Copyright © 2013 Apache Software Foundation. All rights reserved.