Package com.vmware.bdd.apitypes.PlacementPolicy

Examples of com.vmware.bdd.apitypes.PlacementPolicy.GroupAssociation


      }
      nodeGroupRead.setInstances(nodeList);

      List<GroupAssociation> associations = new ArrayList<GroupAssociation>();
      for (NodeGroupAssociation relation : groupAssociations) {
         GroupAssociation association = new GroupAssociation();
         association.setReference(relation.getReferencedGroup());
         association.setType(relation.getAssociationType());
         associations.add(association);
      }

      PlacementPolicy policy = new PlacementPolicy();
      policy.setInstancePerHost(instancePerHost);
View Full Code Here


         }
         if (associonEntities != null) {
            List<GroupAssociation> associons =
                  new ArrayList<GroupAssociation>(associonEntities.size());
            for (NodeGroupAssociation ae : associonEntities) {
               GroupAssociation a = new GroupAssociation();
               a.setReference(ae.getReferencedGroup());
               a.setType(ae.getAssociationType());
               associons.add(a);
            }
            policies.setGroupAssociations(associons);
         }
View Full Code Here

      storageCompute.setSizeGB(50);
      ngs[2].setStorage(storageCompute);
      PlacementPolicy policy = new PlacementPolicy();
      policy.setInstancePerHost(2);
      List<GroupAssociation> associates = new ArrayList<GroupAssociation>();
      GroupAssociation associate = new GroupAssociation();
      associate.setReference("data");
      associate.setType(GroupAssociationType.STRICT);
      associates.add(associate);
      policy.setGroupAssociations(associates);
      ngs[2].setPlacementPolicies(policy);

      spec.setNodeGroups(ngs);
View Full Code Here

            instancePerHost = true;
         }

         if (placement != null && placement.getGroupAssociations() != null
               && placement.getGroupAssociations().size() > 0) {
            GroupAssociation association =
                  placement.getGroupAssociations().get(0);
            if (GroupAssociationType.STRICT.equals(association.getType())) {
               strictAssociated = true;
               referToGroup = association.getReference();
            }
         }

         int count = 0;
         Map<String, Integer> usage = hostMapByGroup.get(nodeGroup.getName());
View Full Code Here

   @Test
   public void testGetReferredGroup() {
      NodeGroupCreate compute = new NodeGroupCreate();
      PlacementPolicy computePlacementPolicy = new PlacementPolicy();
      GroupAssociation computeGroupAssociation = new GroupAssociation();
      computeGroupAssociation.setReference("data");
      computePlacementPolicy.setGroupAssociations(Arrays
            .asList(computeGroupAssociation));
      compute.setPlacementPolicies(computePlacementPolicy);
      assertEquals("data", compute.getReferredGroup());
   }
View Full Code Here

   @Test
   public void testIsStrictReferred() {
      NodeGroupCreate compute = new NodeGroupCreate();
      PlacementPolicy computePlacementPolicy = new PlacementPolicy();
      GroupAssociation computeGroupAssociation = new GroupAssociation();
      computeGroupAssociation.setReference("data");
      computePlacementPolicy.setGroupAssociations(Arrays
            .asList(computeGroupAssociation));
      compute.setPlacementPolicies(computePlacementPolicy);
      assertEquals(false, compute.isStrictReferred());
      computeGroupAssociation.setType(GroupAssociationType.STRICT);
      computePlacementPolicy.setGroupAssociations(Arrays
            .asList(computeGroupAssociation));
      compute.setPlacementPolicies(computePlacementPolicy);
      assertEquals(true, compute.isStrictReferred());
   }
View Full Code Here

      cluster.setNodeGroups(new NodeGroupCreate[] { compute, data });
      assertEquals(false, cluster.validateNodeGroupPlacementPolicies(
            failedMsgList, warningMsgList));
      assertEquals(2, failedMsgList.size());
      failedMsgList.clear();
      GroupAssociation groupAssociation = new GroupAssociation();
      groupAssociation.setType(GroupAssociationType.STRICT);
      groupAssociation.setReference("data");
      computePlacementPolicy.setGroupAssociations(Arrays
            .asList(groupAssociation));
      computePlacementPolicy.setInstancePerHost(2);
      compute.setPlacementPolicies(computePlacementPolicy);
      compute.setInstanceNum(4);
