当前位置: 首页>>代码示例>>Java>>正文


Java BlockInfo.getNext方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo.getNext方法的典型用法代码示例。如果您正苦于以下问题:Java BlockInfo.getNext方法的具体用法?Java BlockInfo.getNext怎么用?Java BlockInfo.getNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo的用法示例。


在下文中一共展示了BlockInfo.getNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printContents

import org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo; //导入方法依赖的package包/类
private void printContents(BlockInfo head) {
  BlockInfo it = head;
  while (it != null) {
    LOG.info("Block: " + it.toString());
    it = it.getNext(0);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:8,代码来源:TestBlockInfo.java

示例2: testBlockListMoveToHead

import org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo; //导入方法依赖的package包/类
public void testBlockListMoveToHead() throws Exception {
  LOG.info("BlockInfo moveToHead tests...");

  final int MAX_BLOCKS = 10;

  DatanodeDescriptor dd = new DatanodeDescriptor();
  ArrayList<Block> blockList = new ArrayList<Block>(MAX_BLOCKS);
  ArrayList<BlockInfo> blockInfoList = new ArrayList<BlockInfo>();

  BlockInfo head = null;

  LOG.info("Building block list...");
  for (int i = 0; i < MAX_BLOCKS; i++) {
    blockList.add(new Block(i, 0, GenerationStamp.FIRST_VALID_STAMP));
    blockInfoList.add(new BlockInfo(blockList.get(i), 3));
    blockInfoList.get(i).addNode(dd);
    head = blockInfoList.get(i).listInsert(head, dd, -1);

    // index of the datanode should be 0
    assertEquals("Find datanode should be 0", 0, blockInfoList.get(i)
        .findDatanode(dd));
  }

  // list length should be equal to the number of blocks we inserted
  LOG.info("Checking list length...");
  assertEquals("Length should be MEX_BLOCK", MAX_BLOCKS, head.listCount(dd));

  DatanodeIndex ind = new DatanodeIndex();
  ind.headIndex = head.findDatanode(dd);

  LOG.info("Moving each block to the head of the list...");
  for (int i = 0; i < MAX_BLOCKS; i++) {
    ind.currentIndex = blockInfoList.get(i).findDatanode(dd);
    head = dd.listMoveToHead(blockInfoList.get(i), head, ind);
    // the moved element must be at the head of the list
    assertEquals("Block should be at the head of the list now.",
        blockInfoList.get(i), head);
    // list length must not change
    assertEquals("List size should not change", MAX_BLOCKS,
        head.listCount(dd));
  }

  // move head of the list to the head - this should not change the list
  LOG.info("Moving head to the head...");
  BlockInfo temp = head;
  ind.currentIndex = 0;
  ind.headIndex = 0;
  head = dd.listMoveToHead(head, head, ind);
  assertEquals(
      "Moving head to the head of the list shopuld not change the list",
      temp, head);

  // check all elements of the list against the original blockInfoList
  LOG.info("Checking elements of the list...");
  BlockInfo it = head;
  assertNotNull("Head should not be null", head);
  int c = MAX_BLOCKS - 1;
  while (it != null) {
    assertEquals("Expected element is not on the list",
        blockInfoList.get(c--), it);
    it = it.getNext(0);
  }

  ind.headIndex = head.findDatanode(dd);

  LOG.info("Moving random blocks to the head of the list...");
  Random rand = new Random();
  for (int i = 0; i < MAX_BLOCKS; i++) {
    int j = rand.nextInt(MAX_BLOCKS);
    ind.currentIndex = blockInfoList.get(j).findDatanode(dd);
    head = dd.listMoveToHead(blockInfoList.get(j), head, ind);
    // the moved element must be at the head of the list
    assertEquals("Block should be at the head of the list now.",
        blockInfoList.get(j), head);
    // list length must not change
    assertEquals("List size should not change", MAX_BLOCKS,
        head.listCount(dd));
  }

}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:81,代码来源:TestBlockInfo.java


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