Examples of BlockIterator


Examples of org.apache.hadoop.hdfs.server.namenode.UnderReplicatedBlocks.BlockIterator

        // print a limited # of corrupt files per call
        int count = 0;
        ArrayList<CorruptFileBlockInfo> corruptFiles =
          new ArrayList<CorruptFileBlockInfo>();

        BlockIterator blkIterator = null;
        if (decommissioningOnly) {
          blkIterator = neededReplications.iterator(0);
        } else {
          blkIterator = getCorruptReplicaBlockIterator();
        }
       
        if (cookieTab == null) {
          cookieTab = new String[] { null };
        }
        int skip = getIntCookie(cookieTab[0]);
        for(int i = 0; i < skip && blkIterator.hasNext(); i++) {
          blkIterator.next();
        }
       
        while (blkIterator.hasNext()) {
          Block blk = blkIterator.next();
          INode inode = blocksMap.getINode(blk);
          skip++;
          if (inode != null) {
            String src = FSDirectory.getFullPathName(inode);
            if (src.startsWith(path)) {
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.UnderReplicatedBlocks.BlockIterator

          return blocksToReplicate;
        }

        for (int priority = 0; priority<UnderReplicatedBlocks.LEVEL; priority++) {
        // Go through all blocks that need replications of priority
        BlockIterator neededReplicationsIterator = neededReplications.iterator(priority);
        int numBlocks = neededReplications.size(priority);
        if (replIndex[priority] > numBlocks) {
          replIndex[priority] = 0;
        }
        // skip to the first unprocessed block, which is at replIndex
        for (int i = 0; i < replIndex[priority] && neededReplicationsIterator.hasNext(); i++) {
          neededReplicationsIterator.next();
        }
        // # of blocks to process for this priority
        int blocksToProcessIter = getQuotaForThisPriority(blocksToProcess,
            numBlocks, neededReplications.getSize(priority+1));
        blocksToProcess -= blocksToProcessIter;

        for (int blkCnt = 0; blkCnt < blocksToProcessIter; blkCnt++, replIndex[priority]++) {
          if (!neededReplicationsIterator.hasNext()) {
            // start from the beginning
            replIndex[priority] = 0;
            neededReplicationsIterator = neededReplications.iterator(priority);
            assert neededReplicationsIterator.hasNext() :
              "neededReplications should not be empty.";
          }

          BlockInfo block = neededReplicationsIterator.next();
          blocksToReplicate.get(priority).add(block);
        } // end for
        }
      } // end try
      return blocksToReplicate;
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.UnderReplicatedBlocks.BlockIterator

        // print a limited # of corrupt files per call
        int count = 0;
        ArrayList<CorruptFileBlockInfo> corruptFiles =
          new ArrayList<CorruptFileBlockInfo>();

        BlockIterator blkIterator = null;
        if (decommissioningOnly) {
          blkIterator = neededReplications.iterator(0);
        } else {
          blkIterator = getCorruptReplicaBlockIterator();
        }
       
        if (cookieTab == null) {
          cookieTab = new String[] { null };
        }
        int skip = getIntCookie(cookieTab[0]);
        for(int i = 0; i < skip && blkIterator.hasNext(); i++) {
          blkIterator.next();
        }
       
        while (blkIterator.hasNext()) {
          Block blk = blkIterator.next();
          INode inode = blocksMap.getINode(blk);
          skip++;
          if (inode != null) {
            try {
              String src = FSDirectory.getFullPathName(inode);
View Full Code Here

Examples of org.bukkit.util.BlockIterator

        if (Double.isNaN(projectile.getLocation().getDirection().normalize().getX()))
            return; // I can't explain this one either. It also chooses to happen whenever it pleases.

        Block block = null;
        try {
            BlockIterator bi = new BlockIterator(projectile.getLocation().getWorld(),
                    projectile.getLocation().toVector(), projectile.getLocation().getDirection().normalize(), 0, 4);
            while(bi.hasNext()) {
                block = bi.next();
                if(block.getTypeId() != 0) {
                    break;
                }
            }
        }
View Full Code Here

Examples of org.bukkit.util.BlockIterator

                    }
                }
            }

            // Find the valid target
            BlockIterator bi;
            try {
                bi = new BlockIterator(getPlayerEntity(), range);
            }
            catch (IllegalStateException e) {
                return null;
            }
            Block b;
            Location l;
            int bx, by, bz;
            double ex, ey, ez;

            // Loop through player's line of sight
            while (bi.hasNext()) {
                b = bi.next();
                bx = b.getX();
                by = b.getY();
                bz = b.getZ();

                if (b.getType() != Material.AIR) {
View Full Code Here

Examples of org.bukkit.util.BlockIterator

            return null;

        Block block;
        Block previousBlock = null;

        Iterator<Block> itr = new BlockIterator(me, 200);
        while (itr.hasNext())
        {
            block = itr.next();
            if (block.getType() != Material.AIR && block.getType() != Material.LONG_GRASS)
            {
                return previousBlock;
            }
            previousBlock = block;
View Full Code Here

Examples of org.bukkit.util.BlockIterator

        if (maxDistance > 120) {
            maxDistance = 120;
        }

        LinkedList<Block> blocks = new LinkedList<>();
        Iterator<Block> itr = new BlockIterator(this, maxDistance);
        while (itr.hasNext()) {
            Block block = itr.next();
            blocks.add(block);
            if (maxLength != 0 && blocks.size() > maxLength) {
                blocks.removeFirst();
            }
            int id = block.getTypeId();
View Full Code Here

Examples of org.bukkit.util.BlockIterator

        setMaxStackSize(16);
    }

    @Override
    public void rightClickAir(GlowPlayer player, ItemStack holding) {
        Iterator<Block> itr = new BlockIterator(player, 5);
        Block target = null;
        // Used to determine the side the block was clicked on:
        Block previousTarget = null;
        BlockType targetBlockType = null;
        boolean validTarget = false;

        // Find the next available non-air liquid block type which is collectible in a radius of 5 blocks
        while (itr.hasNext()) {
            previousTarget = target;
            target = itr.next();
            targetBlockType = ItemTable.instance().getBlock(target.getType());
            if (targetBlockType != null && targetBlockType instanceof BlockLiquid) {
                if (((BlockLiquid) targetBlockType).isCollectible((GlowBlockState) target.getState())) {
                    validTarget = true;
                    break;
View Full Code Here

Examples of org.bukkit.util.BlockIterator

   * @param end
   * @throws IllegalStateException randomly (Bukkit bug)
   */
  @SuppressWarnings("null")
  public BlockLineIterator(final Block start, final Block end) throws IllegalStateException {
    super(new BlockIterator(start.getWorld(), fitInWorld(start.getLocation().add(0.5, 0.5, 0.5), end.getLocation().subtract(start.getLocation()).toVector()),
        end.equals(start) ? new Vector(1, 0, 0) : end.getLocation().subtract(start.getLocation()).toVector(), 0, 0), // should prevent an error if start = end
    new NullableChecker<Block>() {
      private final double overshotSq = Math.pow(start.getLocation().distance(end.getLocation()) + 2, 2);
     
      @Override
View Full Code Here

Examples of org.bukkit.util.BlockIterator

   * @param dir
   * @param dist
   * @throws IllegalStateException randomly (Bukkit bug)
   */
  public BlockLineIterator(final Location start, final Vector dir, final double dist) throws IllegalStateException {
    super(new BlockIterator(start.getWorld(), fitInWorld(start, dir), dir, 0, 0), new NullableChecker<Block>() {
      private final double distSq = dist * dist;
     
      @Override
      public boolean check(final @Nullable Block b) {
        return b != null && b.getLocation().add(0.5, 0.5, 0.5).distanceSquared(start) >= distSq;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.