Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
KeeProMise committed Jan 9, 2024
1 parent c97a88f commit 3343470
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1159,4 +1159,26 @@ public void testGetTransferRateInBytesPerSecond() {
assertEquals(102_400_000,
DFSUtil.getTransferRateInBytesPerSecond(512_000_000L, 5_000_000_000L));
}

@Test
public void testLazyResolve(){
final String ns1Nn1 = "localhost:8020";
final String ns1Nn2 = "127.0.0.1:8020";
HdfsConfiguration conf = new HdfsConfiguration();
conf.setBoolean(HdfsClientConfigKeys.Failover.DFS_CLIENT_LAZY_RESOLVED, true);
conf.set(DFS_NAMESERVICES, "ns1");
conf.set(DFSUtil.addKeySuffixes(DFS_HA_NAMENODES_KEY_PREFIX, "ns1"), "nn1,nn2");
conf.set(DFSUtil.addKeySuffixes(
DFS_NAMENODE_RPC_ADDRESS_KEY, "ns1", "nn1"), ns1Nn1);
conf.set(DFSUtil.addKeySuffixes(
DFS_NAMENODE_RPC_ADDRESS_KEY, "ns1", "nn2"), ns1Nn2);
Map<String, Map<String, InetSocketAddress>> addresses =
DFSUtilClient.getAddresses(conf, null, DFS_NAMENODE_RPC_ADDRESS_KEY);
Map<String, InetSocketAddress> inetSocketAddressMap = addresses.get("ns1");
// Address is null, because it has not been resolved yet
for(Map.Entry<String, InetSocketAddress> entry : inetSocketAddressMap.entrySet()) {
assertNull(entry.getValue().getAddress());
assertEquals(entry.getValue().getPort(), 8020);
}
}
}

0 comments on commit 3343470

Please sign in to comment.