Java Code Examples for org.apache.hadoop.hdfs.DFSUtil#flattenAddressMap()

The following examples show how to use org.apache.hadoop.hdfs.DFSUtil#flattenAddressMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetConf.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public int doWorkInternal(GetConf tool, String []args) throws IOException {
  Configuration config = tool.getConf();
  List<ConfiguredNNAddress> cnnlist = DFSUtil.flattenAddressMap(
      DFSUtil.getNNServiceRpcAddressesForCluster(config));
  if (!cnnlist.isEmpty()) {
    for (ConfiguredNNAddress cnn : cnnlist) {
      InetSocketAddress rpc = cnn.getAddress();
      tool.printOut(rpc.getHostName()+":"+rpc.getPort());
    }
    return 0;
  }
  tool.printError("Did not get namenode service rpc addresses.");
  return -1;
}
 
Example 2
Source File: GetConf.java    From hadoop with Apache License 2.0 5 votes vote down vote up
void printMap(Map<String, Map<String, InetSocketAddress>> map) {
  StringBuilder buffer = new StringBuilder();

  List<ConfiguredNNAddress> cnns = DFSUtil.flattenAddressMap(map);
  for (ConfiguredNNAddress cnn : cnns) {
    InetSocketAddress address = cnn.getAddress();
    if (buffer.length() > 0) {
      buffer.append(" ");
    }
    buffer.append(address.getHostName());
  }
  printOut(buffer.toString());
}
 
Example 3
Source File: TestGetConf.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void verifyAddresses(HdfsConfiguration conf, TestType type,
    boolean checkPort, String... expected) throws Exception {
  // Ensure DFSUtil returned the right set of addresses
  Map<String, Map<String, InetSocketAddress>> map =
    getAddressListFromConf(type, conf);
  List<ConfiguredNNAddress> list = DFSUtil.flattenAddressMap(map);
  String[] actual = toStringArray(list);
  Arrays.sort(actual);
  Arrays.sort(expected);
  assertArrayEquals(expected, actual);

  // Test GetConf returned addresses
  getAddressListFromTool(type, conf, checkPort, list);
}
 
Example 4
Source File: GetConf.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public int doWorkInternal(GetConf tool, String []args) throws IOException {
  Configuration config = tool.getConf();
  List<ConfiguredNNAddress> cnnlist = DFSUtil.flattenAddressMap(
      DFSUtil.getNNServiceRpcAddressesForCluster(config));
  if (!cnnlist.isEmpty()) {
    for (ConfiguredNNAddress cnn : cnnlist) {
      InetSocketAddress rpc = cnn.getAddress();
      tool.printOut(rpc.getHostName()+":"+rpc.getPort());
    }
    return 0;
  }
  tool.printError("Did not get namenode service rpc addresses.");
  return -1;
}
 
Example 5
Source File: GetConf.java    From big-c with Apache License 2.0 5 votes vote down vote up
void printMap(Map<String, Map<String, InetSocketAddress>> map) {
  StringBuilder buffer = new StringBuilder();

  List<ConfiguredNNAddress> cnns = DFSUtil.flattenAddressMap(map);
  for (ConfiguredNNAddress cnn : cnns) {
    InetSocketAddress address = cnn.getAddress();
    if (buffer.length() > 0) {
      buffer.append(" ");
    }
    buffer.append(address.getHostName());
  }
  printOut(buffer.toString());
}
 
Example 6
Source File: TestGetConf.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void verifyAddresses(HdfsConfiguration conf, TestType type,
    boolean checkPort, String... expected) throws Exception {
  // Ensure DFSUtil returned the right set of addresses
  Map<String, Map<String, InetSocketAddress>> map =
    getAddressListFromConf(type, conf);
  List<ConfiguredNNAddress> list = DFSUtil.flattenAddressMap(map);
  String[] actual = toStringArray(list);
  Arrays.sort(actual);
  Arrays.sort(expected);
  assertArrayEquals(expected, actual);

  // Test GetConf returned addresses
  getAddressListFromTool(type, conf, checkPort, list);
}