public interface TokenMap
Note that the methods that take a keyspace argument are based on schema metadata, which can be disabled or restricted to a subset of keyspaces; therefore these methods might return empty results for some or all of the keyspaces.
Modifier and Type | Method and Description |
---|---|
String |
format(Token token)
Formats a token into a string representation appropriate for concatenation in a CQL query.
|
String |
getPartitionerName()
The name of the partitioner class in use, as reported by the Cassandra nodes.
|
default Set<Node> |
getReplicas(CqlIdentifier keyspace,
ByteBuffer partitionKey)
Shortcut for
getReplicas(keyspace,
null, partitionKey) . |
Set<Node> |
getReplicas(CqlIdentifier keyspace,
Partitioner partitioner,
ByteBuffer partitionKey)
The replicas for a given partition key in the given keyspace.
|
Set<Node> |
getReplicas(CqlIdentifier keyspace,
Token token)
The replicas for a given token in the given keyspace.
|
default Set<Node> |
getReplicas(CqlIdentifier keyspace,
TokenRange range)
The replicas for a given range in the given keyspace.
|
default Set<Node> |
getReplicas(String keyspaceName,
ByteBuffer partitionKey)
|
default Set<Node> |
getReplicas(String keyspaceName,
Partitioner partitioner,
ByteBuffer partitionKey)
|
default Set<Node> |
getReplicas(String keyspaceName,
Token token)
Shortcut for
getReplicas(CqlIdentifier.fromCql(keyspaceName), token) . |
default Set<Node> |
getReplicas(String keyspaceName,
TokenRange range)
Shortcut for
getReplicas(CqlIdentifier.fromCql(keyspaceName), range) . |
Set<TokenRange> |
getTokenRanges()
The token ranges that define data distribution on the ring.
|
Set<TokenRange> |
getTokenRanges(CqlIdentifier keyspace,
Node replica)
The token ranges that are replicated on the given node, for the given keyspace.
|
Set<TokenRange> |
getTokenRanges(Node node)
The token ranges for which a given node is the primary replica.
|
default Set<TokenRange> |
getTokenRanges(String keyspaceName,
Node replica)
|
default Set<Token> |
getTokens(Node node)
The tokens owned by the given node.
|
default Token |
newToken(ByteBuffer... partitionKey)
Shortcut for
newToken(null, partitionKey) . |
Token |
newToken(Partitioner partitioner,
ByteBuffer... partitionKey)
Builds a token from a partition key.
|
TokenRange |
newTokenRange(Token start,
Token end) |
Token |
parse(String tokenString)
Builds a token from its string representation.
|
@NonNull Token parse(@NonNull String tokenString)
@NonNull String format(@NonNull Token token)
@NonNull Token newToken(@Nullable Partitioner partitioner, @NonNull ByteBuffer... partitionKey)
partitioner
- the partitioner to use or null
for this TokenMap's partitioner.partitionKey
- the partition key components, in their serialized form (which can be
obtained with TypeCodec.encode(Object, ProtocolVersion)
. Neither the individual
components, nor the vararg array itself, can be null
.@NonNull default Token newToken(@NonNull ByteBuffer... partitionKey)
newToken(null, partitionKey)
.@NonNull TokenRange newTokenRange(@NonNull Token start, @NonNull Token end)
@NonNull Set<TokenRange> getTokenRanges()
@NonNull Set<TokenRange> getTokenRanges(Node node)
@NonNull default Set<Token> getTokens(@NonNull Node node)
This is functionally equivalent to getTokenRanges(node).map(r -> r.getEnd())
. Note
that the set is rebuilt every time you call this method.
@NonNull Set<TokenRange> getTokenRanges(@NonNull CqlIdentifier keyspace, @NonNull Node replica)
@NonNull default Set<TokenRange> getTokenRanges(@NonNull String keyspaceName, @NonNull Node replica)
@NonNull Set<Node> getReplicas(@NonNull CqlIdentifier keyspace, @Nullable Partitioner partitioner, @NonNull ByteBuffer partitionKey)
@NonNull default Set<Node> getReplicas(@NonNull CqlIdentifier keyspace, @NonNull ByteBuffer partitionKey)
getReplicas(keyspace,
null, partitionKey)
.@NonNull default Set<Node> getReplicas(@NonNull String keyspaceName, @Nullable Partitioner partitioner, @NonNull ByteBuffer partitionKey)
@NonNull default Set<Node> getReplicas(@NonNull String keyspaceName, @NonNull ByteBuffer partitionKey)
@NonNull Set<Node> getReplicas(@NonNull CqlIdentifier keyspace, @NonNull Token token)
@NonNull default Set<Node> getReplicas(@NonNull String keyspaceName, @NonNull Token token)
getReplicas(CqlIdentifier.fromCql(keyspaceName), token)
.@NonNull default Set<Node> getReplicas(@NonNull CqlIdentifier keyspace, @NonNull TokenRange range)
It is assumed that the input range does not overlap across multiple node ranges. If the
range extends over multiple nodes, it only returns the nodes that are replicas for the last
token of the range. In other words, this method is a shortcut for getReplicas(keyspace,
range.getEnd())
.
@NonNull default Set<Node> getReplicas(@NonNull String keyspaceName, @NonNull TokenRange range)
getReplicas(CqlIdentifier.fromCql(keyspaceName), range)
.@NonNull String getPartitionerName()
Copyright © 2017–2024. All rights reserved.