Java Code Examples for org.apache.hadoop.hdfs.protocol.DatanodeInfo#getNetworkLocation()
The following examples show how to use
org.apache.hadoop.hdfs.protocol.DatanodeInfo#getNetworkLocation() .
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: PBHelper.java From hadoop with Apache License 2.0 | 6 votes |
public static DatanodeInfoProto convert(DatanodeInfo info) { DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder(); if (info.getNetworkLocation() != null) { builder.setLocation(info.getNetworkLocation()); } builder .setId(PBHelper.convert((DatanodeID)info)) .setCapacity(info.getCapacity()) .setDfsUsed(info.getDfsUsed()) .setRemaining(info.getRemaining()) .setBlockPoolUsed(info.getBlockPoolUsed()) .setCacheCapacity(info.getCacheCapacity()) .setCacheUsed(info.getCacheUsed()) .setLastUpdate(info.getLastUpdate()) .setLastUpdateMonotonic(info.getLastUpdateMonotonic()) .setXceiverCount(info.getXceiverCount()) .setAdminState(PBHelper.convert(info.getAdminState())) .build(); return builder.build(); }
Example 2
Source File: PBHelper.java From big-c with Apache License 2.0 | 6 votes |
public static DatanodeInfoProto convert(DatanodeInfo info) { DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder(); if (info.getNetworkLocation() != null) { builder.setLocation(info.getNetworkLocation()); } builder .setId(PBHelper.convert((DatanodeID)info)) .setCapacity(info.getCapacity()) .setDfsUsed(info.getDfsUsed()) .setRemaining(info.getRemaining()) .setBlockPoolUsed(info.getBlockPoolUsed()) .setCacheCapacity(info.getCacheCapacity()) .setCacheUsed(info.getCacheUsed()) .setLastUpdate(info.getLastUpdate()) .setLastUpdateMonotonic(info.getLastUpdateMonotonic()) .setXceiverCount(info.getXceiverCount()) .setAdminState(PBHelper.convert(info.getAdminState())) .build(); return builder.build(); }
Example 3
Source File: DFSAdmin.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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; }
Example 4
Source File: DFSAdmin.java From big-c with Apache License 2.0 | 5 votes |
/** * 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; }
Example 5
Source File: BlockPlacementPolicyWithNodeGroup.java From hadoop with Apache License 2.0 | 4 votes |
@Override protected String getRack(final DatanodeInfo cur) { String nodeGroupString = cur.getNetworkLocation(); return NetworkTopology.getFirstHalf(nodeGroupString); }
Example 6
Source File: BlockPlacementPolicyWithNodeGroup.java From big-c with Apache License 2.0 | 4 votes |
@Override protected String getRack(final DatanodeInfo cur) { String nodeGroupString = cur.getNetworkLocation(); return NetworkTopology.getFirstHalf(nodeGroupString); }
Example 7
Source File: BlockPlacementPolicy.java From hadoop with Apache License 2.0 | 2 votes |
/** * Get rack string from a data node * @return rack of data node */ protected String getRack(final DatanodeInfo datanode) { return datanode.getNetworkLocation(); }
Example 8
Source File: BlockPlacementPolicy.java From big-c with Apache License 2.0 | 2 votes |
/** * Get rack string from a data node * @return rack of data node */ protected String getRack(final DatanodeInfo datanode) { return datanode.getNetworkLocation(); }