Package org.apache.hadoop.raid.PlacementMonitor

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


      names[i] = d.getName();
    }
   
    BlockLocation loc = new BlockLocation(
        names, hosts, b.getStartOffset(), b.getBlockSize());
    return new BlockInfo(loc, file);
  }
View Full Code Here

      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(srcStat, 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(parityStat, lb);
        parityInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
      }
      placementMonitor.checkBlockLocations(
View Full Code Here

        DatanodeInfo d = sourceLocations[i];
        DatanodeInfo d1 = sourceLocations[i+1];
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId, 0, 0L), new DatanodeInfo[]{d, d1}, 0L,
            0, 0, 0);
        BlockInfo info = createBlockInfo(srcStat, lb);
        srcBlockList.add(lb);
        srcInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
        resolver.addNode(d1.getName(), d1);
       
        List<DatanodeInfo> dnList = new ArrayList<DatanodeInfo>();
        dnList.add(d);
        dnList.add(d1);
        blockLocations.put(String.valueOf(blockId), dnList);
        ++ blockId;
      }
      List<LocatedBlock> parityBlockList = new LinkedList<LocatedBlock>();
      List<BlockInfo> parityInfoList = new LinkedList<BlockInfo>();
      for (int i = 0; i < parityLocations.length; i+=2) {
        DatanodeInfo d = parityLocations[i];
        DatanodeInfo d1 = parityLocations[i+1];
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId, 0, 0L), new DatanodeInfo[]{d, d1}, 0L,
            0, 0, 0);
        parityBlockList.add(lb);
        BlockInfo info = createBlockInfo(parityStat, lb);
        parityInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
        resolver.addNode(d1.getName(), d1);
        List<DatanodeInfo> dnList = new ArrayList<DatanodeInfo>();
        dnList.add(d);
        dnList.add(d1);
        blockLocations.put(String.valueOf(blockId), dnList);
        ++ blockId;
      }
      fakeBlockMover.setBlockLocations(blockLocations);
      placementMonitor.checkBlockLocations(
          srcInfoList, parityInfoList, Codec.getCodec("xor"), xorPolicy,
          srcStat, resolver);
      for (BlockMover.BlockMoveAction action :
        fakeBlockMover.getSubmittedActions()) {
        LOG.info("Block move:" + action);
      }
      Set<Block> movedBlocks = new HashSet<Block>();
      for (BlockMover.BlockMoveAction action :
          fakeBlockMover.getSubmittedActions()) {
        movedBlocks.add(action.block.getBlock());
      }
      Map<Integer, Long> hist =
          placementMonitor.blockHistograms.get("xor");
      Assert.assertEquals(3, hist.size());
      Assert.assertEquals(3, hist.get(0).longValue());
      Assert.assertEquals(2, hist.get(1).longValue());
      Assert.assertEquals(3, hist.get(2).longValue());
     
      // since each node is on different rack, the rack histogram should
      // be the same the one for nodes.
      Map<Integer, Long> histRack =
          placementMonitor.blockHistogramsPerRack.get("xor");
      Assert.assertEquals(3, histRack.size());
      Assert.assertEquals(3, histRack.get(0).longValue());
      Assert.assertEquals(2, histRack.get(1).longValue());
      Assert.assertEquals(3, histRack.get(2).longValue());
     

      // Note that the first block will stay.
      Assert.assertEquals(8, fakeBlockMover.getSubmittedActions().size());
      Assert.assertEquals(6, movedBlocks.size());
      Assert.assertTrue(movedBlocks.contains(new Block(1L, 0, 0L)));
      Assert.assertTrue(movedBlocks.contains(new Block(2L, 0, 0L)));
      Assert.assertTrue(movedBlocks.contains(new Block(4L, 0, 0L)));
      Assert.assertTrue(movedBlocks.contains(new Block(5L, 0, 0L)));
      Assert.assertTrue(movedBlocks.contains(new Block(6L, 0, 0L)));
      Assert.assertTrue(movedBlocks.contains(new Block(7L, 0, 0L)));
     
      fakeBlockMover.clearActions();
      resolver = new FakeBlockAndDatanodeResolver();
      // rebuild the block infos
      srcInfoList = new LinkedList<BlockInfo>();
      for (LocatedBlock srcBlock : srcBlockList) {
        List<DatanodeInfo> replicaNodes = blockLocations.get(
            String.valueOf(srcBlock.getBlock().getBlockId()));
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(srcBlock.getBlock().getBlockId(), 0, 0L),
            replicaNodes.toArray(new DatanodeInfo[]{}),
            0L, 0, 0, 0);
       
        BlockInfo info = createBlockInfo(srcStat, lb);
        srcInfoList.add(info);
        resolver.addBlock(info, lb);
        for (DatanodeInfo d : replicaNodes) {
          resolver.addNode(d.getName(), d);
        }
      }
     
      parityInfoList = new LinkedList<BlockInfo>();
      for (LocatedBlock parityBlock : parityBlockList) {
        List<DatanodeInfo> replicaNodes = blockLocations.get(
            String.valueOf(parityBlock.getBlock().getBlockId()));
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(parityBlock.getBlock().getBlockId(), 0, 0L),
            replicaNodes.toArray(new DatanodeInfo[]{}),
            0L, 0, 0, 0);
       
        BlockInfo info = createBlockInfo(srcStat, lb);
        parityInfoList.add(info);
        resolver.addBlock(info, lb);
        for (DatanodeInfo d : replicaNodes) {
          resolver.addNode(d.getName(), d);
        }
