Program: 48604
Project: 48604
Buggy source:
public void validateGroupConfig(ClusterBlueprint blueprint,List<String> failedMsgList,List<String> warningMsgList){
  List<NodeGroupInfo> nodeGroups=blueprint.getNodeGroups();
  boolean namenodeHACheck=false;
  int masterCount=0, jobtrackerCount=0, resourcemanagerCount=0, hbasemasterCount=0, zookeeperCount=0, workerCount=0, numOfJournalNode=0;
  for (  NodeGroupInfo nodeGroup : nodeGroups) {
    List<NodeGroupRole> groupRoles=getNodeGroupRoles(nodeGroup);
    if (groupRoles != null) {
      for (      NodeGroupRole role : groupRoles) {
switch (role) {
case MASTER:
          masterCount++;
        int numOfInstance=nodeGroup.getInstanceNum();
      if (numOfInstance >= 0 && numOfInstance != 1) {
        if (numOfInstance != 2) {
          collectInstanceNumInvalidateMsg(nodeGroup,failedMsgList);
        }
 else {
          namenodeHACheck=true;
        }
      }
    break;
case JOB_TRACKER:
  jobtrackerCount++;
if (nodeGroup.getInstanceNum() >= 0 && nodeGroup.getInstanceNum() != 1) {
  failedMsgList.add(Constants.WRONG_NUM_OF_JOBTRACKER);
}
break;
case RESOURCEMANAGER:
resourcemanagerCount++;
if (nodeGroup.getInstanceNum() >= 0 && nodeGroup.getInstanceNum() != 1) {
failedMsgList.add(Constants.WRONG_NUM_OF_RESOURCEMANAGER);
}
break;
case HBASE_MASTER:
hbasemasterCount++;
if (nodeGroup.getInstanceNum() == 0) {
collectInstanceNumInvalidateMsg(nodeGroup,failedMsgList);
}
break;
case ZOOKEEPER:
zookeeperCount++;
if (nodeGroup.getInstanceNum() > 0 && nodeGroup.getInstanceNum() < 3) {
failedMsgList.add(Constants.WRONG_NUM_OF_ZOOKEEPER);
}
 else if (nodeGroup.getInstanceNum() > 0 && nodeGroup.getInstanceNum() % 2 == 0) {
warningMsgList.add(Constants.ODD_NUM_OF_ZOOKEEPER);
}
break;
case JOURNAL_NODE:
numOfJournalNode+=nodeGroup.getInstanceNum();
if (nodeGroup.getRoles().contains(HadoopRole.HADOOP_DATANODE.toString()) || nodeGroup.getRoles().contains(HadoopRole.HADOOP_CLIENT_ROLE.toString())) {
failedMsgList.add(Constants.DATA_CLIENT_NODE_JOURNALNODE_COEXIST);
}
break;
case WORKER:
workerCount++;
if (nodeGroup.getInstanceNum() == 0) {
collectInstanceNumInvalidateMsg(nodeGroup,failedMsgList);
}
 else if (nodeGroup.isHaEnabled()) {
warningMsgList.add(Constants.WORKER_CLIENT_HA_FLAG);
}
List<String> roles=nodeGroup.getRoles();
if (roles.contains(HadoopRole.HBASE_REGIONSERVER_ROLE.toString()) && !roles.contains(HadoopRole.HADOOP_DATANODE.toString())) {
warningMsgList.add(Constants.REGISONSERVER_DATANODE_SEPERATION);
}
break;
case CLIENT:
if (nodeGroup.isHaEnabled()) {
warningMsgList.add(Constants.WORKER_CLIENT_HA_FLAG);
}
break;
case NONE:
break;
default :
break;
}
}
}
if (!supportedWithHdfs2(blueprint)) {
if (namenodeHACheck || masterCount > 1) {
failedMsgList.add(Constants.CURRENT_DISTRO_CAN_NOT_SUPPORT_HDFS2);
}
}
 else if (namenodeHACheck) {
if (numOfJournalNode >= 0 && numOfJournalNode < 3) {
failedMsgList.add(Constants.WRONG_NUM_OF_JOURNALNODE);
}
 else if (numOfJournalNode > 0 && numOfJournalNode % 2 == 0) {
warningMsgList.add(Constants.ODD_NUM_OF_JOURNALNODE);
}
if (zookeeperCount == 0) {
failedMsgList.add(Constants.NAMENODE_AUTO_FAILOVER_ZOOKEEPER);
}
}
if ((jobtrackerCount > 1) || (resourcemanagerCount > 1) || (zookeeperCount > 1)|| (hbasemasterCount > 1)) {
failedMsgList.add(Constants.WRONG_NUM_OF_NODEGROUPS);
}
if (numOfJournalNode > 0 && !namenodeHACheck) {
failedMsgList.add(Constants.NO_NAMENODE_HA);
}
}
if (!warningMsgList.isEmpty() && !warningMsgList.get(0).startsWith("String_Node_Str")) {
warningMsgList.set(0,"String_Node_Str" + warningMsgList.get(0));
}
}

