Examples of BlockInfo


Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

                  Collection<Block> toAdd,
                  Collection<Block> toRemove,
                  Collection<Block> toInvalidate) {
    // place a deilimiter in the list which separates blocks
    // that have been reported from those that have not
    BlockInfo delimiter = new BlockInfo(new Block(), 1);
    boolean added = this.addBlock(delimiter);
    assert added : "Delimiting block cannot be present in the node";
    if(newReport == null)
      newReport = new BlockListAsLongs( new long[0]);
    // scan the report and collect newly reported blocks
    // Note we are taking special precaution to limit tmp blocks allocated
    // as part this block report - which why block list is stored as longs
    Block iblk = new Block(); // a fixed new'ed block to be reused with index i
    Block oblk = new Block(); // for fixing genstamps
    for (int i = 0; i < newReport.getNumberOfBlocks(); ++i) {
      iblk.set(newReport.getBlockId(i), newReport.getBlockLen(i),
               newReport.getBlockGenStamp(i));
      BlockInfo storedBlock = blocksMap.getStoredBlock(iblk);
      if(storedBlock == null) {
        // if the block with a WILDCARD generation stamp matches
        // then accept this block.
        // This block has a diferent generation stamp on the datanode
        // because of a lease-recovery-attempt.
        oblk.set(newReport.getBlockId(i), newReport.getBlockLen(i),
                 GenerationStamp.WILDCARD_STAMP);
        storedBlock = blocksMap.getStoredBlock(oblk);
        if (storedBlock != null && storedBlock.getINode() != null &&
            (storedBlock.getGenerationStamp() <= iblk.getGenerationStamp() ||
             storedBlock.getINode().isUnderConstruction())) {
          // accept block. It wil be cleaned up on cluster restart.
        } else {
          storedBlock = null;
        }
      }
      if(storedBlock == null) {
        // If block is not in blocksMap it does not belong to any file
        toInvalidate.add(new Block(iblk));
        continue;
      }
      if(storedBlock.findDatanode(this) < 0) {// Known block, but not on the DN
        // if the size differs from what is in the blockmap, then return
        // the new block. addStoredBlock will then pick up the right size of this
        // block and will update the block object in the BlocksMap
        if (storedBlock.getNumBytes() != iblk.getNumBytes()) {
          toAdd.add(new Block(iblk));
        } else {
          toAdd.add(storedBlock);
        }
        continue;
      }
      // move block to the head of the list
      this.moveBlockToHead(storedBlock);
    }
    // collect blocks that have not been reported
    // all of them are next to the delimiter
    Iterator<Block> it = new BlockIterator(delimiter.getNext(0), this);
    while(it.hasNext()) {
      BlockInfo storedBlock = (BlockInfo)it.next();
      INodeFile file = storedBlock.getINode();
      if (file == null || !file.isUnderConstruction()) {
        toRemove.add(storedBlock);
      }
    }
    this.removeBlock(delimiter);
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

    public boolean hasNext() {
      return current != null;
    }

    public BlockInfo next() {
      BlockInfo res = current;
      current = current.getNext(current.findDatanode(node));
      return res;
    }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

    int numBlocks = in.readInt();
    BlockInfo[] blocks = new BlockInfo[numBlocks];
    Block blk = new Block();
    for (int i = 0; i < numBlocks; i++) {
      blk.readFields(in);
      blocks[i] = new BlockInfo(blk, blockReplication);
    }
    PermissionStatus perm = PermissionStatus.read(in);
    String clientName = readString(in);
    String clientMachine = readString(in);
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

      updateCount(inodes, inodes.length-1, 0,
          fileNode.getPreferredBlockSize()*fileNode.getReplication(), true);
     
      // associate the new list of blocks with this file
      namesystem.blocksMap.addINode(block, fileNode);
      BlockInfo blockInfo = namesystem.blocksMap.getStoredBlock(block);
      fileNode.addBlock(blockInfo);

      NameNode.stateChangeLog.debug("DIR* FSDirectory.addFile: "
                                    + path + " with " + block
                                    + " block is added to the in-memory "
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

        }
      }
     
      int index = 0;
      for (Block b : newnode.getBlocks()) {
        BlockInfo info = namesystem.blocksMap.addINode(b, newnode);
        newnode.setBlock(index, info); // inode refers to the block in BlocksMap
        index++;
      }
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

      INodeFile file = dir.getFileINode(src);

      Block[] blocks = file.getBlocks();
      if (blocks != null && blocks.length > 0) {
        Block last = blocks[blocks.length-1];
        BlockInfo storedBlock = blocksMap.getStoredBlock(last);
        if (file.getPreferredBlockSize() > storedBlock.getNumBytes()) {
          long fileLength = file.computeContentSummary().getLength();
          DatanodeDescriptor[] targets = new DatanodeDescriptor[blocksMap.numNodes(last)];
          Iterator<DatanodeDescriptor> it = blocksMap.nodeIterator(last);
          for (int i = 0; it != null && it.hasNext(); i++) {
            targets[i] = it.next();
          }
          lb = new LocatedBlock(last, targets,
                                fileLength-storedBlock.getNumBytes());

          // Remove block from replication queue.
          updateNeededReplications(last, 0, 0);

          // remove this block from the list of pending blocks to be deleted.
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo

      ) throws IOException {
    LOG.info("commitBlockSynchronization(lastblock=" + lastblock
          + ", newgenerationstamp=" + newgenerationstamp
          + ", newlength=" + newlength
          + ", newtargets=" + Arrays.asList(newtargets) + ")");
    final BlockInfo oldblockinfo = blocksMap.getStoredBlock(lastblock);
    if (oldblockinfo == null) {
      throw new IOException("Block (=" + lastblock + ") not found");
    }
    INodeFile iFile = oldblockinfo.getINode();
    if (!iFile.isUnderConstruction()) {
      throw new IOException("Unexpected block (=" + lastblock
          + ") since the file (=" + iFile.getLocalName()
          + ") is not under construction");
    }
    INodeFileUnderConstruction pendingFile = (INodeFileUnderConstruction)iFile;

    // Remove old block from blocks map. This always have to be done
    // because the generation stamp of this block is changing.
    blocksMap.removeBlock(oldblockinfo);

    if (deleteblock) {
      pendingFile.removeBlock(lastblock);
    }
    else {
      // update last block, construct newblockinfo and add it to the blocks map
      lastblock.set(lastblock.getBlockId(), newlength, newgenerationstamp);
      final BlockInfo newblockinfo = blocksMap.addINode(lastblock, pendingFile);
   
      //update block info
      DatanodeDescriptor[] descriptors = null;
      if (newtargets.length > 0) {
        descriptors = new DatanodeDescriptor[newtargets.length];
View Full Code Here

Examples of org.apache.hadoop.raid.DirectoryStripeReader.BlockInfo

    assertNotNull(lfs);
    for (int fid = 0; fid < lfs.size(); fid++) {
      FileStatus fsStat = lfs.get(fid);
      long numBlock = RaidNode.getNumBlocks(fsStat);
      for (int bid = 0; bid < numBlock; bid++) {
        blocks.add(new BlockInfo(fid, bid));
      }
      lengths[fid] = fsStat.getLen();
    }
    HashSet<Integer> affectedFiles = new HashSet<Integer>();
    HashSet<Integer> affectedBlocks = new HashSet<Integer>();
    // corrupt blocks
    for (int blockNumToCorrupt : listBlockNumToCorrupt) {
      if (blockNumToCorrupt >= blocks.size()) {
        continue;
      }
      BlockInfo bi = null;
      int blockIndex = blockNumToCorrupt;
      if (blockNumToCorrupt < 0) {
        blockIndex = blocks.size() + blockNumToCorrupt;
        if (blockIndex < 0) {
          continue;
View Full Code Here

Examples of org.apache.hadoop.raid.PlacementMonitor.BlockInfo

      List<BlockInfo> srcInfoList = new LinkedList<BlockInfo>();
      for (DatanodeInfo d : sourceLocations) {
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId++, 0, 0L), new DatanodeInfo[]{d}, 0L,
            0, 0, 0);
        BlockInfo info = createBlockInfo(src, lb);
        srcBlockList.add(lb);
        srcInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
      }
      List<LocatedBlock> parityBlockList = new LinkedList<LocatedBlock>();
      List<BlockInfo> parityInfoList = new LinkedList<BlockInfo>();
      for (DatanodeInfo d : parityLocations) {
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId++, 0, 0L), new DatanodeInfo[]{d}, 0L,
            0, 0, 0);
        parityBlockList.add(lb);
        BlockInfo info = createBlockInfo(parity, lb);
        parityInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
      }
      FileStatus stat = new FileStatus(14, false, 1, 1, 0, src);
View Full Code Here

Examples of tachyon.worker.hierarchy.BlockInfo

        return null;
      } else {
        blockSize = dirCandidate.getBlockSize(blockId);
      }
      // Add info of the block to the list
      blockInfoList.add(new BlockInfo(dirCandidate, blockId, blockSize));
      dir2BlocksToEvict.put(dirCandidate, blockId);
      dir2LRUBlocks.remove(dirCandidate);
      long evictionSize;
      // Update eviction size for this StorageDir
      if (sizeToEvict.containsKey(dirCandidate)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.