Search in sources :

Example 1 with Splitter

use of com.google_voltpatches.common.base.Splitter 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)

Example 2 with Splitter

use of com.google_voltpatches.common.base.Splitter in project voltdb by VoltDB.

the class KafkaImportBenchmark method dbconnect.

/**
     * Connect to one or more VoltDB servers.
     *
     * @param servers A comma separated list of servers using the hostname:port
     * syntax (where :port is optional). Assumes 21212 if not specified otherwise.
     * @throws InterruptedException if anything bad happens with the threads.
     */
static void dbconnect(String servers, int ratelimit) throws InterruptedException, Exception {
    final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();
    log.info("Connecting to VoltDB Interface...");
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setMaxTransactionsPerSecond(ratelimit);
    clientConfig.setReconnectOnConnectionLoss(true);
    client = ClientFactory.createClient(clientConfig);
    for (String server : COMMA_SPLITTER.split(servers)) {
        log.info("..." + server);
        client.createConnection(server);
    }
}
Also used : Splitter(com.google_voltpatches.common.base.Splitter) ClientConfig(org.voltdb.client.ClientConfig)

Aggregations

Splitter (com.google_voltpatches.common.base.Splitter)2 ImmutableSortedSet (com.google_voltpatches.common.collect.ImmutableSortedSet)1 ClientConfig (org.voltdb.client.ClientConfig)1