View Full Code Here

        DatanodeInfo d = sourceLocations[i];
        DatanodeInfo d1 = sourceLocations[i+1];
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId++, 0, 0L), new DatanodeInfo[]{d, d1}, 0L,
            0, 0, 0);
        BlockInfo info = createBlockInfo(srcStat, lb);
        srcBlockList.add(lb);
        srcInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
        resolver.addNode(d1.getName(), d1);
      }
      List<LocatedBlock> parityBlockList = new LinkedList<LocatedBlock>();
      List<BlockInfo> parityInfoList = new LinkedList<BlockInfo>();
      for (int i = 0; i < parityLocations.length; i+=2) {
        DatanodeInfo d = parityLocations[i];
        DatanodeInfo d1 = parityLocations[i+1];
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId++, 0, 0L), new DatanodeInfo[]{d, d1}, 0L,
            0, 0, 0);
        parityBlockList.add(lb);
        BlockInfo info = createBlockInfo(parityStat, lb);
        parityInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
        resolver.addNode(d1.getName(), d1);
      }
View Full Code Here

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

      for (int i = 0; i < srcLocations.length; i+=3) {
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId++, 0, 0L),
            new DatanodeInfo[] {srcLocations[i], srcLocations[i+1], srcLocations[i+2]},
            0L, 0, 0, 0);
        BlockInfo info = createBlockInfo(srcStat, lb);
        srcBlockList.add(lb);
        srcInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(srcLocations[i].getName(), srcLocations[i]);
        resolver.addNode(srcLocations[i+1].getName(), srcLocations[i+1]);
View Full Code Here

      for (int i = 0; i < srcLocations.length; i+=3) {
        LocatedBlockWithMetaInfo lb = new LocatedBlockWithMetaInfo(
            new Block(blockId++, 0, 0L),
            new DatanodeInfo[] {srcLocations[i], srcLocations[i+1], srcLocations[i+2]},
            0L, 0, 0, 0);
        BlockInfo info = createBlockInfo(srcStat, lb);
        srcBlockList.add(lb);
        srcInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(srcLocations[i].getName(), srcLocations[i]);
        resolver.addNode(srcLocations[i+1].getName(), srcLocations[i+1]);
View Full Code Here

      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(srcStat, 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(parityStat, lb);
        parityInfoList.add(info);
        resolver.addBlock(info, lb);
        resolver.addNode(d.getName(), d);
      }
      placementMonitor.checkBlockLocations(
View Full Code Here

      names[i] = d.getName();
    }
   
    BlockLocation loc = new BlockLocation(
        names, hosts, b.getStartOffset(), b.getBlockSize());
    return new BlockInfo(loc, stat);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.raid.PlacementMonitor.BlockInfo

Copyright © 2018 www.massapicom. 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.