Package org.apache.hadoop.hdfs.protocol

Examples of org.apache.hadoop.hdfs.protocol.LocatedBlockWithFileName


   *
   * @throws IOException
   */
  private int getBlockInfo(String[] argv, int i) throws IOException {
    long blockId = Long.valueOf(argv[i++]);
    LocatedBlockWithFileName locatedBlock =
        getDFS().getClient().getBlockInfo(blockId);
 
    if (null == locatedBlock) {
      System.err.println("Could not find the block with id : " + blockId);
      return -1;
    }
   
    StringBuilder sb = new StringBuilder();
    sb.append("blockid: ")
          .append(locatedBlock.getBlock().getBlockId()).append("\n")
          .append("filename: ")
          .append(locatedBlock.getFileName()).append("\n")
          .append("locations: ");
   
    DatanodeInfo[] locs = locatedBlock.getLocations();
    for (int k=0; k<locs.length; k++) {
      if (k > 0) {
        sb.append(" , ");
      }
      sb.append(locs[k].getHostName());
View Full Code Here


   *
   * @throws IOException
   */
  private int getBlockInfo(String[] argv, int i) throws IOException {
    long blockId = Long.valueOf(argv[i++]);
    LocatedBlockWithFileName locatedBlock =
        getDFS().getClient().getBlockInfo(blockId);
 
    if (null == locatedBlock) {
      System.err.println("Could not find the block with id : " + blockId);
      return -1;
    }
   
    StringBuilder sb = new StringBuilder();
    sb.append("blockid: ")
          .append(locatedBlock.getBlock().getBlockId()).append("\n")
          .append("filename: ")
          .append(locatedBlock.getFileName()).append("\n")
          .append("locations: ");
   
    DatanodeInfo[] locs = locatedBlock.getLocations();
    for (int k=0; k<locs.length; k++) {
      if (k > 0) {
        sb.append(" , ");
      }
      sb.append(locs[k].getHostName());
View Full Code Here

            } else {
              LOG.info("Using zeros for location " + i);
              inputs[i] = new RaidUtils.ZeroInputStream(limit);
              continue;
            }
            LocatedBlockWithFileName lb =
                srcFs.getClient().getBlockInfo(blockId);
            if (lb == null) {
              throw new BlockMissingException(String.valueOf(blockId),
                "Location " + i + " can not be found. Block id: " + blockId, 0);
            } else {
              Path filePath = new Path(lb.getFileName());
              FileStatus stat = srcFs.getFileStatus(filePath);
              long blockSize = stat.getBlockSize();
              if (offsetInBlock > blockSize) {
                stm = new RaidUtils.ZeroInputStream(limit);
              } else {
                if (srcFs.exists(filePath)) {
                  long startOffset =
                      getBlockIdInFile(srcFs, filePath, blockId) * blockSize;
                  long offset = startOffset + offsetInBlock;
                  LOG.info("Opening " + lb.getFileName() + ":" + offset +
                      " for location " + i);
                  FSDataInputStream is = srcFs.open(filePath);
                  is.seek(offset);
                  stm = is;
                } else {
                  LOG.info("Location " + i + ", File " + lb.getFileName() +
                      " does not exist, using zeros");
                  locationsToNotRead.add(i);
                  stm = new RaidUtils.ZeroInputStream(limit);
                }
              }
View Full Code Here

   *
   * @throws IOException
   */
  private int getBlockInfo(String[] argv, int i) throws IOException {
    long blockId = Long.valueOf(argv[i++]);
    LocatedBlockWithFileName locatedBlock =
        getDFS().getClient().getBlockInfo(blockId);
 
    if (null == locatedBlock) {
      System.err.println("Could not find the block with id : " + blockId);
      return -1;
    }
   
    StringBuilder sb = new StringBuilder();
    sb.append("block: ")
          .append(locatedBlock.getBlock()).append("\n")
          .append("filename: ")
          .append(locatedBlock.getFileName()).append("\n")
          .append("locations: ");
   
    DatanodeInfo[] locs = locatedBlock.getLocations();
    for (int k=0; k<locs.length; k++) {
      if (k > 0) {
        sb.append(" , ");
      }
      sb.append(locs[k].getHostName());
View Full Code Here

      // Get the original block locations
      List<LocatedBlock> blocks = located.getLocatedBlocks();
      LocatedBlock firstBlock = blocks.get(0);
      long blockId = firstBlock.getBlock().getBlockId();     

      LocatedBlockWithFileName locatedBlockWithFileName =
          nn.getBlockInfo(blockId);
     
      assertEquals(pathStr, locatedBlockWithFileName.getFileName());
      assertEquals(3, locatedBlockWithFileName.getLocations().length);

      // Test the deleted block id
      fs.delete(path, true);
      assertNull(nn.getBlockInfo(blockId));
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.protocol.LocatedBlockWithFileName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.