Class CassandraService
- java.lang.Object
-
- com.palantir.atlasdb.keyvalue.cassandra.pool.CassandraService
-
- All Implemented Interfaces:
AutoCloseable
public class CassandraService extends Object implements AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description CassandraService(com.palantir.atlasdb.util.MetricsManager metricsManager, CassandraKeyValueServiceConfig config, com.palantir.refreshable.Refreshable<CassandraKeyValueServiceRuntimeConfig> runtimeConfig, Blacklist blacklist, CassandraClientPoolMetrics poolMetrics)
-
Method Summary
-
-
-
Constructor Detail
-
CassandraService
public CassandraService(com.palantir.atlasdb.util.MetricsManager metricsManager, CassandraKeyValueServiceConfig config, com.palantir.refreshable.Refreshable<CassandraKeyValueServiceRuntimeConfig> runtimeConfig, Blacklist blacklist, CassandraClientPoolMetrics poolMetrics)
-
-
Method Detail
-
createInitialized
public static CassandraService createInitialized(com.palantir.atlasdb.util.MetricsManager metricsManager, CassandraKeyValueServiceConfig config, com.palantir.refreshable.Refreshable<CassandraKeyValueServiceRuntimeConfig> runtimeConfig, Blacklist blacklist, CassandraClientPoolMetrics poolMetrics)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
refreshTokenRangesAndGetServers
public com.google.common.collect.ImmutableSet<CassandraServer> refreshTokenRangesAndGetServers()
-
getCurrentServerListFromConfig
public com.google.common.collect.ImmutableSet<CassandraServer> getCurrentServerListFromConfig()
It is expected that config provides list of servers that are directly reachable and do not require special IP resolution.
-
getLocalHosts
public Set<CassandraServer> getLocalHosts()
-
getRandomGoodHostForPredicate
public Optional<CassandraClientPoolingContainer> getRandomGoodHostForPredicate(java.util.function.Predicate<CassandraServer> predicate)
-
getRandomGoodHostForPredicate
public Optional<CassandraClientPoolingContainer> getRandomGoodHostForPredicate(java.util.function.Predicate<CassandraServer> predicate, Set<CassandraServer> triedNodes)
-
getAllNonBlacklistedHosts
public List<com.palantir.common.pooling.PoolingContainer<CassandraClient>> getAllNonBlacklistedHosts()
-
getRandomGoodHost
public CassandraClientPoolingContainer getRandomGoodHost()
-
getTokenMap
public com.google.common.collect.RangeMap<LightweightOppToken,com.google.common.collect.ImmutableSet<CassandraServer>> getTokenMap()
-
getPools
public Map<CassandraServer,CassandraClientPoolingContainer> getPools()
-
debugLogStateOfPool
public void debugLogStateOfPool()
-
getRandomCassandraNodeForKey
public CassandraServer getRandomCassandraNodeForKey(byte[] key)
-
addPool
public void addPool(CassandraServer server)
-
returnOrCreatePool
public void returnOrCreatePool(CassandraServer server, Optional<CassandraClientPoolingContainer> container)
-
removePool
public CassandraClientPoolingContainer removePool(CassandraServer removedServerAddress)
Removes the pool from the set of current pools. Note that this shuts down all idle connections, but active ones remain alive until they are returned to the pool, whereby they are destroyed immediately. Threads waiting on the pool will be interrupted.
-
cacheInitialCassandraHosts
public void cacheInitialCassandraHosts()
-
clearInitialCassandraHosts
public void clearInitialCassandraHosts()
-
-