Java Code Examples for org.apache.hadoop.hdfs.protocol.DatanodeInfo#isDecommissioned()

The following examples show how to use org.apache.hadoop.hdfs.protocol.DatanodeInfo#isDecommissioned() . 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: Dispatcher.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private boolean shouldIgnore(DatanodeInfo dn) {
  // ignore decommissioned nodes
  final boolean decommissioned = dn.isDecommissioned();
  // ignore decommissioning nodes
  final boolean decommissioning = dn.isDecommissionInProgress();
  // ignore nodes in exclude list
  final boolean excluded = Util.isExcluded(excludedNodes, dn);
  // ignore nodes not in the include list (if include list is not empty)
  final boolean notIncluded = !Util.isIncluded(includedNodes, dn);

  if (decommissioned || decommissioning || excluded || notIncluded) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Excluding datanode " + dn + ": " + decommissioned + ", "
          + decommissioning + ", " + excluded + ", " + notIncluded);
    }
    return true;
  }
  return false;
}
 
Example 2
Source File: Dispatcher.java    From big-c with Apache License 2.0 6 votes vote down vote up
private boolean shouldIgnore(DatanodeInfo dn) {
  // ignore decommissioned nodes
  final boolean decommissioned = dn.isDecommissioned();
  // ignore decommissioning nodes
  final boolean decommissioning = dn.isDecommissionInProgress();
  // ignore nodes in exclude list
  final boolean excluded = Util.isExcluded(excludedNodes, dn);
  // ignore nodes not in the include list (if include list is not empty)
  final boolean notIncluded = !Util.isIncluded(includedNodes, dn);

  if (decommissioned || decommissioning || excluded || notIncluded) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Excluding datanode " + dn + ": " + decommissioned + ", "
          + decommissioning + ", " + excluded + ", " + notIncluded);
    }
    return true;
  }
  return false;
}
 
Example 3
Source File: DatanodeBenThread.java    From RDFS with Apache License 2.0 6 votes vote down vote up
private static Set<DatanodeInfo> getValidDatanodes(JobConf nameNodeConf,
    DatanodeBenRunTimeConstants rtc) throws IOException {
  FileSystem fs = FileSystem.get(nameNodeConf);
  DistributedFileSystem dfs = getDFS(fs);
  HashMap<String, ArrayList<Path>> nsPickLists = 
      rtc.pickLists.get(nameNodeConf.get(FileSystem.FS_DEFAULT_NAME_KEY));
  DatanodeInfo[] dnStats = dfs.getLiveDataNodeStats();
  Set<DatanodeInfo> validDatanodes = new HashSet<DatanodeInfo>();
  for (DatanodeInfo dn: dnStats) {
    if (dn.isDecommissioned() || dn.isDecommissionInProgress()) {
      continue;
    }
    if (!nsPickLists.containsKey(dn.getHostName())) {
      continue;
    }
    validDatanodes.add(dn);
  }
  return validDatanodes;
}
 
Example 4
Source File: TestDecommission.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
private boolean checkNodeState(FileSystem filesys, 
                               String node, 
                               NodeState state) throws IOException {
  DistributedFileSystem dfs = (DistributedFileSystem) filesys;
  boolean done = false;
  boolean foundNode = false;
  DatanodeInfo[] datanodes = dfs.getDataNodeStats();
  for (int i = 0; i < datanodes.length; i++) {
    DatanodeInfo dn = datanodes[i];
    if (dn.getName().equals(node)) {
      if (state == NodeState.DECOMMISSIONED) {
        done = dn.isDecommissioned();
      } else if (state == NodeState.DECOMMISSION_INPROGRESS) {
        done = dn.isDecommissionInProgress();
      } else {
        done = (!dn.isDecommissionInProgress() && !dn.isDecommissioned());
      }
      System.out.println(dn.getDatanodeReport());
      foundNode = true;
    }
  }
  if (!foundNode) {
    throw new IOException("Could not find node: " + node);
  }
  return done;
}
 
Example 5
Source File: DFSUtil.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(DatanodeInfo a, DatanodeInfo b) {
  // Decommissioned nodes will still be moved to the end of the list
  if (a.isDecommissioned()) {
    return b.isDecommissioned() ? 0 : 1;
  } else if (b.isDecommissioned()) {
    return -1;
  }
  // Stale nodes will be moved behind the normal nodes
  boolean aStale = a.isStale(staleInterval);
  boolean bStale = b.isStale(staleInterval);
  return aStale == bStale ? 0 : (aStale ? 1 : -1);
}
 
Example 6
Source File: NamenodeWebHdfsMethods.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Choose the datanode to redirect the request. Note that the nodes have been
 * sorted based on availability and network distances, thus it is sufficient
 * to return the first element of the node here.
 */
private static DatanodeInfo bestNode(DatanodeInfo[] nodes,
    HashSet<Node> excludes) throws IOException {
  for (DatanodeInfo dn: nodes) {
    if (false == dn.isDecommissioned() && false == excludes.contains(dn)) {
      return dn;
    }
  }
  throw new IOException("No active nodes contain this block");
}
 
Example 7
Source File: DFSUtil.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(DatanodeInfo a, DatanodeInfo b) {
  // Decommissioned nodes will still be moved to the end of the list
  if (a.isDecommissioned()) {
    return b.isDecommissioned() ? 0 : 1;
  } else if (b.isDecommissioned()) {
    return -1;
  }
  // Stale nodes will be moved behind the normal nodes
  boolean aStale = a.isStale(staleInterval);
  boolean bStale = b.isStale(staleInterval);
  return aStale == bStale ? 0 : (aStale ? 1 : -1);
}
 
Example 8
Source File: NamenodeWebHdfsMethods.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Choose the datanode to redirect the request. Note that the nodes have been
 * sorted based on availability and network distances, thus it is sufficient
 * to return the first element of the node here.
 */
private static DatanodeInfo bestNode(DatanodeInfo[] nodes,
    HashSet<Node> excludes) throws IOException {
  for (DatanodeInfo dn: nodes) {
    if (false == dn.isDecommissioned() && false == excludes.contains(dn)) {
      return dn;
    }
  }
  throw new IOException("No active nodes contain this block");
}
 
Example 9
Source File: DFSUtil.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(DatanodeInfo a, DatanodeInfo b) {
  return a.isDecommissioned() == b.isDecommissioned() ? 0 : 
    a.isDecommissioned() ? 1 : -1;
}
 
Example 10
Source File: DFSUtil.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(DatanodeInfo a, DatanodeInfo b) {
  return a.isDecommissioned() == b.isDecommissioned() ? 0 : 
    a.isDecommissioned() ? 1 : -1;
}
 
Example 11
Source File: DFSUtil.java    From RDFS with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(DatanodeInfo a, DatanodeInfo b) {
  return a.isDecommissioned() == b.isDecommissioned() ? 0 :
    a.isDecommissioned() ? 1 : -1;
}