cluster.setStatus(ClusterStatus.PROVISIONING);
cluster.setAutomationEnable(false);
cluster.setAppManager(Constants.IRONFAN);
List<NodeGroupEntity> nodeGroups = new LinkedList<NodeGroupEntity>();
NodeGroupEntity hdfsGroup = new NodeGroupEntity(HDFS_GROUP);
// add hdfs node group
hdfsGroup.setCluster(cluster);
hdfsGroup.setCpuNum(1);
hdfsGroup.setMemorySize(2048);
hdfsGroup.setStorageSize(20);
hdfsGroup.setStorageType(DatastoreType.LOCAL);
hdfsGroup.setDefineInstanceNum(1);
hdfsGroup.setHaFlag("on");
ArrayList<String> roleStr = new ArrayList<String>();
roleStr.add(HadoopRole.HADOOP_DATANODE.toString());
hdfsGroup.setRoles((new Gson()).toJson(roleStr));
// add a hdfs node
List<NodeEntity> nodes = new LinkedList<NodeEntity>();
NodeEntity node0 = new NodeEntity();
node0.setVmName(HDFS_NODE_0);
node0.setNodeGroup(hdfsGroup);
nodes.add(node0);
NodeEntity node1 = new NodeEntity();
node1.setVmName(HDFS_NODE_1);
node1.setNodeGroup(hdfsGroup);
nodes.add(node1);
hdfsGroup.setNodes(nodes);
nodeGroups.add(hdfsGroup);
// add compute node group
NodeGroupEntity computeGroup = new NodeGroupEntity(COMPUTE_GROUP);
computeGroup.setCluster(cluster);
computeGroup.setCpuNum(1);
computeGroup.setMemorySize(2048);
computeGroup.setStorageSize(20);
computeGroup.setStorageType(DatastoreType.SHARED);
computeGroup.setDefineInstanceNum(1);
computeGroup.setHaFlag("on");
roleStr.clear();
roleStr.add(HadoopRole.HADOOP_TASKTRACKER.toString());
computeGroup.setRoles((new Gson()).toJson(roleStr));
Set<NodeGroupAssociation> associations =
new HashSet<NodeGroupAssociation>();
NodeGroupAssociation association = new NodeGroupAssociation();
association.setReferencedGroup(HDFS_GROUP);
association.setAssociationType(GroupAssociationType.STRICT);
association.setNodeGroup(computeGroup);
associations.add(association);
computeGroup.setGroupAssociations(associations);
computeGroup.setNodes(new LinkedList<NodeEntity>());
nodeGroups.add(computeGroup);
cluster.setNodeGroups(nodeGroups);