ClusterCreate implements Serializable { public void validateClusterCreate(List<String> failedMsgList, List<String> warningMsgList) { NodeGroupCreate[] nodeGroupCreates = getNodeGroups(); AuAssert.check(nodeGroupCreates != null && nodeGroupCreates.length > 0); if (hasHDFSUrlConfigured() && !validateHDFSUrl()) { failedMsgList.add(new StringBuilder().append("externalHDFS=") .append(getExternalHDFS()).toString()); } validateNodeGroupPlacementPolicies(failedMsgList, warningMsgList); validateStorageType(failedMsgList); validateSwapRatio(nodeGroupCreates, failedMsgList); validateCpuRatio(nodeGroupCreates, failedMsgList); validateMemRatio(nodeGroupCreates, failedMsgList); for (NodeGroupCreate nodeGroupCreate : nodeGroupCreates) { checkInstanceNum(nodeGroupCreate, failedMsgList); checkCPUAndMemory(nodeGroupCreate, failedMsgList, warningMsgList); } if (!warningMsgList.isEmpty() && !warningMsgList.get(0).startsWith("Warning: ")) { warningMsgList.set(0, "Warning: " + warningMsgList.get(0)); } } 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 testValidateClusterCreate() { ClusterCreate cluster = new ClusterCreate(); cluster.setDistroVendor(Constants.DEFAULT_VENDOR); Map<NetTrafficType, List<String>> networkConfig = new HashMap<NetTrafficType, List<String>>(); List<String> mgtnets = new ArrayList<String>(); mgtnets.add("nw1"); networkConfig.put(NetTrafficType.MGT_NETWORK, mgtnets); List<String> hadpnets = new ArrayList<String>(); hadpnets.add("nw2"); networkConfig.put(NetTrafficType.HDFS_NETWORK, hadpnets); cluster.setNetworkConfig(networkConfig); NodeGroupCreate master = new NodeGroupCreate(); master.setName("master"); master.setMemCapacityMB(7501); master.setSwapRatio(-0.5F); master.setInstanceNum(1); master.setRoles(Arrays.asList("hadoop_namenode", "hadoop_resourcemanager")); NodeGroupCreate worker = new NodeGroupCreate(); worker.setName("worker"); worker.setRoles(Arrays.asList("hadoop_datanode", "hadoop_nodemanager")); worker.setMemCapacityMB(3748); worker.setInstanceNum(0); NodeGroupCreate client = new NodeGroupCreate(); client.setName("client"); client.setMemCapacityMB(3748); client.setInstanceNum(0); client.setRoles(Arrays.asList("hadoop_client", "hive_server", "hive")); List<String> failedMsgList = new ArrayList<String>(); List<String> warningMsgList = new ArrayList<String>(); cluster.setNodeGroups(new NodeGroupCreate[] { master, worker, client }); cluster.validateClusterCreate(failedMsgList, warningMsgList); assertEquals(1, failedMsgList.size()); assertEquals("The 'swapRatio' must be greater than or equal to 0 in group master.", failedMsgList.get(0)); assertEquals(1, warningMsgList.size()); assertEquals( "Warning: The size of the virtual machine memory must be evenly divisible by 4. For group master, 7500 replaces 7501 for the memCapacityMB value.", warningMsgList.get(0)); }