Java 类org.apache.hadoop.hdfs.server.blockmanagement.MutableBlockCollection 实例源码

项目:hops    文件:FSNamesystem.java   
/**
 * Check that the indicated file's blocks are present and
 * replicated.  If not, return false. If checkAll is true, then check
 * all blocks, otherwise check only penultimate block.
 */
private boolean checkFileProgress(INodeFile v, boolean checkAll)
    throws IOException {
  if (checkAll) {
    //
    // check all blocks of the file.
    //
    for (BlockInfo block : v.getBlocks()) {
      if (!block.isComplete()) {
        BlockInfo cBlock = blockManager
            .tryToCompleteBlock((MutableBlockCollection) v,
                block.getBlockIndex());
        if (cBlock != null) {
          block = cBlock;
        }
        if (!block.isComplete()) {
          LOG.info("BLOCK* checkFileProgress: " + block +
              " has not reached minimal replication " +
              blockManager.minReplication);
          return false;
        }
      }
    }
  } else {
    //
    // check the penultimate block of this file
    //
    BlockInfo b = v.getPenultimateBlock();
    if (b != null && !b.isComplete()) {
      blockManager
          .tryToCompleteBlock((MutableBlockCollection) v, b.getBlockIndex());
      b = v.getPenultimateBlock();
      if (!b.isComplete()) {
        LOG.info("BLOCK* checkFileProgress: " + b +
            " has not reached minimal replication " +
            blockManager.minReplication);
        return false;
      }

    }
  }
  return true;
}