HDFS-3036. Remove unused method DFSUtil#isDefaultNamenodeAddress. Contributed by Aaron T. Myers.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1295961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e31bf675d
commit
f22677ef8e
@ -68,6 +68,8 @@ Trunk (unreleased changes)
|
|||||||
HDFS-3030. Remove getProtocolVersion and getProtocolSignature from translators.
|
HDFS-3030. Remove getProtocolVersion and getProtocolSignature from translators.
|
||||||
(jitendra)
|
(jitendra)
|
||||||
|
|
||||||
|
HDFS-3036. Remove unused method DFSUtil#isDefaultNamenodeAddress. (atm)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-2477. Optimize computing the diff between a block report and the
|
HDFS-2477. Optimize computing the diff between a block report and the
|
||||||
|
@ -446,8 +446,7 @@ public static List<InetSocketAddress> getNNServiceRpcAddresses(
|
|||||||
* namenode, this method returns the corresponding nameservice ID,
|
* namenode, this method returns the corresponding nameservice ID,
|
||||||
* by doing a reverse lookup on the list of nameservices until it
|
* by doing a reverse lookup on the list of nameservices until it
|
||||||
* finds a match.
|
* finds a match.
|
||||||
* If null is returned, client should try {@link #isDefaultNamenodeAddress}
|
*
|
||||||
* to check pre-Federated configurations.
|
|
||||||
* Since the process of resolving URIs to Addresses is slightly expensive,
|
* Since the process of resolving URIs to Addresses is slightly expensive,
|
||||||
* this utility method should not be used in performance-critical routines.
|
* this utility method should not be used in performance-critical routines.
|
||||||
*
|
*
|
||||||
@ -470,7 +469,6 @@ public static String getNameServiceIdFromAddress(Configuration conf,
|
|||||||
|
|
||||||
// Configuration with a single namenode and no nameserviceId
|
// Configuration with a single namenode and no nameserviceId
|
||||||
if (nameserviceIds == null || nameserviceIds.isEmpty()) {
|
if (nameserviceIds == null || nameserviceIds.isEmpty()) {
|
||||||
// client should try {@link isDefaultNamenodeAddress} instead
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Get the candidateAddresses for all the configured nameServiceIds
|
// Get the candidateAddresses for all the configured nameServiceIds
|
||||||
@ -484,7 +482,6 @@ public static String getNameServiceIdFromAddress(Configuration conf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// didn't find a match
|
// didn't find a match
|
||||||
// client should try {@link isDefaultNamenodeAddress} instead
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,38 +524,6 @@ public static String getInfoServer(
|
|||||||
return httpAddress;
|
return httpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Given the InetSocketAddress for any configured communication with a
|
|
||||||
* namenode, this method determines whether it is the configured
|
|
||||||
* communication channel for the "default" namenode.
|
|
||||||
* It does a reverse lookup on the list of default communication parameters
|
|
||||||
* to see if the given address matches any of them.
|
|
||||||
* Since the process of resolving URIs to Addresses is slightly expensive,
|
|
||||||
* this utility method should not be used in performance-critical routines.
|
|
||||||
*
|
|
||||||
* @param conf - configuration
|
|
||||||
* @param address - InetSocketAddress for configured communication with NN.
|
|
||||||
* Configured addresses are typically given as URIs, but we may have to
|
|
||||||
* compare against a URI typed in by a human, or the server name may be
|
|
||||||
* aliased, so we compare unambiguous InetSocketAddresses instead of just
|
|
||||||
* comparing URI substrings.
|
|
||||||
* @param keys - list of configured communication parameters that should
|
|
||||||
* be checked for matches. For example, to compare against RPC addresses,
|
|
||||||
* provide the list DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY,
|
|
||||||
* DFS_NAMENODE_RPC_ADDRESS_KEY
|
|
||||||
* @return - boolean confirmation if matched generic parameter
|
|
||||||
*/
|
|
||||||
public static boolean isDefaultNamenodeAddress(Configuration conf,
|
|
||||||
InetSocketAddress address, String... keys) {
|
|
||||||
for (String key : keys) {
|
|
||||||
String candidateAddress = conf.get(key);
|
|
||||||
if (candidateAddress != null
|
|
||||||
&& address.equals(NetUtils.createSocketAddr(candidateAddress)))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return key specific to a nameserviceId from a generic key
|
* @return key specific to a nameserviceId from a generic key
|
||||||
*/
|
*/
|
||||||
|
@ -208,27 +208,6 @@ public void checkNameServiceId(Configuration conf, String addr,
|
|||||||
assertEquals(expectedNameServiceId, nameserviceId);
|
assertEquals(expectedNameServiceId, nameserviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for
|
|
||||||
* {@link DFSUtil#isDefaultNamenodeAddress(Configuration, InetSocketAddress, String...)}
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testSingleNamenode() {
|
|
||||||
HdfsConfiguration conf = new HdfsConfiguration();
|
|
||||||
final String DEFAULT_ADDRESS = "localhost:9000";
|
|
||||||
final String NN2_ADDRESS = "localhost:9001";
|
|
||||||
conf.set(DFS_NAMENODE_RPC_ADDRESS_KEY, DEFAULT_ADDRESS);
|
|
||||||
|
|
||||||
InetSocketAddress testAddress1 = NetUtils.createSocketAddr(DEFAULT_ADDRESS);
|
|
||||||
boolean isDefault = DFSUtil.isDefaultNamenodeAddress(conf, testAddress1,
|
|
||||||
DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY);
|
|
||||||
assertTrue(isDefault);
|
|
||||||
InetSocketAddress testAddress2 = NetUtils.createSocketAddr(NN2_ADDRESS);
|
|
||||||
isDefault = DFSUtil.isDefaultNamenodeAddress(conf, testAddress2,
|
|
||||||
DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY);
|
|
||||||
assertFalse(isDefault);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tests to ensure default namenode is used as fallback */
|
/** Tests to ensure default namenode is used as fallback */
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultNamenode() throws IOException {
|
public void testDefaultNamenode() throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user