private static Set<Integer> rangeToSet(String range) {
    Set<Integer> indexSet = new HashSet<>();
    int startIndex;
    int endIndex;
    if (range.contains("-")) {
      startIndex = Integer.parseInt(range.split("-")[0]);
      endIndex = Integer.parseInt(range.split("-")[1]);
    } else if (range.contains(",")) {
      startIndex = Integer.parseInt(range.split(",")[0]);
      endIndex = Integer.parseInt(range.split(",")[1]);
    } else {
      startIndex = endIndex = Integer.parseInt(range);
    }
    for (int i = startIndex; i <= endIndex; i++) {
      indexSet.add(i);
    }
    return indexSet;
  }
Splits a range to its explicit set of values.
<p/>
For example if the range is "1-5", the result will be [1, 2, 3, 4, 5]

@param range the range to split
@return a set of integers representing the original range
ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java