ClusterCreate implements Serializable { public boolean validateNodeGroupPlacementPolicies( List<String> failedMsgList, List<String> warningMsgList) { boolean valid = true; Map<String, NodeGroupCreate> allGroups = new TreeMap<String, NodeGroupCreate>(); if (getNodeGroups() == null) { return valid; } for (NodeGroupCreate nodeGroupCreate : getNodeGroups()) { allGroups.put(nodeGroupCreate.getName(), nodeGroupCreate); } for (NodeGroupCreate ngc : getNodeGroups()) { if (!ngc.validatePlacementPolicies(this, allGroups, failedMsgList, warningMsgList)) { valid = false; } } return valid; } ClusterCreate();  ClusterCreate(ClusterCreate cluster); @JsonProperty("infrastructure_config") Map<String, Map<String, String>> getInfrastructure_config(); void setInfrastructure_config(Map<String, Map<String, String>> infrastructure_config); Map<String, Object> getConfiguration(); void setConfiguration(Map<String, Object> configuration); @RestRequired String getName(); void setName(String name); String getAppManager(); void setAppManager(String appManager); ClusterType getType(); void setType(ClusterType type); void setExternalHDFS(String externalHDFS); String getExternalHDFS(); String getExternalMapReduce(); void setExternalMapReduce(String externalMapReduce); String getExternalNamenode(); void setExternalNamenode(String externalNamenode); String getExternalSecondaryNamenode(); void setExternalSecondaryNamenode(String externalSecondaryNamenode); Set<String> getExternalDatanodes(); void setExternalDatanodes(Set<String> externalDatanodes); String getDistro(); void setDistro(String distro); @RestIgnore String getDistroVendor(); void setDistroVendor(String distroVendor); @RestIgnore String getDistroVersion(); void setDistroVersion(String distroVersion); String getPackagesExistStatus(); void setPackagesExistStatus(String packagesExistStatus); @RestIgnore String getHttpProxy(); void setHttpProxy(String httpProxy); @RestIgnore String getNoProxy(); void setNoProxy(String noProxy); List<String> getRpNames(); void setRpNames(List<String> rpNames); NodeGroupCreate[] getNodeGroups(); void setNodeGroups(NodeGroupCreate[] nodeGroups); List<String> getDsNames(); void setDsNames(List<String> dsNames); @JsonIgnore List<String> getNetworkNames(); Map<NetTrafficType, List<String>> getNetworkConfig(); void setNetworkConfig(Map<NetTrafficType, List<String>> networkConfig); @RestIgnore List<NetworkAdd> getNetworkings(); void setNetworkings(List<NetworkAdd> networkings); @RestIgnore List<VcCluster> getVcClusters(); void setVcClusters(List<VcCluster> vcClusters); String getTemplateName(); void setTemplateName(String templateName); @RestIgnore List<String> getPackageRepos(); void setPackageRepos(List<String> packageRepos); @RestIgnore HadoopDistroMap getDistroMap(); void setDistroMap(HadoopDistroMap distroMap); TopologyType getTopologyPolicy(); void setTopologyPolicy(TopologyType topologyPolicy); @RestIgnore Map<String, String> getHostToRackMap(); void setHostToRackMap(Map<String, String> hostToRackMap); @RestIgnore Set<String> getSharedDatastorePattern(); void setSharedDatastorePattern(Set<String> sharedDatastorePattern); @RestIgnore Set<String> getLocalDatastorePattern(); void setLocalDatastorePattern(Set<String> localDatastorePattern); Boolean isValidateConfig(); void setValidateConfig(Boolean validateConfig); @RestIgnore String getDeployPolicy(); void setDeployPolicy(String deployPolicy); Boolean isSpecFile(); void setSpecFile(Boolean specFile); boolean validateNodeGroupPlacementPolicies(
         List<String> failedMsgList, List<String> warningMsgList); void validateStorageType(List<String> failedMsgList); boolean hasHDFSUrlConfigured(); boolean validateHDFSUrl(); int totalInstances(); NodeGroupCreate getNodeGroup(String name); void validateClusterCreate(List<String> failedMsgList,
         List<String> warningMsgList); boolean supportedWithHdfs2(); void validateCDHVersion(List<String> warningMsgList); void validateNodeGroupNames(); String getPassword(); void setPassword(String password); void verifyClusterNameLength(); ClusterBlueprint toBlueprint(); String getLocalRepoURL(); void setLocalRepoURL(String localRepoURL); String getHostnamePrefix(); void setHostnamePrefix(String hostnamePrefix); String getClusterCloneType(); void setClusterCloneType(String clusterCloneType);  }
@Test public void testValidateNodeGroupPlacementPolicies() { List<String> failedMsgList = new ArrayList<String>(); List<String> warningMsgList = new ArrayList<String>(); ClusterCreate cluster = new ClusterCreate(); assertEquals(true, cluster.validateNodeGroupPlacementPolicies( failedMsgList, warningMsgList)); NodeGroupCreate compute = new NodeGroupCreate(); compute.setName("compute"); compute.setInstanceNum(10); compute.setRoles(Arrays.asList("hadoop_tasktracker")); NodeGroupCreate data = new NodeGroupCreate(); data.setName("data"); compute.setInstanceNum(4); data.setRoles(Arrays.asList("hadoop_datanode")); cluster.setNodeGroups(new NodeGroupCreate[] { compute, data }); cluster.setTopologyPolicy(TopologyType.HVE); assertEquals(true, cluster.validateNodeGroupPlacementPolicies( failedMsgList, warningMsgList)); PlacementPolicy computePlacementPolicy = new PlacementPolicy(); computePlacementPolicy.setInstancePerHost(3); compute.setPlacementPolicies(computePlacementPolicy); PlacementPolicy dataPlacementPolicy = new PlacementPolicy(); dataPlacementPolicy.setInstancePerHost(0); data.setPlacementPolicies(dataPlacementPolicy); 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); dataPlacementPolicy.setInstancePerHost(2); data.setInstanceNum(2); data.setPlacementPolicies(dataPlacementPolicy); cluster.setNodeGroups(new NodeGroupCreate[] { compute, data }); assertEquals(false, cluster.validateNodeGroupPlacementPolicies( failedMsgList, warningMsgList)); assertEquals(1, failedMsgList.size()); }