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
|
void |
addRelocatingTokens(java.util.Collection<Token> tokens,
java.net.InetAddress endpoint)
Add new relocating ranges (tokens moving from their respective endpoints, to another).
|
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, move, and relocate 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) |
java.util.Map<Token,java.net.InetAddress> |
getRelocatingRanges()
Ranges which are migrating to new endpoints.
|
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 |
invalidateCaches() |
boolean |
isLeaving(java.net.InetAddress endpoint) |
boolean |
isMember(java.net.InetAddress endpoint) |
boolean |
isMoving(java.net.InetAddress endpoint) |
boolean |
isRelocating(Token token) |
java.util.Collection<java.net.InetAddress> |
pendingEndpointsFor(Token token,
java.lang.String keyspaceName) |
int |
pendingRangeChanges(java.net.InetAddress source) |
java.lang.String |
printPendingRanges() |
java.lang.String |
printRelocatingRanges() |
void |
register(AbstractReplicationStrategy subscriber) |
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
|
void |
removeFromRelocating(Token token,
java.net.InetAddress endpoint)
Remove pair of token/address from relocating ranges.
|
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 |
unregister(AbstractReplicationStrategy subscriber) |
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.
|
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)
endpointTokens
- public void updateHostId(java.util.UUID hostId, java.net.InetAddress endpoint)
hostId
- 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 addRelocatingTokens(java.util.Collection<Token> tokens, java.net.InetAddress endpoint)
tokens
- tokens being movedendpoint
- destination of movespublic void removeEndpoint(java.net.InetAddress endpoint)
public void removeFromMoving(java.net.InetAddress endpoint)
endpoint
- address of the moving nodepublic void removeFromRelocating(Token token, java.net.InetAddress endpoint)
endpoint
- public 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 boolean isRelocating(Token token)
public TokenMetadata cloneOnlyTokenMap()
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 java.util.Map<Token,java.net.InetAddress> getRelocatingRanges()
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.lang.String printRelocatingRanges()
public void invalidateCaches()
public void register(AbstractReplicationStrategy subscriber)
public void unregister(AbstractReplicationStrategy subscriber)
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()
Copyright © 2013 The Apache Software Foundation