Package com.vmware.bdd.placement.entity

Examples of com.vmware.bdd.placement.entity.BaseNode


//   @Test(groups = { "TestClusteringService" }, dependsOnMethods = { "testCreateDhcpVmNullResult" })
   public void testCreateDhcpVmCreateVmFail() throws Exception {
      List<NetworkAdd> networkAdds = createNetworkAdd();
      List<BaseNode> vNodes = new ArrayList<BaseNode>();
      BaseNode node = new BaseNode("test-master-0");
      // create cluster spec
      ClusterCreate spec = createClusterSpec();
      node.setCluster(spec);
      node.setNodeGroup(spec.getNodeGroup("master"));
      node.setTargetVcCluster("cluster-ws");
      node.setVmMobId("test-vm");
      vNodes.add(node);
      // create vm schema
      VmSchema vmSchema = createVmSchema();
      node.setVmSchema(vmSchema);

      // mock a clusterEntityMgr and node group entity
      ClusterEntity clusterEntity = Mockito.mock(ClusterEntity.class);
      Mockito.when(clusterEntity.getIoShares()).thenReturn(Priority.HIGH);
      IClusterEntityManager entityMgr = Mockito.mock(IClusterEntityManager.class);
View Full Code Here


//   @Test(groups = { "TestClusteringService" }, dependsOnMethods = { "testCreateDhcpVmCreateVmFail" })
   public void testCreateDhcpVmCreateVmPass() throws Exception {
      List<NetworkAdd> networkAdds = createNetworkAdd();
      List<BaseNode> vNodes = new ArrayList<BaseNode>();
      BaseNode node = new BaseNode("test-master-0");
      ClusterCreate spec = createClusterSpec();
      node.setCluster(spec);
      node.setNodeGroup(spec.getNodeGroup("master"));
      node.setTargetVcCluster("cluster-ws");
      vNodes.add(node);
      // create vm schema
      VmSchema vmSchema = createVmSchema();
      node.setVmSchema(vmSchema);

      // mock a clusterEntityMgr and node group entity
      NodeGroupEntity nodeGroup = Mockito.mock(NodeGroupEntity.class);
      ClusterEntity clusterEntity = Mockito.mock(ClusterEntity.class);
      Mockito.when(clusterEntity.getIoShares()).thenReturn(Priority.HIGH);
View Full Code Here

* Test Case for placement exception
*/
public class PlacementExceptionTest {
   @Test
   public void testPLACEMENT_ERROR() {
      BaseNode placement1 = new BaseNode("hbase5-worker-0");
      placement1.setTargetHost("host1");
      BaseNode placement2 = new BaseNode("hbase5-worker-1");
      placement2.setTargetHost("host2");
      List<BaseNode> placedNodes = Arrays.asList(placement2, placement1);

      Map<String, List<String>> filteredHosts = new HashMap<>();
      filteredHosts.put(PlacementUtil.NETWORK_NAMES, Arrays.asList("defaultNetwork", "dhcp"));
      filteredHosts.put(PlacementUtil.NO_NETWORKS_HOSTS, Arrays.asList("hbase5-worker-01", "hbase5-worker-02"));
View Full Code Here

         NodeGroupCreate nodeGroup, int index) {
      String vmName =
            PlacementUtil.getVmName(cluster.getName(), nodeGroup.getName(),
                  index);

      BaseNode node = new BaseNode(vmName, nodeGroup, cluster);

      // initialize disks
      List<DiskSpec> disks = new ArrayList<DiskSpec>();

      DiskSpec systemDisk = new DiskSpec(templateNode.getDisks().get(0));
      /*
       * TRICK: here we count the size of vswp file into the system disk size, as the
       * vswp file will be put together with system disk.
       */
      Integer memCapa = nodeGroup.getMemCapacityMB();
      memCapa = (memCapa == null) ? 0 : memCapa;
      systemDisk.setSize(systemDisk.getSize() + (memCapa + 1023) / 1024);

      systemDisk.setDiskType(DiskType.SYSTEM_DISK);
      systemDisk.setSeparable(false);
      disks.add(systemDisk);
      AllocationType diskAllocType = null;
      if (nodeGroup.getStorage().getAllocType() != null) {
         diskAllocType =
               AllocationType.valueOf(nodeGroup.getStorage().getAllocType());
      } else {
         // THICK as by default
         diskAllocType = AllocationType.THICK;
      }
      // swap disk
      int swapDisk =
            (((int) Math.ceil(nodeGroup.getMemCapacityMB()
                  * nodeGroup.getSwapRatio()) + 1023) / 1024);
      disks.add(new DiskSpec(DiskType.SWAP_DISK.getDiskName(), swapDisk, node
            .getVmName(), false, DiskType.SWAP_DISK,
            DiskScsiControllerType.LSI_CONTROLLER, null, diskAllocType
                  .toString(), null, null, null));

      // data disks
      if (!DatastoreType.TEMPFS.name().equalsIgnoreCase(
            nodeGroup.getStorage().getType())) {
         // no need to add data disk for storage type tempfs
         disks.add(new DiskSpec(DiskType.DATA_DISK.getDiskName(), nodeGroup
               .getStorage().getSizeGB(), node.getVmName(), true,
               DiskType.DATA_DISK, nodeGroup.getStorage().getControllerType(),
               nodeGroup.getStorage().getSplitPolicy(), diskAllocType
                     .toString(), null, null, null));
      }
      node.setDisks(disks);

      // target vm folder
      node.setVmFolder(nodeGroup.getVmFolderPath());

      // target network, hard coded as the only one NIC
      NetworkSchema netSchema = new NetworkSchema();

      ArrayList<Network> networks = new ArrayList<Network>();
      netSchema.networks = networks;

      // TODO: enhance this logic to support nodegroup level networks
      for (NetworkAdd networkAdd : cluster.getNetworkings()) {
         Network network = new Network();
         network.vcNetwork = networkAdd.getPortGroup();
         networks.add(network);
      }

      node.getVmSchema().networkSchema = netSchema;

      // resource schema
      ResourceSchema resourceSchema = new ResourceSchema();
      resourceSchema.numCPUs = node.getCpu();
      // we don't reserve cpu resource
      resourceSchema.cpuReservationMHz = 0;
      resourceSchema.memSize = node.getMem();
      resourceSchema.memReservationSize = 0;
      resourceSchema.name = "Resource Schema";
      resourceSchema.priority = Priority.Normal;

      node.getVmSchema().resourceSchema = resourceSchema;

      return node;
   }
View Full Code Here

            if (i * baseNodeNum >= nodeGroup.getInstanceNum()) {
               baseNodeNum = 0;
            }

            for (int j = 0; j < baseNodeNum; j++) {
               BaseNode newGuy =
                     getBaseNode(cluster, nodeGroup, i * baseNodeNum + j);
               boolean existed = false;

               if (existedNodes != null && existedNodes.size() > 0) {
                  // existedNodes -> Map<NodeName>
                  for (BaseNode node : existedNodes) {
                     if (newGuy.getVmName().equalsIgnoreCase(node.getVmName())) {
                        existed = true;
                        // handle the special data node existence case here
                        if (mixed
                              && newGuy.getNodeGroup().getReferredGroup() == null) {
                           primaryExisted = true;
                           primaryGroup = newGuy.getNodeGroup().getName();
                        }
                        break;
                     }
                  }
               }
View Full Code Here

TOP

Related Classes of com.vmware.bdd.placement.entity.BaseNode

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.