private Collection<Token> getTokensFor(InetAddress endpoint) { try { EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint); if (state == null) return Collections.emptyList(); VersionedValue versionedValue = state.getApplicationState(ApplicationState.TOKENS); if (versionedValue == null) return Collections.emptyList(); return TokenSerializer.deserialize(tokenMetadata.partitioner, new DataInputStream(new ByteArrayInputStream(versionedValue.toBytes()))); } catch (IOException e) { throw new RuntimeException(e); } }
private Collection<Token> getTokensFor(InetAddress endpoint) { try { EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint); if (state == null) return Collections.emptyList(); VersionedValue versionedValue = state.getApplicationState(ApplicationState.TOKENS); if (versionedValue == null) return Collections.emptyList(); return TokenSerializer.deserialize(tokenMetadata.partitioner, new DataInputStream(new ByteArrayInputStream(versionedValue.toBytes()))); } catch (IOException e) { throw new RuntimeException(e); } }
private Collection<Token> getTokensFor(InetAddress endpoint) { try { EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint); if (state == null) return Collections.emptyList(); VersionedValue versionedValue = state.getApplicationState(ApplicationState.TOKENS); if (versionedValue == null) return Collections.emptyList(); return TokenSerializer.deserialize(tokenMetadata.partitioner, new DataInputStream(new ByteArrayInputStream(versionedValue.toBytes()))); } catch (IOException e) { throw new RuntimeException(e); } }
private Collection<Token> getTokensFor(InetAddress endpoint) { try { EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint); if (state == null) return Collections.emptyList(); VersionedValue versionedValue = state.getApplicationState(ApplicationState.TOKENS); if (versionedValue == null) return Collections.emptyList(); return TokenSerializer.deserialize(getPartitioner(), new DataInputStream(new ByteArrayInputStream(versionedValue.toBytes()))); } catch (IOException e) { throw new RuntimeException(e); } }
throw new RuntimeException(String.format("Could not find tokens for %s to replace", replaceAddress)); bootstrapTokens = TokenSerializer.deserialize(tokenMetadata.partitioner, new DataInputStream(new ByteArrayInputStream(tokensVersionedValue.toBytes())));
throw new RuntimeException(String.format("Could not find tokens for %s to replace", replaceAddress)); bootstrapTokens = TokenSerializer.deserialize(tokenMetadata.partitioner, new DataInputStream(new ByteArrayInputStream(tokensVersionedValue.toBytes())));
throw new RuntimeException(String.format("Could not find tokens for %s to replace", replaceAddress)); bootstrapTokens = TokenSerializer.deserialize(tokenMetadata.partitioner, new DataInputStream(new ByteArrayInputStream(tokensVersionedValue.toBytes())));
public synchronized Collection<Token> prepareReplacementInfo() throws ConfigurationException { logger.info("Gathering node replacement information for {}", DatabaseDescriptor.getReplaceAddress()); if (!MessagingService.instance().isListening()) MessagingService.instance().listen(FBUtilities.getLocalAddress()); // make magic happen Gossiper.instance.doShadowRound(); UUID hostId = null; // now that we've gossiped at least once, we should be able to find the node we're replacing if (Gossiper.instance.getEndpointStateForEndpoint(DatabaseDescriptor.getReplaceAddress())== null) throw new RuntimeException("Cannot replace_address " + DatabaseDescriptor.getReplaceAddress() + " because it doesn't exist in gossip"); hostId = Gossiper.instance.getHostId(DatabaseDescriptor.getReplaceAddress()); try { VersionedValue tokensVersionedValue = Gossiper.instance.getEndpointStateForEndpoint(DatabaseDescriptor.getReplaceAddress()).getApplicationState(ApplicationState.TOKENS); if (tokensVersionedValue == null) throw new RuntimeException("Could not find tokens for " + DatabaseDescriptor.getReplaceAddress() + " to replace"); Collection<Token> tokens = TokenSerializer.deserialize(getPartitioner(), new DataInputStream(new ByteArrayInputStream(tokensVersionedValue.toBytes()))); SystemKeyspace.setLocalHostId(hostId); // use the replacee's host Id as our own so we receive hints, etc Gossiper.instance.resetEndpointStateMap(); // clean up since we have what we need return tokens; } catch (IOException e) { throw new RuntimeException(e); } }