• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BlockInfoUnderConstruction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction的典型用法代码示例。如果您正苦于以下问题:Java BlockInfoUnderConstruction类的具体用法?Java BlockInfoUnderConstruction怎么用?Java BlockInfoUnderConstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlockInfoUnderConstruction类属于org.apache.hadoop.hdfs.server.blockmanagement包,在下文中一共展示了BlockInfoUnderConstruction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setLastBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
@Override // BlockCollection, the file should be under construction
public BlockInfoUnderConstruction setLastBlock(BlockInfo lastBlock,
    DatanodeStorageInfo[] locations) throws IOException {
  Preconditions.checkState(isUnderConstruction(),
      "file is no longer under construction");

  if (numBlocks() == 0) {
    throw new IOException("Failed to set last block: File is empty.");
  }
  BlockInfoUnderConstruction ucBlock =
    lastBlock.convertToBlockUnderConstruction(
        BlockUCState.UNDER_CONSTRUCTION, locations);
  ucBlock.setBlockCollection(this);
  setBlock(numBlocks() - 1, ucBlock);
  return ucBlock;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:17,代码来源:INodeFile.java


示例2: computeFileSize

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * Compute file size of the current file.
 * 
 * @param includesLastUcBlock
 *          If the last block is under construction, should it be included?
 * @param usePreferredBlockSize4LastUcBlock
 *          If the last block is under construction, should we use actual
 *          block size or preferred block size?
 *          Note that usePreferredBlockSize4LastUcBlock is ignored
 *          if includesLastUcBlock == false.
 * @return file size
 */
public final long computeFileSize(boolean includesLastUcBlock,
    boolean usePreferredBlockSize4LastUcBlock) {
  if (blocks == null || blocks.length == 0) {
    return 0;
  }
  final int last = blocks.length - 1;
  //check if the last block is BlockInfoUnderConstruction
  long size = blocks[last].getNumBytes();
  if (blocks[last] instanceof BlockInfoUnderConstruction) {
     if (!includesLastUcBlock) {
       size = 0;
     } else if (usePreferredBlockSize4LastUcBlock) {
       size = getPreferredBlockSize();
     }
  }
  //sum other blocks
  for(int i = 0; i < last; i++) {
    size += blocks[i].getNumBytes();
  }
  return size;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:34,代码来源:INodeFile.java


示例3: getExpectedPrimaryNode

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * @return the node which is expected to run the recovery of the
 * given block, which is known to be under construction inside the
 * given NameNOde.
 */
public static DatanodeDescriptor getExpectedPrimaryNode(NameNode nn,
    ExtendedBlock blk) {
  BlockManager bm0 = nn.getNamesystem().getBlockManager();
  BlockInfo storedBlock = bm0.getStoredBlock(blk.getLocalBlock());
  assertTrue("Block " + blk + " should be under construction, " +
      "got: " + storedBlock,
      storedBlock instanceof BlockInfoUnderConstruction);
  BlockInfoUnderConstruction ucBlock =
    (BlockInfoUnderConstruction)storedBlock;
  // We expect that the replica with the most recent heart beat will be
  // the one to be in charge of the synchronization / recovery protocol.
  final DatanodeStorageInfo[] storages = ucBlock.getExpectedStorageLocations();
  DatanodeStorageInfo expectedPrimary = storages[0];
  long mostRecentLastUpdate = expectedPrimary.getDatanodeDescriptor().getLastUpdate();
  for (int i = 1; i < storages.length; i++) {
    final long lastUpdate = storages[i].getDatanodeDescriptor().getLastUpdate();
    if (lastUpdate > mostRecentLastUpdate) {
      expectedPrimary = storages[i];
      mostRecentLastUpdate = lastUpdate;
    }
  }
  return expectedPrimary.getDatanodeDescriptor();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:29,代码来源:DFSTestUtil.java


示例4: makeNameSystemSpy

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
private FSNamesystem makeNameSystemSpy(Block block,
                                       INodeFileUnderConstruction file)
    throws IOException {
  Configuration conf = new Configuration();
  FSImage image = new FSImage(conf);
  DatanodeDescriptor[] targets = new DatanodeDescriptor[0];

  FSNamesystem namesystem = new FSNamesystem(conf, image);
  FSNamesystem namesystemSpy = spy(namesystem);
  BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
      block, 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
  blockInfo.setBlockCollection(file);
  blockInfo.setGenerationStamp(genStamp);
  blockInfo.initializeBlockRecovery(genStamp);
  doReturn(true).when(file).removeLastBlock(any(Block.class));

  doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class));
  doReturn("").when(namesystemSpy).closeFileCommitBlocks(
      any(INodeFileUnderConstruction.class),
      any(BlockInfo.class));
  doReturn("").when(namesystemSpy).persistBlocks(
      any(INodeFileUnderConstruction.class), anyBoolean());
  doReturn(mock(FSEditLog.class)).when(namesystemSpy).getEditLog();

  return namesystemSpy;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:27,代码来源:TestCommitBlockSynchronization.java


示例5: getExpectedPrimaryNode

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * @return the node which is expected to run the recovery of the
 * given block, which is known to be under construction inside the
 * given NameNOde.
 */
private DatanodeDescriptor getExpectedPrimaryNode(NameNode nn,
    ExtendedBlock blk) {
  BlockManager bm0 = nn.getNamesystem().getBlockManager();
  BlockInfo storedBlock = bm0.getStoredBlock(blk.getLocalBlock());
  assertTrue("Block " + blk + " should be under construction, " +
      "got: " + storedBlock,
      storedBlock instanceof BlockInfoUnderConstruction);
  BlockInfoUnderConstruction ucBlock =
    (BlockInfoUnderConstruction)storedBlock;
  // We expect that the replica with the most recent heart beat will be
  // the one to be in charge of the synchronization / recovery protocol.
  DatanodeDescriptor[] datanodes = ucBlock.getExpectedLocations();
  DatanodeDescriptor expectedPrimary = datanodes[0];
  long mostRecentLastUpdate = expectedPrimary.getLastUpdate();
  for (int i = 1; i < datanodes.length; i++) {
    if (datanodes[i].getLastUpdate() > mostRecentLastUpdate) {
      expectedPrimary = datanodes[i];
      mostRecentLastUpdate = expectedPrimary.getLastUpdate();
    }
  }
  return expectedPrimary;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:28,代码来源:TestPipelinesFailover.java


示例6: computeFileSize

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
static long computeFileSize(boolean includesBlockInfoUnderConstruction,
    BlockInfo[] blocks) throws StorageException {
  if (blocks == null || blocks.length == 0) {
    return 0;
  }
  final int last = blocks.length - 1;
  //check if the last block is BlockInfoUnderConstruction
  long bytes = 0;
  
  if(blocks[last] instanceof BlockInfoUnderConstruction){
      if(includesBlockInfoUnderConstruction){
          bytes = blocks[last].getNumBytes();
      }
  }else{
      bytes = blocks[last].getNumBytes();
  }
  for (int i = 0; i < last; i++) {
    bytes += blocks[i].getNumBytes();
  }
  return bytes;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:INodeFile.java


示例7: convertHDFStoDAL

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
@Override
public BlockInfo convertHDFStoDAL(
    org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo hdfsClass)
    throws StorageException {
  if (hdfsClass != null) {
    BlockInfo hopBlkInfo =
        new BlockInfo(hdfsClass.getBlockId(), hdfsClass.getBlockIndex(),
            hdfsClass.getInodeId(), hdfsClass.getNumBytes(),
            hdfsClass.getGenerationStamp(),
            hdfsClass.getBlockUCState().ordinal(), hdfsClass.getTimestamp());
    if (hdfsClass instanceof BlockInfoUnderConstruction) {
      BlockInfoUnderConstruction ucBlock =
          (BlockInfoUnderConstruction) hdfsClass;
      hopBlkInfo.setPrimaryNodeIndex(ucBlock.getPrimaryNodeIndex());
      hopBlkInfo.setBlockRecoveryId(ucBlock.getBlockRecoveryId());
    }
    return hopBlkInfo;
  } else {
    return null;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:BlockInfoDALAdaptor.java


示例8: resolveINodeFromBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
public static INodeIdentifier resolveINodeFromBlock(final Block b)
    throws StorageException {
  if (b instanceof BlockInfo || b instanceof BlockInfoUnderConstruction) {
    INodeIdentifier inodeIden =
        new INodeIdentifier(((BlockInfo) b).getInodeId());
    INodeDALAdaptor ida = (INodeDALAdaptor) HdfsStorageFactory
        .getDataAccess(INodeDataAccess.class);
    INode inode = ida.findInodeByIdFTIS(((BlockInfo) b).getInodeId());
    if (inode != null) {
      inodeIden.setName(inode.getLocalName());
      inodeIden.setPid(inode.getParentId());
      inodeIden.setPartitionId(inode.getPartitionId());
    }
    return inodeIden;
  } else {
    return resolveINodeFromBlockID(b.getBlockId());
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:19,代码来源:INodeUtil.java


示例9: makeNameSystemSpy

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
private FSNamesystem makeNameSystemSpy(Block block, INodeFile file)
    throws IOException {
  Configuration conf = new Configuration();
  FSImage image = new FSImage(conf);
  final DatanodeStorageInfo[] targets = {};

  FSNamesystem namesystem = new FSNamesystem(conf, image);
  FSNamesystem namesystemSpy = spy(namesystem);
  BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
      block, 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
  blockInfo.setBlockCollection(file);
  blockInfo.setGenerationStamp(genStamp);
  blockInfo.initializeBlockRecovery(genStamp);
  doReturn(true).when(file).removeLastBlock(any(Block.class));
  doReturn(true).when(file).isUnderConstruction();

  doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class));
  doReturn("").when(namesystemSpy).closeFileCommitBlocks(
      any(INodeFile.class), any(BlockInfo.class));
  doReturn("").when(namesystemSpy).persistBlocks(
      any(INodeFile.class), anyBoolean());
  doReturn(mock(FSEditLog.class)).when(namesystemSpy).getEditLog();

  return namesystemSpy;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:26,代码来源:TestCommitBlockSynchronization.java


示例10: getExpectedPrimaryNode

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * @return the node which is expected to run the recovery of the
 * given block, which is known to be under construction inside the
 * given NameNOde.
 */
private DatanodeDescriptor getExpectedPrimaryNode(NameNode nn,
    ExtendedBlock blk) {
  BlockManager bm0 = nn.getNamesystem().getBlockManager();
  BlockInfo storedBlock = bm0.getStoredBlock(blk.getLocalBlock());
  assertTrue("Block " + blk + " should be under construction, " +
      "got: " + storedBlock,
      storedBlock instanceof BlockInfoUnderConstruction);
  BlockInfoUnderConstruction ucBlock =
    (BlockInfoUnderConstruction)storedBlock;
  // We expect that the replica with the most recent heart beat will be
  // the one to be in charge of the synchronization / recovery protocol.
  final DatanodeStorageInfo[] storages = ucBlock.getExpectedStorageLocations();
  DatanodeStorageInfo expectedPrimary = storages[0];
  long mostRecentLastUpdate = expectedPrimary.getDatanodeDescriptor().getLastUpdate();
  for (int i = 1; i < storages.length; i++) {
    final long lastUpdate = storages[i].getDatanodeDescriptor().getLastUpdate();
    if (lastUpdate > mostRecentLastUpdate) {
      expectedPrimary = storages[i];
      mostRecentLastUpdate = lastUpdate;
    }
  }
  return expectedPrimary.getDatanodeDescriptor();
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:29,代码来源:TestPipelinesFailover.java


示例11: addNewBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * Add a new block into the given INodeFile
 */
private void addNewBlock(FSDirectory fsDir, AddBlockOp op, INodeFile file)
    throws IOException {
  BlockInfo[] oldBlocks = file.getBlocks();
  Block pBlock = op.getPenultimateBlock();
  Block newBlock= op.getLastBlock();
  
  if (pBlock != null) { // the penultimate block is not null
    Preconditions.checkState(oldBlocks != null && oldBlocks.length > 0);
    // compare pBlock with the last block of oldBlocks
    Block oldLastBlock = oldBlocks[oldBlocks.length - 1];
    if (oldLastBlock.getBlockId() != pBlock.getBlockId()
        || oldLastBlock.getGenerationStamp() != pBlock.getGenerationStamp()) {
      throw new IOException(
          "Mismatched block IDs or generation stamps for the old last block of file "
              + op.getPath() + ", the old last block is " + oldLastBlock
              + ", and the block read from editlog is " + pBlock);
    }
    
    oldLastBlock.setNumBytes(pBlock.getNumBytes());
    if (oldLastBlock instanceof BlockInfoUnderConstruction) {
      fsNamesys.getBlockManager().forceCompleteBlock(file,
          (BlockInfoUnderConstruction) oldLastBlock);
      fsNamesys.getBlockManager().processQueuedMessagesForBlock(pBlock);
    }
  } else { // the penultimate block is null
    Preconditions.checkState(oldBlocks == null || oldBlocks.length == 0);
  }
  // add the new block
  BlockInfo newBI = new BlockInfoUnderConstruction(
        newBlock, file.getBlockReplication());
  fsNamesys.getBlockManager().addBlockCollection(newBI, file);
  file.addBlock(newBI);
  fsNamesys.getBlockManager().processQueuedMessagesForBlock(newBlock);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:38,代码来源:FSEditLogLoader.java


示例12: cleanZeroSizeBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * When deleting a file in the current fs directory, and the file is contained
 * in a snapshot, we should delete the last block if it's under construction
 * and its size is 0.
 */
void cleanZeroSizeBlock(final INodeFile f,
    final BlocksMapUpdateInfo collectedBlocks) {
  final BlockInfo[] blocks = f.getBlocks();
  if (blocks != null && blocks.length > 0
      && blocks[blocks.length - 1] instanceof BlockInfoUnderConstruction) {
    BlockInfoUnderConstruction lastUC =
        (BlockInfoUnderConstruction) blocks[blocks.length - 1];
    if (lastUC.getNumBytes() == 0) {
      // this is a 0-sized block. do not need check its UC state here
      collectedBlocks.addDeleteBlock(lastUC);
      f.removeLastBlock(lastUC);
    }
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:20,代码来源:FileUnderConstructionFeature.java


示例13: addBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * Add a block to the file. Returns a reference to the added block.
 */
BlockInfo addBlock(String path, INodesInPath inodesInPath, Block block,
    DatanodeStorageInfo[] targets) throws IOException {
  writeLock();
  try {
    final INodeFile fileINode = inodesInPath.getLastINode().asFile();
    Preconditions.checkState(fileINode.isUnderConstruction());

    // check quota limits and updated space consumed
    updateCount(inodesInPath, 0, fileINode.getBlockDiskspace(), true);

    // associate new last block for the file
    BlockInfoUnderConstruction blockInfo =
      new BlockInfoUnderConstruction(
          block,
          fileINode.getFileReplication(),
          BlockUCState.UNDER_CONSTRUCTION,
          targets);
    getBlockManager().addBlockCollection(blockInfo, fileINode);
    fileINode.addBlock(blockInfo);

    if(NameNode.stateChangeLog.isDebugEnabled()) {
      NameNode.stateChangeLog.debug("DIR* FSDirectory.addBlock: "
          + path + " with " + block
          + " block is added to the in-memory "
          + "file system");
    }
    return blockInfo;
  } finally {
    writeUnlock();
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:35,代码来源:FSDirectory.java


示例14: isInSnapshot

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
@Override
public boolean isInSnapshot(BlockInfoUnderConstruction blockUC) {
  assert hasReadLock();
  final BlockCollection bc = blockUC.getBlockCollection();
  if (bc == null || !(bc instanceof INodeFile)
      || !bc.isUnderConstruction()) {
    return false;
  }

  INodeFile inodeUC = (INodeFile) bc;
  String fullName = inodeUC.getName();
  try {
    if (fullName != null && fullName.startsWith(Path.SEPARATOR)
        && dir.getINode(fullName) == inodeUC) {
      // If file exists in normal path then no need to look in snapshot
      return false;
    }
  } catch (UnresolvedLinkException e) {
    LOG.error("Error while resolving the link : " + fullName, e);
    return false;
  }
  /*
   * 1. if bc is an instance of INodeFileUnderConstructionWithSnapshot, and
   * bc is not in the current fsdirectory tree, bc must represent a snapshot
   * file. 
   * 2. if fullName is not an absolute path, bc cannot be existent in the 
   * current fsdirectory tree. 
   * 3. if bc is not the current node associated with fullName, bc must be a
   * snapshot inode.
   */
  return true;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:33,代码来源:FSNamesystem.java


示例15: makeNameSystemSpy

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
private FSNamesystem makeNameSystemSpy(Block block, INodeFile file)
    throws IOException {
  Configuration conf = new Configuration();
  FSImage image = new FSImage(conf);
  final DatanodeStorageInfo[] targets = {};

  FSNamesystem namesystem = new FSNamesystem(conf, image);
  namesystem.setImageLoaded(true);

  // set file's parent as root and put the file to inodeMap, so
  // FSNamesystem's isFileDeleted() method will return false on this file
  if (file.getParent() == null) {
    INodeDirectory mparent = mock(INodeDirectory.class);
    INodeDirectory parent = new INodeDirectory(mparent.getId(), new byte[0],
        mparent.getPermissionStatus(), mparent.getAccessTime());
    parent.setLocalName(new byte[0]);
    parent.addChild(file);
    file.setParent(parent);
  }
  namesystem.dir.getINodeMap().put(file);

  FSNamesystem namesystemSpy = spy(namesystem);
  BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
      block, (short) 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
  blockInfo.setBlockCollection(file);
  blockInfo.setGenerationStamp(genStamp);
  blockInfo.initializeBlockRecovery(genStamp);
  doReturn(true).when(file).removeLastBlock(any(Block.class));
  doReturn(true).when(file).isUnderConstruction();

  doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class));
  doReturn("").when(namesystemSpy).closeFileCommitBlocks(
      any(INodeFile.class), any(BlockInfo.class));
  doReturn(mock(FSEditLog.class)).when(namesystemSpy).getEditLog();

  return namesystemSpy;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:38,代码来源:TestCommitBlockSynchronization.java


示例16: checkNamenodeBeforeReturn

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  INodeFile fileNode = cluster.getNamesystem(0).getFSDirectory()
      .getINode4Write(file).asFile();
  BlockInfoUnderConstruction blkUC = 
      (BlockInfoUnderConstruction) (fileNode.getBlocks())[1];
  int datanodeNum = blkUC.getExpectedStorageLocations().length;
  for (int i = 0; i < CHECKTIMES && datanodeNum != 2; i++) {
    Thread.sleep(1000);
    datanodeNum = blkUC.getExpectedStorageLocations().length;
  }
  return datanodeNum == 2;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:14,代码来源:TestRetryCacheWithHA.java


示例17: testGetBlockLocations

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * Test NameNode.getBlockLocations(..) on reading un-closed files.
 */
@Test
public void testGetBlockLocations() throws IOException {
  final NamenodeProtocols namenode = cluster.getNameNodeRpc();
  final Path p = new Path(BASE_DIR, "file2.dat");
  final String src = p.toString();
  final FSDataOutputStream out = TestFileCreation.createFile(hdfs, p, 3);

  // write a half block
  int len = BLOCK_SIZE >>> 1;
  writeFile(p, out, len);

  for(int i = 1; i < NUM_BLOCKS; ) {
    // verify consistency
    final LocatedBlocks lb = namenode.getBlockLocations(src, 0, len);
    final List<LocatedBlock> blocks = lb.getLocatedBlocks();
    assertEquals(i, blocks.size());
    final Block b = blocks.get(blocks.size() - 1).getBlock().getLocalBlock();
    assertTrue(b instanceof BlockInfoUnderConstruction);

    if (++i < NUM_BLOCKS) {
      // write one more block
      writeFile(p, out, BLOCK_SIZE);
      len += BLOCK_SIZE;
    }
  }
  // close file
  out.close();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:32,代码来源:TestBlockUnderConstruction.java


示例18: setLastBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * Convert the last block of the file to an under-construction block.
 * Set its locations.
 */
@Override
public BlockInfoUnderConstruction setLastBlock(BlockInfo lastBlock,
    DatanodeDescriptor[] targets) throws IOException {
  if (numBlocks() == 0) {
    throw new IOException("Failed to set last block: File is empty.");
  }
  BlockInfoUnderConstruction ucBlock =
    lastBlock.convertToBlockUnderConstruction(
        BlockUCState.UNDER_CONSTRUCTION, targets);
  ucBlock.setBlockCollection(this);
  setBlock(numBlocks()-1, ucBlock);
  return ucBlock;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:18,代码来源:INodeFileUnderConstruction.java


示例19: addBlock

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
/**
 * Add a block to the file. Returns a reference to the added block.
 */
BlockInfo addBlock(String path, INodesInPath inodesInPath, Block block,
    DatanodeDescriptor targets[]) throws IOException {
  waitForReady();

  writeLock();
  try {
    final INodeFileUnderConstruction fileINode = 
        INodeFileUnderConstruction.valueOf(inodesInPath.getLastINode(), path);

    // check quota limits and updated space consumed
    updateCount(inodesInPath, 0, fileINode.getBlockDiskspace(), true);

    // associate new last block for the file
    BlockInfoUnderConstruction blockInfo =
      new BlockInfoUnderConstruction(
          block,
          fileINode.getFileReplication(),
          BlockUCState.UNDER_CONSTRUCTION,
          targets);
    getBlockManager().addBlockCollection(blockInfo, fileINode);
    fileINode.addBlock(blockInfo);

    if(NameNode.stateChangeLog.isDebugEnabled()) {
      NameNode.stateChangeLog.debug("DIR* FSDirectory.addBlock: "
          + path + " with " + block
          + " block is added to the in-memory "
          + "file system");
    }
    return blockInfo;
  } finally {
    writeUnlock();
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:37,代码来源:FSDirectory.java


示例20: makeNameSystemSpy

import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; //导入依赖的package包/类
private FSNamesystem makeNameSystemSpy(Block block, INodeFile file)
    throws IOException {
  Configuration conf = new Configuration();
  FSImage image = new FSImage(conf);
  final DatanodeStorageInfo[] targets = {};

  FSNamesystem namesystem = new FSNamesystem(conf, image);
  namesystem.setImageLoaded(true);

  // set file's parent as root and put the file to inodeMap, so
  // FSNamesystem's isFileDeleted() method will return false on this file
  if (file.getParent() == null) {
    INodeDirectory parent = mock(INodeDirectory.class);
    parent.setLocalName(new byte[0]);
    parent.addChild(file);
    file.setParent(parent);
  }
  namesystem.dir.getINodeMap().put(file);

  FSNamesystem namesystemSpy = spy(namesystem);
  BlockInfoUnderConstruction blockInfo = new BlockInfoUnderConstruction(
      block, 1, HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
  blockInfo.setBlockCollection(file);
  blockInfo.setGenerationStamp(genStamp);
  blockInfo.initializeBlockRecovery(genStamp);
  doReturn(true).when(file).removeLastBlock(any(Block.class));
  doReturn(true).when(file).isUnderConstruction();

  doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class));
  doReturn("").when(namesystemSpy).closeFileCommitBlocks(
      any(INodeFile.class), any(BlockInfo.class));
  doReturn(mock(FSEditLog.class)).when(namesystemSpy).getEditLog();

  return namesystemSpy;
}
 
开发者ID:yncxcw,项目名称:FlexMap,代码行数:36,代码来源:TestCommitBlockSynchronization.java



注:本文中的org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Status类代码示例发布时间:2022-05-23
下一篇:
Java FeatureState类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap