本文整理汇总了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);
}
}
示例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));
}
}