View Full Code Here

            + Constants.STORAGE_TYPE_ALLOWED, failedMsgList.get(0));
      failedMsgList.clear();
      computeStorageRead.setType(DatastoreType.TEMPFS.toString());
      compute.setStorage(computeStorageRead);
      PlacementPolicy computePlacementPolicy = new PlacementPolicy();
      GroupAssociation groupAssociation = new GroupAssociation();
      groupAssociation.setType(GroupAssociationType.WEAK);
      computePlacementPolicy.setGroupAssociations(Arrays
            .asList(groupAssociation));
      compute.setPlacementPolicies(computePlacementPolicy);
      cluster.setNodeGroups(new NodeGroupCreate[] { compute, data });
      cluster.validateStorageType(failedMsgList);
View Full Code Here

                           .append(getName())
                           .append(
                                 ".placementPolicies.groupAssociations.size should be 1.")
                           .toString());
            } else {
               GroupAssociation a = policies.getGroupAssociations().get(0);

               if (a.getType() == null) {
                  a.setType(GroupAssociationType.WEAK); // set to default
               }

               if (a.getReference() == null) {
                  valid = false;
                  failedMsgList
                        .add(new StringBuilder()
                              .append(getName())
                              .append(
                                    ".placementPolicies.groupAssociations[0].reference not set.")
                              .toString());
               } else if (a.getReference().equals(getName())) {
                  valid = false;
                  failedMsgList
                        .add(new StringBuilder()
                              .append(getName())
                              .append(
                                    ".placementPolicies.groupAssociations[0] refers to itself.")
                              .toString());
               } else if (!groups.containsKey(a.getReference())) {
                  valid = false;
                  failedMsgList
                        .add(new StringBuilder()
                              .append(getName())
                              .append(
                                    ".placementPolicies.groupAssociations[0] refers to invalid node group ")
                              .append(a.getReference()).append(".").toString());
               } else {
                  /*
                   *  This is normal case, do more checks.
                   *
                   *  If STRICT is specified, the host number of the current node
                   *  group should not be larger than the referenced one.
                   */
                  if (a.getType() == GroupAssociationType.STRICT) {
                     /*
                      * For the referenced node group, we assume the max node number equals to
                      * instance number when instance per host is unspecified. For the reference
                      * node group, we assume the min node number is 1 when instance per host is
                      * unspecified. This rule follows the underlying placement algorithm.
                      */
                     int hostNum = 1;
                     int refHostNum =
                           groups.get(a.getReference()).getInstanceNum();
                     if (calculateHostNum() != null) {
                        hostNum = calculateHostNum();
                     }
                     if (groups.get(a.getReference()).calculateHostNum() != null) {
                        refHostNum =
                              groups.get(a.getReference()).calculateHostNum();
                     }
                     if (hostNum > refHostNum) {
                        valid = false;
                        failedMsgList
                              .add(new StringBuilder()
                                    .append(getName())
                                    .append(
                                          ".placementPolicies.groupAssociations[0] requires "
                                                + "more hosts than the referenced node group ")
                                    .append(a.getReference()).append(".").toString());
                     }
                  }

                  // current implementation only support sum(in/out degree) <= 1
                  PlacementPolicy refPolicies =
                        groups.get(a.getReference()).getPlacementPolicies();
                  if (refPolicies != null
                        && refPolicies.getGroupAssociations() != null
                        && !refPolicies.getGroupAssociations().isEmpty()) {
                     valid = false;
                     failedMsgList
                           .add(new StringBuilder()
                                 .append(getName())
                                 .append(
                                       ".placementPolicies.groupAssociations[0] refers to node group ")
                                 .append(a.getReference())
                                 .append(" which also has reference(s).")
                                 .toString());
                  }
               }
            }
View Full Code Here

TOP

Related Classes of com.vmware.bdd.apitypes.PlacementPolicy.GroupAssociation

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.