Examples of IpBlockEntity


Examples of com.vmware.bdd.entity.IpBlockEntity

    * pieces and then subtract the original block with all these pieces one by
    * one. Finally the result diff will equals to en empty set.
    */
   @Test(enabled=false)
   private void doSubtractRandomTest(boolean allowOverlap) {
      IpBlockEntity original = new IpBlockEntity(new NetworkEntity("net1", "vmnet1",
            AllocType.IP_POOL, "255.255.255.0", "192.168.1.1", "8.8.8.8", null), 1L,
            BlockType.ASSIGNED, 1L, 1L << 15);

      List<IpBlockEntity> setA = new ArrayList<IpBlockEntity>();
      setA.add(original);
View Full Code Here

Examples of com.vmware.bdd.entity.IpBlockEntity

      List<IpBlock> ipBlocks = new ArrayList<IpBlock>();
      ipBlocks.add(new IpBlock("192.168.1.11", "192.168.1.12"));
      final List<IpBlockEntity> blocks =
            new ArrayList<IpBlockEntity>(ipBlocks.size());
      for (IpBlock ib : ipBlocks) {
         IpBlockEntity blk =
               new IpBlockEntity(network, IpBlockEntity.FREE_BLOCK_OWNER_ID,
                     BlockType.FREE, IpAddressUtil.getAddressAsLong(ib
                           .getBeginIp()), IpAddressUtil.getAddressAsLong(ib
                           .getEndIp()));
         blocks.add(blk);
      }
View Full Code Here

Examples of com.vmware.bdd.entity.IpBlockEntity

      // sort in asc order by (beginIp, type, owner)
      Collections.sort(ipBlocks);

      List<IpBlockEntity> newBlocks = new ArrayList<IpBlockEntity>(ipBlocks.size());
      Iterator<IpBlockEntity> iter = ipBlocks.iterator();
      IpBlockEntity prev = iter.next();

      while (iter.hasNext()) {
         IpBlockEntity curr = iter.next();
         if (prev.canConcatWith(curr)) {
            if (prev.isOverlapedWith(curr)) {
               logger.warn("detected overlapped IP blocks: " + prev + ", " + curr);
               if (!silentWhenOverlap) {
                  throw NetworkException.OVERLAPPED_IP_BLOCKS(prev, curr);
               }
            }

            if ((ignoreOwner || prev.getOwnerId().equals(curr.getOwnerId()))
                  && (ignoreType || prev.getType() == curr.getType())) {
               prev.setEndIp(Math.max(curr.getEndIp(), prev.getEndIp()));

               /**
                * If curr is an persistent entity, delete it
                */
               if (curr.getId() != null) {
                  if (inHibernateSession) {
                     /**
                      * The input blocks must be Hibernate-aware entities.
                      */
                     delete(curr);
View Full Code Here

Examples of com.vmware.bdd.entity.IpBlockEntity

      Collections.sort(freeBlocks);

      Iterator<IpBlockEntity> iter = freeBlocks.iterator();

      while (count > 0) {
         IpBlockEntity curr = iter.next();
         if (count >= curr.getLength()) {
            // change ownership and record the new assigned block
            curr.setOwnerId(clusterId);
            curr.setType(BlockType.ASSIGNED);
            newAssigned.add(curr);

            count -= curr.getLength();
         } else {
            // record the new assigned block
            newAssigned.add(new IpBlockEntity(entity, clusterId, BlockType.ASSIGNED,
                  curr.getBeginIp(), curr.getBeginIp() + count - 1));

            // add the remaining partial block
            curr.setBeginIp(curr.getBeginIp() + count);
            allBlocks.add(curr);

            count = 0;
         }
      }
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.