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 ( ) ; }
Helper method that takes a comma delimited list of host specs validates it and converts it to a set of valid coordinators