@@ -555,10 +555,10 @@ public void testHANameNodesWithFederation() throws URISyntaxException {
555
555
assertTrue (HAUtil .isHAEnabled (conf , "ns2" ));
556
556
assertFalse (HAUtil .isHAEnabled (conf , "ns3" ));
557
557
558
- assertEquals ( resolvedName ( NS1_NN1_HOST ) , map .get ("ns1" ).get ("ns1-nn1" ). toString ( ));
559
- assertEquals ( resolvedName ( NS1_NN2_HOST ) , map .get ("ns1" ).get ("ns1-nn2" ). toString ( ));
560
- assertEquals ( resolvedName ( NS2_NN1_HOST ) , map .get ("ns2" ).get ("ns2-nn1" ). toString ( ));
561
- assertEquals ( resolvedName ( NS2_NN2_HOST ) , map .get ("ns2" ).get ("ns2-nn2" ). toString ( ));
558
+ assertInetSocketAddress ( NS1_NN1_HOST , map .get ("ns1" ).get ("ns1-nn1" ));
559
+ assertInetSocketAddress ( NS1_NN2_HOST , map .get ("ns1" ).get ("ns1-nn2" ));
560
+ assertInetSocketAddress ( NS2_NN1_HOST , map .get ("ns2" ).get ("ns2-nn1" ));
561
+ assertInetSocketAddress ( NS2_NN2_HOST , map .get ("ns2" ).get ("ns2-nn2" ));
562
562
563
563
assertEquals (NS1_NN1_HOST ,
564
564
DFSUtil .getNamenodeServiceAddr (conf , "ns1" , "ns1-nn1" ));
@@ -626,16 +626,25 @@ public void getNameNodeServiceAddr() throws IOException {
626
626
}
627
627
628
628
@ Test
629
- public void testGetHaNnHttpAddresses () throws IOException {
629
+ public void testGetHaNnHttpAddresses () {
630
630
final String LOGICAL_HOST_NAME = "ns1" ;
631
631
632
632
Configuration conf = createWebHDFSHAConfiguration (LOGICAL_HOST_NAME , NS1_NN1_ADDR , NS1_NN2_ADDR );
633
633
634
634
Map <String , Map <String , InetSocketAddress >> map =
635
635
DFSUtilClient .getHaNnWebHdfsAddresses (conf , "webhdfs" );
636
636
637
- assertEquals (resolvedName (NS1_NN1_ADDR ), map .get ("ns1" ).get ("nn1" ).toString ());
638
- assertEquals (resolvedName (NS1_NN2_ADDR ), map .get ("ns1" ).get ("nn2" ).toString ());
637
+ assertInetSocketAddress (NS1_NN1_ADDR , map .get ("ns1" ).get ("nn1" ));
638
+ assertInetSocketAddress (NS1_NN2_ADDR , map .get ("ns1" ).get ("nn2" ));
639
+ }
640
+
641
+ static void assertInetSocketAddress (String expected , InetSocketAddress computed ) {
642
+ final int i = expected .indexOf (':' );
643
+ final String host = expected .substring (0 , i );
644
+ final int port = Integer .parseInt (expected .substring (i + 1 ));
645
+ assertEquals (host , computed .getHostName ());
646
+ assertEquals (port , computed .getPort ());
647
+ assertEquals (InetSocketAddress .createUnresolved (host , port ), computed );
639
648
}
640
649
641
650
private static Configuration createWebHDFSHAConfiguration (String logicalHostName , String nnaddr1 , String nnaddr2 ) {
@@ -956,7 +965,7 @@ public void testAssertAllResultsEqual() {
956
965
checkAllResults (new Long []{1l }, true );
957
966
checkAllResults (new Long []{1l , 1l }, true );
958
967
checkAllResults (new Long []{1l , 1l , 1l }, true );
959
- checkAllResults (new Long []{new Long ( 1 ), new Long ( 1 ) }, true );
968
+ checkAllResults (new Long []{1L , 1L }, true );
960
969
checkAllResults (new Long []{null , null , null }, true );
961
970
962
971
checkAllResults (new Long []{1l , 2l }, false );
0 commit comments