@Test public void testDefaultNamenode() throws IOException { HdfsConfiguration conf = new HdfsConfiguration(); final String hdfs_default = "hdfs: conf.set(FS_DEFAULT_NAME_KEY, hdfs_default); Map<String, Map<String, InetSocketAddress>> addrMap = DFSUtil.getNNServiceRpcAddresses(conf); assertEquals(1, addrMap.size()); Map<String, InetSocketAddress> defaultNsMap = addrMap.get(null); assertEquals(1, defaultNsMap.size()); assertEquals(9999, defaultNsMap.get(null).getPort()); }
public static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses( Configuration conf) throws IOException { String defaultAddress; try { defaultAddress = NetUtils.getHostPortString(NameNode.getAddress(conf)); } catch (IllegalArgumentException e) { defaultAddress = null; } Map<String, Map<String, InetSocketAddress>> addressList = getAddresses(conf, defaultAddress, DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY); if (addressList.isEmpty()) { throw new IOException("Incorrect configuration: namenode address " + DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + " or " + DFS_NAMENODE_RPC_ADDRESS_KEY + " is not configured."); } return addressList; }
DFSUtil { public static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses( Configuration conf) throws IOException { String defaultAddress; try { defaultAddress = NetUtils.getHostPortString(NameNode.getAddress(conf)); } catch (IllegalArgumentException e) { defaultAddress = null; } Map<String, Map<String, InetSocketAddress>> addressList = getAddresses(conf, defaultAddress, DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY); if (addressList.isEmpty()) { throw new IOException("Incorrect configuration: namenode address " + DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + " or " + DFS_NAMENODE_RPC_ADDRESS_KEY + " is not configured."); } return addressList; } }
DFSUtil { public static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses( Configuration conf) throws IOException { String defaultAddress; try { defaultAddress = NetUtils.getHostPortString(NameNode.getAddress(conf)); } catch (IllegalArgumentException e) { defaultAddress = null; } Map<String, Map<String, InetSocketAddress>> addressList = getAddresses(conf, defaultAddress, DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY); if (addressList.isEmpty()) { throw new IOException("Incorrect configuration: namenode address " + DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + " or " + DFS_NAMENODE_RPC_ADDRESS_KEY + " is not configured."); } return addressList; } private  DFSUtil(); }
DFSUtil { public static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses( Configuration conf) throws IOException { String defaultAddress; try { defaultAddress = NetUtils.getHostPortString(NameNode.getAddress(conf)); } catch (IllegalArgumentException e) { defaultAddress = null; } Map<String, Map<String, InetSocketAddress>> addressList = getAddresses(conf, defaultAddress, DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY); if (addressList.isEmpty()) { throw new IOException("Incorrect configuration: namenode address " + DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + " or " + DFS_NAMENODE_RPC_ADDRESS_KEY + " is not configured."); } return addressList; } private  DFSUtil(); static int compareBytes(byte[] left, byte[] right); static Random getRandom(); static SecureRandom getSecureRandom(); static T[] shuffle(final T[] array); static boolean isValidName(String src); static boolean isValidNameForComponent(String component); static boolean isReservedPathComponent(String component); static String bytes2String(byte[] bytes); static String bytes2String(byte[] bytes, int offset, int length); static byte[] string2Bytes(String str); static String byteArray2PathString(byte[][] pathComponents,
      int offset, int length); static String byteArray2PathString(byte[][] pathComponents); static String strings2PathString(String[] components); static byte[] byteArray2bytes(byte[][] pathComponents); static String path2String(final Object path); static byte[][] bytes2byteArray(byte[] bytes, byte separator); static byte[][] bytes2byteArray(byte[] bytes,
                                         int len,
                                         byte separator); static BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks); static BlockLocation[] locatedBlocks2Locations(List<LocatedBlock> blocks); static Collection<String> getNameServiceIds(Configuration conf); static Collection<String> getNameNodeIds(Configuration conf, String nsId); static String addKeySuffixes(String key, String... suffixes); static Map<String, InetSocketAddress> getRpcAddressesForNameserviceId(
      Configuration conf, String nsId, String defaultValue); static Set<String> getAllNnPrincipals(Configuration conf); static Map<String, Map<String, InetSocketAddress>> getHaNnRpcAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getHaNnWebHdfsAddresses(
      Configuration conf, String scheme); static Map<String, Map<String, InetSocketAddress>> getBackupNodeAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getSecondaryNameNodeAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddressesForCluster(Configuration conf); static String getNamenodeLifelineAddr(final Configuration conf,
      String nsId, String nnId); static List<ConfiguredNNAddress> flattenAddressMap(
      Map<String, Map<String, InetSocketAddress>> map); static String addressMapToString(
      Map<String, Map<String, InetSocketAddress>> map); static String nnAddressesAsString(Configuration conf); static Collection<URI> getNsServiceRpcUris(Configuration conf); static Collection<URI> getNameServiceUris(Configuration conf,
      String... keys); static String getNameServiceIdFromAddress(final Configuration conf, 
      final InetSocketAddress address, String... keys); static URI getInfoServer(InetSocketAddress namenodeAddr,
      Configuration conf, String scheme); static URI getInfoServerWithDefaultHost(String defaultHost,
      Configuration conf, final String scheme); static String getHttpClientScheme(Configuration conf); static void setGenericConf(Configuration conf,
      String nameserviceId, String nnId, String... keys); static float getPercentUsed(long used, long capacity); static float getPercentRemaining(long remaining, long capacity); static String percent2String(double percentage); static int roundBytesToGB(long bytes); static ClientDatanodeProtocol createClientDatanodeProtocolProxy(
      DatanodeID datanodeid, Configuration conf, int socketTimeout,
      boolean connectToDnViaHostname, LocatedBlock locatedBlock); static ClientDatanodeProtocol createClientDatanodeProtocolProxy(
      DatanodeID datanodeid, Configuration conf, int socketTimeout,
      boolean connectToDnViaHostname); static ClientDatanodeProtocol createClientDatanodeProtocolProxy(
      InetSocketAddress addr, UserGroupInformation ticket, Configuration conf,
      SocketFactory factory); static String getNamenodeNameServiceId(Configuration conf); static String getBackupNameServiceId(Configuration conf); static String getSecondaryNameServiceId(Configuration conf); static URI createUri(String scheme, InetSocketAddress address); static void addPBProtocol(Configuration conf, Class<?> protocol,
      BlockingService service, RPC.Server server); static String getNamenodeServiceAddr(final Configuration conf,
      String nsId, String nnId); static String getOnlyNameServiceIdOrNull(Configuration conf); static boolean parseHelpArgument(String[] args,
      String helpDescription, PrintStream out, boolean printGenericCommandUsage); static float getInvalidateWorkPctPerIteration(Configuration conf); static int getReplWorkMultiplier(Configuration conf); static String getSpnegoKeytabKey(Configuration conf, String defaultKey); static HttpConfig.Policy getHttpPolicy(Configuration conf); static HttpServer2.Builder loadSslConfToHttpServerBuilder(HttpServer2.Builder builder,
      Configuration sslConf); static Configuration loadSslConfiguration(Configuration conf); static HttpServer2.Builder httpServerTemplateForNNAndJN(
      Configuration conf, final InetSocketAddress httpAddr,
      final InetSocketAddress httpsAddr, String name, String spnegoUserNameKey,
      String spnegoKeytabFileKey); static String dateToIso8601String(Date date); static String durationToString(long durationMs); static long parseRelativeTime(String relTime); static void assertAllResultsEqual(Collection<?> objects); static KeyProvider createKeyProvider(
      final Configuration conf); static KeyProviderCryptoExtension createKeyProviderCryptoExtension(
      final Configuration conf); static boolean isHDFSEncryptionEnabled(Configuration conf); }