Fixed version (ground truth):
public void validateGroupConfig(ClusterBlueprint blueprint,List<String> failedMsgList,List<String> warningMsgList){
  List<NodeGroupInfo> nodeGroups=blueprint.getNodeGroups();
  boolean namenodeHACheck=false;
  int masterCount=0, jobtrackerCount=0, resourcemanagerCount=0, hbasemasterCount=0, zookeeperCount=0, workerCount=0, numOfJournalNode=0;
  for (  NodeGroupInfo nodeGroup : nodeGroups) {
    List<NodeGroupRole> groupRoles=getNodeGroupRoles(nodeGroup);
    if (groupRoles != null) {
      for (      NodeGroupRole role : groupRoles) {
switch (role) {
case MASTER:
          masterCount++;
        int numOfInstance=nodeGroup.getInstanceNum();
      if (numOfInstance >= 0 && numOfInstance != 1) {
        if (numOfInstance != 2) {
          collectInstanceNumInvalidateMsg(nodeGroup,failedMsgList);
        }
 else {
          namenodeHACheck=true;
        }
      }
    break;
case JOB_TRACKER:
  jobtrackerCount++;
if (nodeGroup.getInstanceNum() >= 0 && nodeGroup.getInstanceNum() != 1) {
  failedMsgList.add(Constants.WRONG_NUM_OF_JOBTRACKER);
}
break;
case RESOURCEMANAGER:
resourcemanagerCount++;
if (nodeGroup.getInstanceNum() >= 0 && nodeGroup.getInstanceNum() != 1) {
failedMsgList.add(Constants.WRONG_NUM_OF_RESOURCEMANAGER);
}
break;
case HBASE_MASTER:
hbasemasterCount++;
if (nodeGroup.getInstanceNum() == 0) {
collectInstanceNumInvalidateMsg(nodeGroup,failedMsgList);
}
break;
case ZOOKEEPER:
zookeeperCount++;
if (nodeGroup.getInstanceNum() > 0 && nodeGroup.getInstanceNum() < 3) {
failedMsgList.add(Constants.WRONG_NUM_OF_ZOOKEEPER);
}
 else if (nodeGroup.getInstanceNum() > 0 && nodeGroup.getInstanceNum() % 2 == 0) {
warningMsgList.add(Constants.ODD_NUM_OF_ZOOKEEPER);
}
break;
case JOURNAL_NODE:
numOfJournalNode+=nodeGroup.getInstanceNum();
if (nodeGroup.getRoles().contains(HadoopRole.HADOOP_DATANODE.toString()) || nodeGroup.getRoles().contains(HadoopRole.HADOOP_CLIENT_ROLE.toString())) {
failedMsgList.add(Constants.DATA_CLIENT_NODE_JOURNALNODE_COEXIST);
}
break;
case WORKER:
workerCount++;
if (nodeGroup.getInstanceNum() == 0) {
collectInstanceNumInvalidateMsg(nodeGroup,failedMsgList);
}
 else if (nodeGroup.isHaEnabled()) {
warningMsgList.add(Constants.WORKER_CLIENT_HA_FLAG);
}
List<String> roles=nodeGroup.getRoles();
if (roles.contains(HadoopRole.HBASE_REGIONSERVER_ROLE.toString()) && !roles.contains(HadoopRole.HADOOP_DATANODE.toString())) {
warningMsgList.add(Constants.REGISONSERVER_DATANODE_SEPERATION);
}
break;
case CLIENT:
if (nodeGroup.isHaEnabled()) {
warningMsgList.add(Constants.WORKER_CLIENT_HA_FLAG);
}
break;
case NONE:
break;
default :
break;
}
}
}
}
if (!supportedWithHdfs2(blueprint)) {
if (namenodeHACheck || masterCount > 1) {
failedMsgList.add(Constants.CURRENT_DISTRO_CAN_NOT_SUPPORT_HDFS2);
}
}
 else if (namenodeHACheck) {
if (numOfJournalNode >= 0 && numOfJournalNode < 3) {
failedMsgList.add(Constants.WRONG_NUM_OF_JOURNALNODE);
}
 else if (numOfJournalNode > 0 && numOfJournalNode % 2 == 0) {
warningMsgList.add(Constants.ODD_NUM_OF_JOURNALNODE);
}
if (zookeeperCount == 0) {
failedMsgList.add(Constants.NAMENODE_AUTO_FAILOVER_ZOOKEEPER);
}
}
if ((jobtrackerCount > 1) || (resourcemanagerCount > 1) || (zookeeperCount > 1)|| (hbasemasterCount > 1)) {
failedMsgList.add(Constants.WRONG_NUM_OF_NODEGROUPS);
}
if (numOfJournalNode > 0 && !namenodeHACheck) {
failedMsgList.add(Constants.NO_NAMENODE_HA);
}
if (!warningMsgList.isEmpty() && !warningMsgList.get(0).startsWith("String_Node_Str")) {
warningMsgList.set(0,"String_Node_Str" + warningMsgList.get(0));
}
}