Exemplo n.º 1
0
 public Token getSuccessor(Token token) {
   List tokens = sortedTokens();
   int index = Collections.binarySearch(tokens, token);
   assert index >= 0
       : token + " not found in " + StringUtils.join(tokenToEndPointMap.keySet(), ", ");
   return (Token) ((index == (tokens.size() - 1)) ? tokens.get(0) : tokens.get(index + 1));
 }
Exemplo n.º 2
0
 public Set<InetAddress> getAllEndpoints() {
   lock.readLock().lock();
   try {
     return ImmutableSet.copyOf(endpointToHostIdMap.keySet());
   } finally {
     lock.readLock().unlock();
   }
 }
Exemplo n.º 3
0
 /** @return the number of nodes bootstrapping into source's primary range */
 public int pendingRangeChanges(InetAddress source) {
   int n = 0;
   Range sourceRange = getPrimaryRangeFor(getToken(source));
   for (Token token : bootstrapTokens.keySet()) if (sourceRange.contains(token)) n++;
   return n;
 }
Exemplo n.º 4
0
 private List<Token> sortTokens() {
   List<Token> tokens = new ArrayList<Token>(tokenToEndPointMap.keySet());
   Collections.sort(tokens);
   return Collections.unmodifiableList(tokens);
 }