本文整理汇总了Java中org.apache.hadoop.hdfs.DFSUtil.flattenAddressMap方法的典型用法代码示例。如果您正苦于以下问题:Java DFSUtil.flattenAddressMap方法的具体用法?Java DFSUtil.flattenAddressMap怎么用?Java DFSUtil.flattenAddressMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.DFSUtil
的用法示例。
在下文中一共展示了DFSUtil.flattenAddressMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWorkInternal
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
@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;
}
示例2: printMap
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
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());
}
示例3: verifyAddresses
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
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);
}