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

Java BlockUCState类代码示例

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

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



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

示例1: setLastBlock

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
@Override // BlockCollection, the file should be under construction
public BlockInfoContiguousUnderConstruction setLastBlock(
    BlockInfoContiguous 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.");
  }
  BlockInfoContiguousUnderConstruction ucBlock =
    lastBlock.convertToBlockUnderConstruction(
        BlockUCState.UNDER_CONSTRUCTION, locations);
  setBlock(numBlocks() - 1, ucBlock);
  return ucBlock;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:INodeFile.java


示例2: isBlockUnderConstruction

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
private boolean isBlockUnderConstruction(BlockInfoContiguous storedBlock,
    BlockUCState ucState, ReplicaState reportedState) {
  switch(reportedState) {
  case FINALIZED:
    switch(ucState) {
    case UNDER_CONSTRUCTION:
    case UNDER_RECOVERY:
      return true;
    default:
      return false;
    }
  case RBW:
  case RWR:
    return (!storedBlock.isComplete());
  case RUR:       // should not be reported                                                                                             
  case TEMPORARY: // should not be reported                                                                                             
  default:
    return false;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:BlockManager.java


示例3: isBlockUnderConstruction

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
private boolean isBlockUnderConstruction(BlockInfo storedBlock,
    BlockUCState ucState, ReplicaState reportedState) {
  switch(reportedState) {
  case FINALIZED:
    switch(ucState) {
    case UNDER_CONSTRUCTION:
    case UNDER_RECOVERY:
      return true;
    default:
      return false;
    }
  case RBW:
  case RWR:
    return (!storedBlock.isComplete());
  case RUR:       // should not be reported                                                                                             
  case TEMPORARY: // should not be reported                                                                                             
  default:
    return false;
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:BlockManager.java


示例4: checkBlocksProperlyReplicated

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Check that the indicated blocks are present and
 * replicated.
 */
public boolean checkBlocksProperlyReplicated(
    String src, BlockInfo[] blocks) {
  for (BlockInfo b: blocks) {
    if (!b.isComplete()) {
      final int numNodes = b.numNodes();
      final int min = getMinStorageNum(b);
      final BlockUCState state = b.getBlockUCState();
      LOG.info("BLOCK* " + b + " is not COMPLETE (ucState = " + state
          + ", replication# = " + numNodes + (numNodes < min ? " < " : " >= ")
          + " minimum = " + min + ") in file " + src);
      return false;
    }
  }
  return true;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:BlockManager.java


示例5: setLastBlock

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的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


示例6: isBlockUnderConstruction

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
private boolean isBlockUnderConstruction(BlockInfo storedBlock, 
    BlockUCState ucState, ReplicaState reportedState) {
  switch(reportedState) {
  case FINALIZED:
    switch(ucState) {
    case UNDER_CONSTRUCTION:
    case UNDER_RECOVERY:
      return true;
    default:
      return false;
    }
  case RBW:
  case RWR:
    return (!storedBlock.isComplete());
  case RUR:       // should not be reported                                                                                             
  case TEMPORARY: // should not be reported                                                                                             
  default:
    return false;
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:21,代码来源:BlockManager.java


示例7: isBlockUnderConstruction

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
private boolean isBlockUnderConstruction(BlockInfo storedBlock,
    BlockUCState ucState, ReplicaState reportedState) {
  switch (reportedState) {
    case FINALIZED:
      switch (ucState) {
        case UNDER_CONSTRUCTION:
        case UNDER_RECOVERY:
          return true;
        default:
          return false;
      }
    case RBW:
    case RWR:
      return (!storedBlock.isComplete());
    case RUR:       // should not be reported
    case TEMPORARY: // should not be reported
    default:
      return false;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:BlockManager.java


示例8: addBlock

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Add a block to the file. Returns a reference to the added block.
 */
BlockInfoContiguous 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.getPreferredBlockSize(),
        fileINode.getBlockReplication(), true);

    // associate new last block for the file
    BlockInfoContiguousUnderConstruction blockInfo =
      new BlockInfoContiguousUnderConstruction(
          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:naver,项目名称:hadoop,代码行数:36,代码来源:FSDirectory.java


示例9: addStoredBlockImmediate

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Faster version of {@link #addStoredBlock},
 * intended for use with initial block report at startup. If not in startup
 * safe mode, will call standard addStoredBlock(). Assumes this method is
 * called "immediately" so there is no need to refresh the storedBlock from
 * blocksMap. Doesn't handle underReplication/overReplication, or worry about
 * pendingReplications or corruptReplicas, because it's in startup safe mode.
 * Doesn't log every block, because there are typically millions of them.
 * 
 * @throws IOException
 */
private void addStoredBlockImmediate(BlockInfoContiguous storedBlock,
    DatanodeStorageInfo storageInfo)
throws IOException {
  assert (storedBlock != null && namesystem.hasWriteLock());
  if (!namesystem.isInStartupSafeMode() 
      || namesystem.isPopulatingReplQueues()) {
    addStoredBlock(storedBlock, storageInfo, null, false);
    return;
  }

  // just add it
  AddBlockResult result = storageInfo.addBlock(storedBlock);

  // Now check for completion of blocks and safe block count
  int numCurrentReplica = countLiveNodes(storedBlock);
  if (storedBlock.getBlockUCState() == BlockUCState.COMMITTED
      && numCurrentReplica >= minReplication) {
    completeBlock(storedBlock.getBlockCollection(), storedBlock, false);
  } else if (storedBlock.isComplete() && result == AddBlockResult.ADDED) {
    // check whether safe replication is reached for the block
    // only complete blocks are counted towards that.
    // In the case that the block just became complete above, completeBlock()
    // handles the safe block count maintenance.
    namesystem.incrementSafeBlockCount(numCurrentReplica);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:BlockManager.java


示例10: BlockInfoContiguousUnderConstruction

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Create a block that is currently being constructed.
 */
public BlockInfoContiguousUnderConstruction(Block blk, short replication, BlockUCState state, DatanodeStorageInfo[] targets) {
  super(blk, replication);
  assert getBlockUCState() != BlockUCState.COMPLETE :
    "BlockInfoUnderConstruction cannot be in COMPLETE state";
  this.blockUCState = state;
  setExpectedLocations(targets);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:BlockInfoContiguousUnderConstruction.java


示例11: commitBlock

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Commit block's length and generation stamp as reported by the client.
 * Set block state to {@link BlockUCState#COMMITTED}.
 * @param block - contains client reported block length and generation 
 * @throws IOException if block ids are inconsistent.
 */
void commitBlock(Block block) throws IOException {
  if(getBlockId() != block.getBlockId())
    throw new IOException("Trying to commit inconsistent block: id = "
        + block.getBlockId() + ", expected id = " + getBlockId());
  blockUCState = BlockUCState.COMMITTED;
  this.set(getBlockId(), block.getNumBytes(), block.getGenerationStamp());
  // Sort out invalid replicas.
  setGenerationStampAndVerifyReplicas(block.getGenerationStamp());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:BlockInfoContiguousUnderConstruction.java


示例12: testAddBlockUC

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Test adding new blocks but without closing the corresponding the file
 */
@Test
public void testAddBlockUC() throws Exception {
  DistributedFileSystem fs = cluster.getFileSystem();
  final Path file1 = new Path("/file1");
  DFSTestUtil.createFile(fs, file1, BLOCKSIZE - 1, REPLICATION, 0L);
  
  FSDataOutputStream out = null;
  try {
    // append files without closing the streams
    out = fs.append(file1);
    String appendContent = "appending-content";
    out.writeBytes(appendContent);
    ((DFSOutputStream) out.getWrappedStream()).hsync(
        EnumSet.of(SyncFlag.UPDATE_LENGTH));
    
    // restart NN
    cluster.restartNameNode(true);
    FSDirectory fsdir = cluster.getNamesystem().getFSDirectory();
    
    INodeFile fileNode = fsdir.getINode4Write(file1.toString()).asFile();
    BlockInfoContiguous[] fileBlocks = fileNode.getBlocks();
    assertEquals(2, fileBlocks.length);
    assertEquals(BLOCKSIZE, fileBlocks[0].getNumBytes());
    assertEquals(BlockUCState.COMPLETE, fileBlocks[0].getBlockUCState());
    assertEquals(appendContent.length() - 1, fileBlocks[1].getNumBytes());
    assertEquals(BlockUCState.UNDER_CONSTRUCTION,
        fileBlocks[1].getBlockUCState());
  } finally {
    if (out != null) {
      out.close();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestAddBlock.java


示例13: convertLastBlockToUC

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
@Override // BlockCollection, the file should be under construction
public void convertLastBlockToUC(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.");
  }
  lastBlock.convertToBlockUnderConstruction(BlockUCState.UNDER_CONSTRUCTION,
      locations);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:12,代码来源:INodeFile.java


示例14: convertToBlockUnderConstruction

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Add/Update the under construction feature.
 */
public void convertToBlockUnderConstruction(BlockUCState s,
    DatanodeStorageInfo[] targets) {
  if (isComplete()) {
    uc = new BlockUnderConstructionFeature(this, s, targets,
        this.isStriped());
  } else {
    // the block is already under construction
    uc.setBlockUCState(s);
    uc.setExpectedLocations(this, targets, this.isStriped());
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:15,代码来源:BlockInfo.java


示例15: completeBlock

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Convert a specified block of the file to a complete block.
 * @throws IOException if the block does not have at least a minimal number
 * of replicas reported from data-nodes.
 */
private void completeBlock(BlockInfo curBlock, boolean force)
    throws IOException {
  if (curBlock.isComplete()) {
    return;
  }

  int numNodes = curBlock.numNodes();
  if (!force && !hasMinStorage(curBlock, numNodes)) {
    throw new IOException("Cannot complete block: "
        + "block does not satisfy minimal replication requirement.");
  }
  if (!force && curBlock.getBlockUCState() != BlockUCState.COMMITTED) {
    throw new IOException(
        "Cannot complete block: block has not been COMMITTED by the client");
  }

  curBlock.convertToCompleteBlock();
  // Since safe-mode only counts complete blocks, and we now have
  // one more complete block, we need to adjust the total up, and
  // also count it as safe, if we have at least the minimum replica
  // count. (We may not have the minimum replica count yet if this is
  // a "forced" completion when a file is getting closed by an
  // OP_CLOSE edit on the standby).
  bmSafeMode.adjustBlockTotals(0, 1);
  final int minStorage = curBlock.isStriped() ?
      ((BlockInfoStriped) curBlock).getRealDataBlockNum() : minReplication;
  bmSafeMode.incrementSafeBlockCount(Math.min(numNodes, minStorage),
      curBlock);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:35,代码来源:BlockManager.java


示例16: addStoredBlockImmediate

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Faster version of {@link #addStoredBlock},
 * intended for use with initial block report at startup. If not in startup
 * safe mode, will call standard addStoredBlock(). Assumes this method is
 * called "immediately" so there is no need to refresh the storedBlock from
 * blocksMap. Doesn't handle underReplication/overReplication, or worry about
 * pendingReplications or corruptReplicas, because it's in startup safe mode.
 * Doesn't log every block, because there are typically millions of them.
 * 
 * @throws IOException
 */
private void addStoredBlockImmediate(BlockInfo storedBlock, Block reported,
    DatanodeStorageInfo storageInfo)
throws IOException {
  assert (storedBlock != null && namesystem.hasWriteLock());
  if (!namesystem.isInStartupSafeMode()
      || isPopulatingReplQueues()) {
    addStoredBlock(storedBlock, reported, storageInfo, null, false);
    return;
  }

  // just add it
  AddBlockResult result = storageInfo.addBlock(storedBlock, reported);

  // Now check for completion of blocks and safe block count
  int numCurrentReplica = countLiveNodes(storedBlock);
  if (storedBlock.getBlockUCState() == BlockUCState.COMMITTED
      && hasMinStorage(storedBlock, numCurrentReplica)) {
    completeBlock(storedBlock, false);
  } else if (storedBlock.isComplete() && result == AddBlockResult.ADDED) {
    // check whether safe replication is reached for the block
    // only complete blocks are counted towards that.
    // In the case that the block just became complete above, completeBlock()
    // handles the safe block count maintenance.
    bmSafeMode.incrementSafeBlockCount(numCurrentReplica, storedBlock);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:38,代码来源:BlockManager.java


示例17: BlockUnderConstructionFeature

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
public BlockUnderConstructionFeature(Block blk,
    BlockUCState state, DatanodeStorageInfo[] targets, boolean isStriped) {
  assert getBlockUCState() != COMPLETE :
      "BlockUnderConstructionFeature cannot be in COMPLETE state";
  this.blockUCState = state;
  setExpectedLocations(blk, targets, isStriped);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:8,代码来源:BlockUnderConstructionFeature.java


示例18: getRealDataBlockNum

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * If the block is committed/completed and its length is less than a full
 * stripe, it returns the the number of actual data blocks.
 * Otherwise it returns the number of data units specified by erasure coding policy.
 */
public short getRealDataBlockNum() {
  if (isComplete() || getBlockUCState() == BlockUCState.COMMITTED) {
    return (short) Math.min(getDataBlockNum(),
        (getNumBytes() - 1) / ecPolicy.getCellSize() + 1);
  } else {
    return getDataBlockNum();
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:14,代码来源:BlockInfoStriped.java


示例19: testAddBlockUC

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的package包/类
/**
 * Test adding new blocks but without closing the corresponding the file
 */
@Test
public void testAddBlockUC() throws Exception {
  DistributedFileSystem fs = cluster.getFileSystem();
  final Path file1 = new Path("/file1");
  DFSTestUtil.createFile(fs, file1, BLOCKSIZE - 1, REPLICATION, 0L);
  
  FSDataOutputStream out = null;
  try {
    // append files without closing the streams
    out = fs.append(file1);
    String appendContent = "appending-content";
    out.writeBytes(appendContent);
    ((DFSOutputStream) out.getWrappedStream()).hsync(
        EnumSet.of(SyncFlag.UPDATE_LENGTH));
    
    // restart NN
    cluster.restartNameNode(true);
    FSDirectory fsdir = cluster.getNamesystem().getFSDirectory();
    
    INodeFile fileNode = fsdir.getINode4Write(file1.toString()).asFile();
    BlockInfo[] fileBlocks = fileNode.getBlocks();
    assertEquals(2, fileBlocks.length);
    assertEquals(BLOCKSIZE, fileBlocks[0].getNumBytes());
    assertEquals(BlockUCState.COMPLETE, fileBlocks[0].getBlockUCState());
    assertEquals(appendContent.length() - 1, fileBlocks[1].getNumBytes());
    assertEquals(BlockUCState.UNDER_CONSTRUCTION,
        fileBlocks[1].getBlockUCState());
  } finally {
    if (out != null) {
      out.close();
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:37,代码来源:TestAddBlock.java


示例20: addBlock

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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