Search in sources :

Example 1 with CassandraClient

use of com.palantir.atlasdb.keyvalue.cassandra.CassandraClient in project atlasdb by palantir.

the class HostnamesByIpSupplier method get.

@Override
public Map<String, String> get() {
    List<PoolingContainer<CassandraClient>> containers = hosts.get();
    Stopwatch timer = Stopwatch.createStarted();
    for (PoolingContainer<CassandraClient> container : containers) {
        try {
            return container.runWithPooledResource(getHostnamesByIp());
        } catch (Exception | Error e) {
            log.warn("Could not get hostnames by IP from Cassandra", SafeArg.of("poolSize", containers.size()), SafeArg.of("elapsed", timer.elapsed()), e);
        }
        if (timer.elapsed().compareTo(timeout) >= 0) {
            log.warn("Could not find hostnames by IP mapping for pool within timeout", SafeArg.of("poolSize", containers.size()), SafeArg.of("elapsed", timer.elapsed()));
            return ImmutableMap.of();
        }
    }
    log.warn("Could not find hostnames by IP mapping for pool", SafeArg.of("poolSize", containers.size()), SafeArg.of("elapsed", timer.elapsed()));
    return ImmutableMap.of();
}
Also used : PoolingContainer(com.palantir.common.pooling.PoolingContainer) Stopwatch(com.google.common.base.Stopwatch) CassandraClient(com.palantir.atlasdb.keyvalue.cassandra.CassandraClient) FunctionCheckedException(com.palantir.common.base.FunctionCheckedException) NotFoundException(org.apache.cassandra.thrift.NotFoundException)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 CassandraClient (com.palantir.atlasdb.keyvalue.cassandra.CassandraClient)1 FunctionCheckedException (com.palantir.common.base.FunctionCheckedException)1 PoolingContainer (com.palantir.common.pooling.PoolingContainer)1 NotFoundException (org.apache.cassandra.thrift.NotFoundException)1