@VisibleForTesting public IPartitioner setPartitionerUnsafe(IPartitioner newPartitioner) { IPartitioner oldPartitioner = DatabaseDescriptor.setPartitionerUnsafe(newPartitioner); tokenMetadata = tokenMetadata.cloneWithNewPartitioner(newPartitioner); valueFactory = new VersionedValue.VersionedValueFactory(newPartitioner); return oldPartitioner; }
private void addLocalApplicationStateInternal(ApplicationState state, VersionedValue value) { assert taskLock.isHeldByCurrentThread(); EndpointState epState = endpointStateMap.get(FBUtilities.getBroadcastAddress()); InetAddress epAddr = FBUtilities.getBroadcastAddress(); assert epState != null; // Fire "before change" notifications: doBeforeChangeNotifications(epAddr, epState, state, value); // Notifications may have taken some time, so preventively raise the version // of the new value, otherwise it could be ignored by the remote node // if another value with a newer version was received in the meantime: value = StorageService.instance.valueFactory.cloneWithHigherVersion(value); // Add to local application state and fire "on change" notifications: epState.addApplicationState(state, value); doOnChangeNotifications(epAddr, state, value); }
states.add(Pair.create(ApplicationState.TOKENS, valueFactory.tokens(tokens))); states.add(Pair.create(ApplicationState.STATUS, replacing? valueFactory.bootReplacing(DatabaseDescriptor.getReplaceAddress()) : valueFactory.bootstrapping(tokens))); Gossiper.instance.addLocalApplicationStates(states); setMode(Mode.JOINING, "sleeping " + RING_DELAY + " ms for pending range setup", true);
appStates.put(ApplicationState.TOKENS, valueFactory.tokens(bootstrapTokens)); "repair must be run after the replacement process in order to make this node consistent.", DatabaseDescriptor.getReplaceAddress()); appStates.put(ApplicationState.STATUS, valueFactory.hibernate(true)); appStates.put(ApplicationState.NET_VERSION, valueFactory.networkVersion()); appStates.put(ApplicationState.HOST_ID, valueFactory.hostId(localHostId)); appStates.put(ApplicationState.RPC_ADDRESS, valueFactory.rpcaddress(FBUtilities.getBroadcastRpcAddress())); appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
appStates.put(ApplicationState.TOKENS, valueFactory.tokens(bootstrapTokens)); "repair must be run after the replacement process in order to make this node consistent.", DatabaseDescriptor.getReplaceAddress()); appStates.put(ApplicationState.STATUS, valueFactory.hibernate(true)); appStates.put(ApplicationState.NET_VERSION, valueFactory.networkVersion()); appStates.put(ApplicationState.HOST_ID, valueFactory.hostId(localHostId)); appStates.put(ApplicationState.RPC_ADDRESS, valueFactory.rpcaddress(FBUtilities.getBroadcastRpcAddress())); appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
states.add(Pair.create(ApplicationState.TOKENS, valueFactory.tokens(tokens))); states.add(Pair.create(ApplicationState.STATUS, replacing? valueFactory.bootReplacing(DatabaseDescriptor.getReplaceAddress()) : valueFactory.bootstrapping(tokens))); Gossiper.instance.addLocalApplicationStates(states); setMode(Mode.JOINING, "sleeping " + RING_DELAY + " ms for pending range setup", true);
appStates.put(ApplicationState.TOKENS, valueFactory.tokens(bootstrapTokens)); "repair must be run after the replacement process in order to make this node consistent.", DatabaseDescriptor.getReplaceAddress()); appStates.put(ApplicationState.STATUS, valueFactory.hibernate(true)); appStates.put(ApplicationState.NET_VERSION, valueFactory.networkVersion()); appStates.put(ApplicationState.HOST_ID, valueFactory.hostId(localHostId)); appStates.put(ApplicationState.RPC_ADDRESS, valueFactory.rpcaddress(FBUtilities.getBroadcastRpcAddress())); appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
states.add(Pair.create(ApplicationState.TOKENS, valueFactory.tokens(tokens))); states.add(Pair.create(ApplicationState.STATUS, replacing? valueFactory.bootReplacing(DatabaseDescriptor.getReplaceAddress()) : valueFactory.bootstrapping(tokens))); Gossiper.instance.addLocalApplicationStates(states); setMode(Mode.JOINING, "sleeping " + RING_DELAY + " ms for pending range setup", true);
epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(tokens, computeExpireTime())); handleMajorStateChange(endpoint, epState); Uninterruptibles.sleepUninterruptibly(intervalInMillis * 4, TimeUnit.MILLISECONDS);
epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(tokens, computeExpireTime())); handleMajorStateChange(endpoint, epState); Uninterruptibles.sleepUninterruptibly(intervalInMillis * 4, TimeUnit.MILLISECONDS);
epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(tokens, computeExpireTime())); handleMajorStateChange(endpoint, epState); Uninterruptibles.sleepUninterruptibly(intervalInMillis * 4, TimeUnit.MILLISECONDS);
epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(tokens, computeExpireTime())); handleMajorStateChange(endpoint, epState); Uninterruptibles.sleepUninterruptibly(intervalInMillis * 4, TimeUnit.MILLISECONDS);
throw new RuntimeException("Trying to replace_address with auto_bootstrap disabled will not work, check your configuration"); bootstrapTokens = prepareReplacementInfo(); appStates.put(ApplicationState.TOKENS, valueFactory.tokens(bootstrapTokens)); appStates.put(ApplicationState.STATUS, valueFactory.hibernate(true)); appStates.put(ApplicationState.NET_VERSION, valueFactory.networkVersion()); appStates.put(ApplicationState.HOST_ID, valueFactory.hostId(localHostId)); appStates.put(ApplicationState.RPC_ADDRESS, valueFactory.rpcaddress(DatabaseDescriptor.getBroadcastRpcAddress())); appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion()); logger.info("Starting up server gossip"); Gossiper.instance.register(this);
private void bootstrap(Collection<Token> tokens) { isBootstrapMode = true; SystemKeyspace.updateTokens(tokens); // DON'T use setToken, that makes us part of the ring locally which is incorrect until we are done bootstrapping if (!DatabaseDescriptor.isReplacing()) { // if not an existing token then bootstrap List<Pair<ApplicationState, VersionedValue>> states = new ArrayList<Pair<ApplicationState, VersionedValue>>(); states.add(Pair.create(ApplicationState.TOKENS, valueFactory.tokens(tokens))); states.add(Pair.create(ApplicationState.STATUS, valueFactory.bootstrapping(tokens))); Gossiper.instance.addLocalApplicationStates(states); setMode(Mode.JOINING, "sleeping " + RING_DELAY + " ms for pending range setup", true); Uninterruptibles.sleepUninterruptibly(RING_DELAY, TimeUnit.MILLISECONDS); } else { // Dont set any state for the node which is bootstrapping the existing token... tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress()); SystemKeyspace.removeEndpoint(DatabaseDescriptor.getReplaceAddress()); } if (!Gossiper.instance.seenAnySeed()) throw new IllegalStateException("Unable to contact any seeds!"); setMode(Mode.JOINING, "Starting to bootstrap...", true); new BootStrapper(FBUtilities.getBroadcastAddress(), tokens, tokenMetadata).bootstrap(); // handles token update logger.info("Bootstrap completed! for the tokens {}", tokens); }
/** * be careful about just blindly updating ApplicationState.INTERNAL_IP everytime we read the yaml file, * as that can cause connections to get unnecessarily reset (via IESCS.onChange()). */ private void maybeSetApplicationState() { if (localNodeData.dcLocalAddress == null) return; final EndpointState es = Gossiper.instance.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress()); if (es == null) return; final VersionedValue vv = es.getApplicationState(ApplicationState.INTERNAL_IP); if ((vv != null && !vv.value.equals(localNodeData.dcLocalAddress.getHostAddress())) || vv == null) { Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP, StorageService.instance.valueFactory.internalIP(localNodeData.dcLocalAddress.getHostAddress())); } }
private void addLocalApplicationStateInternal(ApplicationState state, VersionedValue value) { assert taskLock.isHeldByCurrentThread(); EndpointState epState = endpointStateMap.get(FBUtilities.getBroadcastAddress()); InetAddress epAddr = FBUtilities.getBroadcastAddress(); assert epState != null; // Fire "before change" notifications: doBeforeChangeNotifications(epAddr, epState, state, value); // Notifications may have taken some time, so preventively raise the version // of the new value, otherwise it could be ignored by the remote node // if another value with a newer version was received in the meantime: value = StorageService.instance.valueFactory.cloneWithHigherVersion(value); // Add to local application state and fire "on change" notifications: epState.addApplicationState(state, value); doOnChangeNotifications(epAddr, state, value); }