Search in sources :

Example 1 with ImmutableSortedSet

use of com.google_voltpatches.common.collect.ImmutableSortedSet in project voltdb by VoltDB.

the class MeshProber method hosts.

/**
     * Helper method that takes a comma delimited list of host specs, validates it,
     * and converts it to a set of valid coordinators
     * @param option a string that contains comma delimited list of host specs
     * @return a set of valid coordinators
     */
public static ImmutableSortedSet<String> hosts(String option) {
    checkArgument(option != null, "option is null");
    if (option.trim().isEmpty()) {
        return ImmutableSortedSet.of(HostAndPort.fromParts("", Constants.DEFAULT_INTERNAL_PORT).toString());
    }
    Splitter commaSplitter = Splitter.on(',').omitEmptyStrings().trimResults();
    ImmutableSortedSet.Builder<String> sbld = ImmutableSortedSet.naturalOrder();
    for (String h : commaSplitter.split(option)) {
        checkArgument(isValidCoordinatorSpec(h), "%s is not a valid host spec", h);
        sbld.add(HostAndPort.fromString(h).withDefaultPort(Constants.DEFAULT_INTERNAL_PORT).toString());
    }
    return sbld.build();
}
Also used : Splitter(com.google_voltpatches.common.base.Splitter) ImmutableSortedSet(com.google_voltpatches.common.collect.ImmutableSortedSet)

Aggregations

Splitter (com.google_voltpatches.common.base.Splitter)1 ImmutableSortedSet (com.google_voltpatches.common.collect.ImmutableSortedSet)1