本文整理匯總了Java中org.apache.hadoop.hdfs.DistributedFileSystem.getDataNodeStats方法的典型用法代碼示例。如果您正苦於以下問題:Java DistributedFileSystem.getDataNodeStats方法的具體用法?Java DistributedFileSystem.getDataNodeStats怎麽用?Java DistributedFileSystem.getDataNodeStats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hdfs.DistributedFileSystem
的用法示例。
在下文中一共展示了DistributedFileSystem.getDataNodeStats方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDateNodeHost
import org.apache.hadoop.hdfs.DistributedFileSystem; //導入方法依賴的package包/類
public static void getDateNodeHost() throws IOException{
Configuration conf = getConf();
FileSystem fs=FileSystem.get(conf);
DistributedFileSystem hdfs = (DistributedFileSystem)fs;
DatanodeInfo[] dataNodeStats = hdfs.getDataNodeStats();
for(int i=0;i<dataNodeStats.length;i++){
System.out.println("DataNode_"+i+"_Name:"+dataNodeStats[i].getHostName());
}
}
示例2: printTopology
import org.apache.hadoop.hdfs.DistributedFileSystem; //導入方法依賴的package包/類
/**
* Display each rack and the nodes assigned to that rack, as determined
* by the NameNode, in a hierarchical manner. The nodes and racks are
* sorted alphabetically.
*
* @throws IOException If an error while getting datanode report
*/
public int printTopology() throws IOException {
DistributedFileSystem dfs = getDFS();
final DatanodeInfo[] report = dfs.getDataNodeStats();
// Build a map of rack -> nodes from the datanode report
HashMap<String, TreeSet<String> > tree = new HashMap<String, TreeSet<String>>();
for(DatanodeInfo dni : report) {
String location = dni.getNetworkLocation();
String name = dni.getName();
if(!tree.containsKey(location)) {
tree.put(location, new TreeSet<String>());
}
tree.get(location).add(name);
}
// Sort the racks (and nodes) alphabetically, display in order
ArrayList<String> racks = new ArrayList<String>(tree.keySet());
Collections.sort(racks);
for(String r : racks) {
System.out.println("Rack: " + r);
TreeSet<String> nodes = tree.get(r);
for(String n : nodes) {
System.out.print(" " + n);
String hostname = NetUtils.getHostNameOfIP(n);
if(hostname != null)
System.out.print(" (" + hostname + ")");
System.out.println();
}
System.out.println();
}
return 0;
}
示例3: getNodeInfo
import org.apache.hadoop.hdfs.DistributedFileSystem; //導入方法依賴的package包/類
public DatanodeInfo[] getNodeInfo() throws IOException {
DistributedFileSystem hdfs = (DistributedFileSystem) fs;
return hdfs.getDataNodeStats();
}