DFSUtil { public static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses( Configuration conf) throws IOException { String defaultAddress; try { defaultAddress = NetUtils.getHostPortString(NameNode.getAddress(conf)); } catch (IllegalArgumentException e) { defaultAddress = null; } Map<String, Map<String, InetSocketAddress>> addressList = getAddresses(conf, defaultAddress, DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, DFS_NAMENODE_RPC_ADDRESS_KEY); if (addressList.isEmpty()) { throw new IOException("Incorrect configuration: namenode address " + DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + " or " + DFS_NAMENODE_RPC_ADDRESS_KEY + " is not configured."); } return addressList; } private  DFSUtil(); static int compareBytes(byte[] left, byte[] right); static Random getRandom(); static SecureRandom getSecureRandom(); static T[] shuffle(final T[] array); static boolean isValidName(String src); static boolean isValidNameForComponent(String component); static boolean isReservedPathComponent(String component); static String bytes2String(byte[] bytes); static String bytes2String(byte[] bytes, int offset, int length); static byte[] string2Bytes(String str); static String byteArray2PathString(byte[][] pathComponents,
      int offset, int length); static String byteArray2PathString(byte[][] pathComponents); static String strings2PathString(String[] components); static byte[] byteArray2bytes(byte[][] pathComponents); static String path2String(final Object path); static byte[][] bytes2byteArray(byte[] bytes, byte separator); static byte[][] bytes2byteArray(byte[] bytes,
                                         int len,
                                         byte separator); static BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks); static BlockLocation[] locatedBlocks2Locations(List<LocatedBlock> blocks); static Collection<String> getNameServiceIds(Configuration conf); static Collection<String> getNameNodeIds(Configuration conf, String nsId); static String addKeySuffixes(String key, String... suffixes); static Map<String, InetSocketAddress> getRpcAddressesForNameserviceId(
      Configuration conf, String nsId, String defaultValue); static Set<String> getAllNnPrincipals(Configuration conf); static Map<String, Map<String, InetSocketAddress>> getHaNnRpcAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getHaNnWebHdfsAddresses(
      Configuration conf, String scheme); static Map<String, Map<String, InetSocketAddress>> getBackupNodeAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getSecondaryNameNodeAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddresses(
      Configuration conf); static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddressesForCluster(Configuration conf); static String getNamenodeLifelineAddr(final Configuration conf,
      String nsId, String nnId); static List<ConfiguredNNAddress> flattenAddressMap(
      Map<String, Map<String, InetSocketAddress>> map); static String addressMapToString(
      Map<String, Map<String, InetSocketAddress>> map); static String nnAddressesAsString(Configuration conf); static Collection<URI> getNsServiceRpcUris(Configuration conf); static Collection<URI> getNameServiceUris(Configuration conf,
      String... keys); static String getNameServiceIdFromAddress(final Configuration conf, 
      final InetSocketAddress address, String... keys); static URI getInfoServer(InetSocketAddress namenodeAddr,
      Configuration conf, String scheme); static URI getInfoServerWithDefaultHost(String defaultHost,
      Configuration conf, final String scheme); static String getHttpClientScheme(Configuration conf); static void setGenericConf(Configuration conf,
      String nameserviceId, String nnId, String... keys); static float getPercentUsed(long used, long capacity); static float getPercentRemaining(long remaining, long capacity); static String percent2String(double percentage); static int roundBytesToGB(long bytes); static ClientDatanodeProtocol createClientDatanodeProtocolProxy(
      DatanodeID datanodeid, Configuration conf, int socketTimeout,
      boolean connectToDnViaHostname, LocatedBlock locatedBlock); static ClientDatanodeProtocol createClientDatanodeProtocolProxy(
      DatanodeID datanodeid, Configuration conf, int socketTimeout,
      boolean connectToDnViaHostname); static ClientDatanodeProtocol createClientDatanodeProtocolProxy(
      InetSocketAddress addr, UserGroupInformation ticket, Configuration conf,
      SocketFactory factory); static String getNamenodeNameServiceId(Configuration conf); static String getBackupNameServiceId(Configuration conf); static String getSecondaryNameServiceId(Configuration conf); static URI createUri(String scheme, InetSocketAddress address); static void addPBProtocol(Configuration conf, Class<?> protocol,
      BlockingService service, RPC.Server server); static String getNamenodeServiceAddr(final Configuration conf,
      String nsId, String nnId); static String getOnlyNameServiceIdOrNull(Configuration conf); static boolean parseHelpArgument(String[] args,
      String helpDescription, PrintStream out, boolean printGenericCommandUsage); static float getInvalidateWorkPctPerIteration(Configuration conf); static int getReplWorkMultiplier(Configuration conf); static String getSpnegoKeytabKey(Configuration conf, String defaultKey); static HttpConfig.Policy getHttpPolicy(Configuration conf); static HttpServer2.Builder loadSslConfToHttpServerBuilder(HttpServer2.Builder builder,
      Configuration sslConf); static Configuration loadSslConfiguration(Configuration conf); static HttpServer2.Builder httpServerTemplateForNNAndJN(
      Configuration conf, final InetSocketAddress httpAddr,
      final InetSocketAddress httpsAddr, String name, String spnegoUserNameKey,
      String spnegoKeytabFileKey); static String dateToIso8601String(Date date); static String durationToString(long durationMs); static long parseRelativeTime(String relTime); static void assertAllResultsEqual(Collection<?> objects); static KeyProvider createKeyProvider(
      final Configuration conf); static KeyProviderCryptoExtension createKeyProviderCryptoExtension(
      final Configuration conf); static boolean isHDFSEncryptionEnabled(Configuration conf); static final Log LOG; static final byte[] EMPTY_BYTES; static final Comparator<DatanodeInfo> DECOM_COMPARATOR; static final Options helpOptions; static final Option helpOpt; }