public class TokenMetadata
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
TokenMetadata.Topology
Tracks the assignment of racks and endpoints in each datacenter for all the "normal" endpoints
in this TokenMetadata.
|
Constructor and Description |
---|
TokenMetadata() |
Modifier and Type | Method and Description |
---|---|
void |
addBootstrapToken(Token token,
java.net.InetAddress endpoint)
Deprecated.
|
void |
addBootstrapTokens(java.util.Collection<Token> tokens,
java.net.InetAddress endpoint) |
void |
addLeavingEndpoint(java.net.InetAddress endpoint) |
void |
addMovingEndpoint(Token token,
java.net.InetAddress endpoint)
Add a new moving endpoint
|
TokenMetadata |
cachedOnlyTokenMap()
Return a cached TokenMetadata with only tokenToEndpointMap, i.e., the same as cloneOnlyTokenMap but
uses a cached copy that is invalided when the ring changes, so in the common case
no extra locking is required.
|
void |
clearUnsafe()
used by tests
|
TokenMetadata |
cloneAfterAllLeft()
Create a copy of TokenMetadata with tokenToEndpointMap reflecting situation after all
current leave operations have finished.
|
TokenMetadata |
cloneAfterAllSettled()
Create a copy of TokenMetadata with tokenToEndpointMap reflecting situation after all
current leave, and move operations have finished.
|
TokenMetadata |
cloneOnlyTokenMap()
Create a copy of TokenMetadata with only tokenToEndpointMap.
|
static Token |
firstToken(java.util.ArrayList<Token> ring,
Token start) |
static int |
firstTokenIndex(java.util.ArrayList ring,
Token start,
boolean insertMin) |
java.util.Set<java.net.InetAddress> |
getAllEndpoints() |
BiMultiValMap<Token,java.net.InetAddress> |
getBootstrapTokens() |
java.net.InetAddress |
getEndpoint(Token token) |
java.net.InetAddress |
getEndpointForHostId(java.util.UUID hostId)
Return the end-point for a unique host ID
|
java.util.Map<java.net.InetAddress,java.util.UUID> |
getEndpointToHostIdMapForReading() |
com.google.common.collect.Multimap<java.net.InetAddress,Token> |
getEndpointToTokenMapForReading() |
java.util.UUID |
getHostId(java.net.InetAddress endpoint)
Return the unique host ID for an end-point.
|
java.util.Set<java.net.InetAddress> |
getLeavingEndpoints()
caller should not modify leavingEndpoints
|
java.util.Set<Pair<Token,java.net.InetAddress>> |
getMovingEndpoints()
Endpoints which are migrating to the new tokens
|
java.util.Map<Token,java.net.InetAddress> |
getNormalAndBootstrappingTokenToEndpointMap() |
java.util.Map<Range<Token>,java.util.Collection<java.net.InetAddress>> |
getPendingRanges(java.lang.String keyspaceName)
a mutable map may be returned but caller should not modify it
|
java.util.List<Range<Token>> |
getPendingRanges(java.lang.String keyspaceName,
java.net.InetAddress endpoint) |
Token |
getPredecessor(Token token) |
Range<Token> |
getPrimaryRangeFor(Token right)
Deprecated.
|
java.util.Collection<Range<Token>> |
getPrimaryRangesFor(java.util.Collection<Token> tokens) |
long |
getRingVersion() |
Token |
getSuccessor(Token token) |
Token |
getToken(java.net.InetAddress endpoint)
Deprecated.
|
java.util.Collection<Token> |
getTokens(java.net.InetAddress endpoint) |
TokenMetadata.Topology |
getTopology() |
java.util.Collection<java.net.InetAddress> |
getWriteEndpoints(Token token,
java.lang.String keyspaceName,
java.util.Collection<java.net.InetAddress> naturalEndpoints)
Deprecated.
retained for benefit of old tests
|
void |
invalidateCachedRings() |
boolean |
isLeaving(java.net.InetAddress endpoint) |
boolean |
isMember(java.net.InetAddress endpoint) |
boolean |
isMoving(java.net.InetAddress endpoint) |
java.util.Collection<java.net.InetAddress> |
pendingEndpointsFor(Token token,
java.lang.String keyspaceName) |
int |
pendingRangeChanges(java.net.InetAddress source) |
java.lang.String |
printPendingRanges() |
void |
removeBootstrapTokens(java.util.Collection<Token> tokens) |
void |
removeEndpoint(java.net.InetAddress endpoint) |
void |
removeFromMoving(java.net.InetAddress endpoint)
Remove pair of token/address from moving endpoints
|
static java.util.Iterator<Token> |
ringIterator(java.util.ArrayList<Token> ring,
Token start,
boolean includeMin)
iterator over the Tokens in the given ring, starting with the token for the node owning start
(which does not have to be a Token in the ring)
|
void |
setPendingRanges(java.lang.String keyspaceName,
com.google.common.collect.Multimap<Range<Token>,java.net.InetAddress> rangeMap) |
java.util.ArrayList<Token> |
sortedTokens() |
java.lang.String |
toString() |
void |
updateHostId(java.util.UUID hostId,
java.net.InetAddress endpoint)
Store an end-point to host ID mapping.
|
void |
updateNormalToken(Token token,
java.net.InetAddress endpoint)
Update token map with a single token/endpoint pair in normal state.
|
void |
updateNormalTokens(java.util.Collection<Token> tokens,
java.net.InetAddress endpoint) |
void |
updateNormalTokens(com.google.common.collect.Multimap<java.net.InetAddress,Token> endpointTokens)
Update token map with a set of token/endpoint pairs in normal state.
|
void |
updateTopology()
This is called when the snitch properties for many endpoints are updated, it will update
the topology mappings of any endpoints whose snitch has changed, see CASSANDRA-10238.
|
void |
updateTopology(java.net.InetAddress endpoint)
This is called when the snitch properties for this endpoint are updated, see CASSANDRA-10238.
|
public int pendingRangeChanges(java.net.InetAddress source)
public void updateNormalToken(Token token, java.net.InetAddress endpoint)
public void updateNormalTokens(java.util.Collection<Token> tokens, java.net.InetAddress endpoint)
public void updateNormalTokens(com.google.common.collect.Multimap<java.net.InetAddress,Token> endpointTokens)
public void updateHostId(java.util.UUID hostId, java.net.InetAddress endpoint)
public java.util.UUID getHostId(java.net.InetAddress endpoint)
public java.net.InetAddress getEndpointForHostId(java.util.UUID hostId)
public java.util.Map<java.net.InetAddress,java.util.UUID> getEndpointToHostIdMapForReading()
@Deprecated public void addBootstrapToken(Token token, java.net.InetAddress endpoint)
public void addBootstrapTokens(java.util.Collection<Token> tokens, java.net.InetAddress endpoint)
public void removeBootstrapTokens(java.util.Collection<Token> tokens)
public void addLeavingEndpoint(java.net.InetAddress endpoint)
public void addMovingEndpoint(Token token, java.net.InetAddress endpoint)
token
- token which is node moving toendpoint
- address of the moving nodepublic void removeEndpoint(java.net.InetAddress endpoint)
public void updateTopology(java.net.InetAddress endpoint)
public void updateTopology()
public void removeFromMoving(java.net.InetAddress endpoint)
endpoint
- address of the moving nodepublic java.util.Collection<Token> getTokens(java.net.InetAddress endpoint)
@Deprecated public Token getToken(java.net.InetAddress endpoint)
public boolean isMember(java.net.InetAddress endpoint)
public boolean isLeaving(java.net.InetAddress endpoint)
public boolean isMoving(java.net.InetAddress endpoint)
public TokenMetadata cloneOnlyTokenMap()
public TokenMetadata cachedOnlyTokenMap()
public TokenMetadata cloneAfterAllLeft()
public TokenMetadata cloneAfterAllSettled()
public java.net.InetAddress getEndpoint(Token token)
public java.util.Collection<Range<Token>> getPrimaryRangesFor(java.util.Collection<Token> tokens)
public java.util.ArrayList<Token> sortedTokens()
public java.util.Map<Range<Token>,java.util.Collection<java.net.InetAddress>> getPendingRanges(java.lang.String keyspaceName)
public java.util.List<Range<Token>> getPendingRanges(java.lang.String keyspaceName, java.net.InetAddress endpoint)
public void setPendingRanges(java.lang.String keyspaceName, com.google.common.collect.Multimap<Range<Token>,java.net.InetAddress> rangeMap)
public BiMultiValMap<Token,java.net.InetAddress> getBootstrapTokens()
public java.util.Set<java.net.InetAddress> getAllEndpoints()
public java.util.Set<java.net.InetAddress> getLeavingEndpoints()
public java.util.Set<Pair<Token,java.net.InetAddress>> getMovingEndpoints()
public static int firstTokenIndex(java.util.ArrayList ring, Token start, boolean insertMin)
public static java.util.Iterator<Token> ringIterator(java.util.ArrayList<Token> ring, Token start, boolean includeMin)
includeMin
- True if the minimum token should be returned in the ring even if it has no owner.public void clearUnsafe()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String printPendingRanges()
public java.util.Collection<java.net.InetAddress> pendingEndpointsFor(Token token, java.lang.String keyspaceName)
public java.util.Collection<java.net.InetAddress> getWriteEndpoints(Token token, java.lang.String keyspaceName, java.util.Collection<java.net.InetAddress> naturalEndpoints)
public com.google.common.collect.Multimap<java.net.InetAddress,Token> getEndpointToTokenMapForReading()
public java.util.Map<Token,java.net.InetAddress> getNormalAndBootstrappingTokenToEndpointMap()
public TokenMetadata.Topology getTopology()
public long getRingVersion()
public void invalidateCachedRings()
Copyright © 2017 The Apache Software Foundation