CL - public class TokenPartitionedTopology<CL> extends java.lang.Object implements Topology<CL>
HostConnectionPools
for a set of hosts in a partitioned ring.
Maintaining the set of pools for all hosts in a token ring
See the setPools(Collection) method for details on how the various data structures are updated from a list of HostConnectionPools
Note that when host connection pools are set on this class, each host associated with the host conneciton pool can serve multiple partitions,
hence this class builds a reverse index from token range -> list < HostConnectionPool> using this update.
Lookup all HostConnectionPools for a given row keyor token
See the getPartition(ByteBuffer) method for details on how the various data structures are consulted for retrieving the comprehensive list of
host connection pools for a row key.
Note that if the token range token is provided directly, then we can directly consult the tokenPartitionMap. But if we receive a row key, then that is converted
to an integer which is then used to do a bin search over the list of all sorted tokens in the token ring.
HostConnectionPoolPartition} for details of token ranges partition based connection pools maintained for each host.| Constructor and Description |
|---|
TokenPartitionedTopology(Partitioner partitioner,
LatencyScoreStrategy strategy) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPool(HostConnectionPool<CL> pool)
Add a pool without knowing its token.
|
TokenHostConnectionPoolPartition<CL> |
getAllPools()
Return a partition that represents all hosts in the ring
|
TokenHostConnectionPoolPartition<CL> |
getPartition(java.nio.ByteBuffer rowkey)
Get the partition best suited to handle a row key
|
TokenHostConnectionPoolPartition<CL> |
getPartition(java.lang.String token)
Return the partition for a specific token
|
int |
getPartitionCount() |
java.util.List<java.lang.String> |
getPartitionNames() |
java.util.Map<java.lang.String,TokenHostConnectionPoolPartition<CL>> |
getPartitions() |
protected TokenHostConnectionPoolPartition<CL> |
makePartition(java.math.BigInteger partition) |
void |
refresh()
Refresh the internal state and apply the latency score strategy
|
void |
removePool(HostConnectionPool<CL> pool)
Remove this pool from all partitions
|
void |
resumePool(HostConnectionPool<CL> pool)
Resume a host that was previously down
|
boolean |
setPools(java.util.Collection<HostConnectionPool<CL>> ring)
Refresh the internal topology structure
|
void |
suspendPool(HostConnectionPool<CL> pool)
Suspend a host that is down
|
java.lang.String |
toString() |
public TokenPartitionedTopology(Partitioner partitioner, LatencyScoreStrategy strategy)
protected TokenHostConnectionPoolPartition<CL> makePartition(java.math.BigInteger partition)
public boolean setPools(java.util.Collection<HostConnectionPool<CL>> ring)
Topologypublic void resumePool(HostConnectionPool<CL> pool)
TopologyresumePool in interface Topology<CL>public void suspendPool(HostConnectionPool<CL> pool)
TopologysuspendPool in interface Topology<CL>public void refresh()
Topologypublic TokenHostConnectionPoolPartition<CL> getPartition(java.lang.String token)
TopologygetPartition in interface Topology<CL>public TokenHostConnectionPoolPartition<CL> getPartition(java.nio.ByteBuffer rowkey)
TopologygetPartition in interface Topology<CL>public TokenHostConnectionPoolPartition<CL> getAllPools()
TopologygetAllPools in interface Topology<CL>public int getPartitionCount()
getPartitionCount in interface Topology<CL>public void removePool(HostConnectionPool<CL> pool)
TopologyremovePool in interface Topology<CL>public void addPool(HostConnectionPool<CL> pool)
Topologypublic java.util.List<java.lang.String> getPartitionNames()
getPartitionNames in interface Topology<CL>public java.util.Map<java.lang.String,TokenHostConnectionPoolPartition<CL>> getPartitions()
getPartitions in interface Topology<CL>public java.lang.String toString()
toString in class java.lang.Object