|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.netflix.astyanax.connectionpool.impl.TokenPartitionedTopology<CL>
CL - public class TokenPartitionedTopology<CL>
Partition hosts by start token. Each token may map to a list of partitions. The class maintains 3 different data structures to represent 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 Summary | |
|---|---|
TokenPartitionedTopology(Partitioner partitioner,
LatencyScoreStrategy strategy)
|
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TokenPartitionedTopology(Partitioner partitioner,
LatencyScoreStrategy strategy)
| Method Detail |
|---|
protected TokenHostConnectionPoolPartition<CL> makePartition(java.math.BigInteger partition)
public boolean setPools(java.util.Collection<HostConnectionPool<CL>> ring)
Topology
setPools in interface Topology<CL>public void resumePool(HostConnectionPool<CL> pool)
Topology
resumePool in interface Topology<CL>public void suspendPool(HostConnectionPool<CL> pool)
Topology
suspendPool in interface Topology<CL>public void refresh()
Topology
refresh in interface Topology<CL>public TokenHostConnectionPoolPartition<CL> getPartition(java.lang.String token)
Topology
getPartition in interface Topology<CL>public TokenHostConnectionPoolPartition<CL> getPartition(java.nio.ByteBuffer rowkey)
Topology
getPartition in interface Topology<CL>public TokenHostConnectionPoolPartition<CL> getAllPools()
Topology
getAllPools in interface Topology<CL>public int getPartitionCount()
getPartitionCount in interface Topology<CL>public void removePool(HostConnectionPool<CL> pool)
Topology
removePool in interface Topology<CL>public void addPool(HostConnectionPool<CL> pool)
Topology
addPool in interface Topology<CL>public 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||