private void setMode(Mode m, boolean log) { setMode(m, null, log); }
private void setMode(Mode m, boolean log) { setMode(m, null, log); }
private void setMode(Mode m, boolean log) { setMode(m, null, log); }
private void setMode(Mode m, boolean log) { setMode(m, null, log); }
/** This method updates the local token on disk */ public void setTokens(Collection<Token> tokens) { assert tokens != null && !tokens.isEmpty() : "Node needs at least one token."; if (logger.isDebugEnabled()) logger.debug("Setting tokens to {}", tokens); SystemKeyspace.updateTokens(tokens); Collection<Token> localTokens = getLocalTokens(); setGossipTokens(localTokens); tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress()); setMode(Mode.NORMAL, false); }
private void unbootstrap(Runnable onFinish) throws ExecutionException, InterruptedException { Map<String, Multimap<Range<Token>, InetAddress>> rangesToStream = new HashMap<>(); for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces()) { Multimap<Range<Token>, InetAddress> rangesMM = getChangedRangesForLeaving(keyspaceName, FBUtilities.getBroadcastAddress()); if (logger.isDebugEnabled()) logger.debug("Ranges needing transfer are [{}]", StringUtils.join(rangesMM.keySet(), ",")); rangesToStream.put(keyspaceName, rangesMM); } setMode(Mode.LEAVING, "replaying batch log and streaming data to other nodes", true); // Start with BatchLog replay, which may create hints but no writes since this is no longer a valid endpoint. Future<?> batchlogReplay = BatchlogManager.instance.startBatchlogReplay(); Future<StreamState> streamSuccess = streamRanges(rangesToStream); // Wait for batch log to complete before streaming hints. logger.debug("waiting for batch log processing."); batchlogReplay.get(); setMode(Mode.LEAVING, "streaming hints to other nodes", true); Future hintsSuccess = streamHints(); // wait for the transfer runnables to signal the latch. logger.debug("waiting for stream acks."); streamSuccess.get(); hintsSuccess.get(); logger.debug("stream acks all received."); leaveRing(); onFinish.run(); }
/** This method updates the local token on disk */ public void setTokens(Collection<Token> tokens) { assert tokens != null && !tokens.isEmpty() : "Node needs at least one token."; if (logger.isDebugEnabled()) logger.debug("Setting tokens to {}", tokens); SystemKeyspace.updateTokens(tokens); Collection<Token> localTokens = getLocalTokens(); setGossipTokens(localTokens); tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress()); setMode(Mode.NORMAL, false); }
/** This method updates the local token on disk */ public void setTokens(Collection<Token> tokens) { assert tokens != null && !tokens.isEmpty() : "Node needs at least one token."; if (logger.isDebugEnabled()) logger.debug("Setting tokens to {}", tokens); SystemKeyspace.updateTokens(tokens); Collection<Token> localTokens = getLocalTokens(); setGossipTokens(localTokens); tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress()); setMode(Mode.NORMAL, false); }
private void unbootstrap(Runnable onFinish) throws ExecutionException, InterruptedException { Map<String, Multimap<Range<Token>, InetAddress>> rangesToStream = new HashMap<>(); for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces()) { Multimap<Range<Token>, InetAddress> rangesMM = getChangedRangesForLeaving(keyspaceName, FBUtilities.getBroadcastAddress()); if (logger.isDebugEnabled()) logger.debug("Ranges needing transfer are [{}]", StringUtils.join(rangesMM.keySet(), ",")); rangesToStream.put(keyspaceName, rangesMM); } setMode(Mode.LEAVING, "replaying batch log and streaming data to other nodes", true); // Start with BatchLog replay, which may create hints but no writes since this is no longer a valid endpoint. Future<?> batchlogReplay = BatchlogManager.instance.startBatchlogReplay(); Future<StreamState> streamSuccess = streamRanges(rangesToStream); // Wait for batch log to complete before streaming hints. logger.debug("waiting for batch log processing."); batchlogReplay.get(); setMode(Mode.LEAVING, "streaming hints to other nodes", true); Future hintsSuccess = streamHints(); // wait for the transfer runnables to signal the latch. logger.debug("waiting for stream acks."); streamSuccess.get(); hintsSuccess.get(); logger.debug("stream acks all received."); leaveRing(); onFinish.run(); }
private void unbootstrap(Runnable onFinish) throws ExecutionException, InterruptedException { Map<String, Multimap<Range<Token>, InetAddress>> rangesToStream = new HashMap<>(); for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces()) { Multimap<Range<Token>, InetAddress> rangesMM = getChangedRangesForLeaving(keyspaceName, FBUtilities.getBroadcastAddress()); if (logger.isDebugEnabled()) logger.debug("Ranges needing transfer are [{}]", StringUtils.join(rangesMM.keySet(), ",")); rangesToStream.put(keyspaceName, rangesMM); } setMode(Mode.LEAVING, "replaying batch log and streaming data to other nodes", true); // Start with BatchLog replay, which may create hints but no writes since this is no longer a valid endpoint. Future<?> batchlogReplay = BatchlogManager.instance.startBatchlogReplay(); Future<StreamState> streamSuccess = streamRanges(rangesToStream); // Wait for batch log to complete before streaming hints. logger.debug("waiting for batch log processing."); batchlogReplay.get(); setMode(Mode.LEAVING, "streaming hints to other nodes", true); Future hintsSuccess = streamHints(); // wait for the transfer runnables to signal the latch. logger.debug("waiting for stream acks."); streamSuccess.get(); hintsSuccess.get(); logger.debug("stream acks all received."); leaveRing(); onFinish.run(); }
/** This method updates the local token on disk */ public void setTokens(Collection<Token> tokens) { if (logger.isDebugEnabled()) logger.debug("Setting tokens to {}", tokens); SystemKeyspace.updateTokens(tokens); tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress()); Collection<Token> localTokens = getLocalTokens(); setGossipTokens(localTokens); setMode(Mode.NORMAL, false); }
public void waitForSchema(int delay) { // first sleep the delay to make sure we see all our peers for (int i = 0; i < delay; i += 1000) { // if we see schema, we can proceed to the next check directly if (!Schema.instance.getVersion().equals(SchemaConstants.emptyVersion)) { logger.debug("got schema: {}", Schema.instance.getVersion()); break; } Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); } // if our schema hasn't matched yet, wait until it has // we do this by waiting for all in-flight migration requests and responses to complete // (post CASSANDRA-1391 we don't expect this to be necessary very often, but it doesn't hurt to be careful) if (!MigrationManager.isReadyForBootstrap()) { setMode(Mode.JOINING, "waiting for schema information to complete", true); MigrationManager.waitUntilReadyForBootstrap(); } }
public void waitForSchema(int delay) { // first sleep the delay to make sure we see all our peers for (int i = 0; i < delay; i += 1000) { // if we see schema, we can proceed to the next check directly if (!Schema.instance.getVersion().equals(SchemaConstants.emptyVersion)) { logger.debug("got schema: {}", Schema.instance.getVersion()); break; } Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); } // if our schema hasn't matched yet, wait until it has // we do this by waiting for all in-flight migration requests and responses to complete // (post CASSANDRA-1391 we don't expect this to be necessary very often, but it doesn't hurt to be careful) if (!MigrationManager.isReadyForBootstrap()) { setMode(Mode.JOINING, "waiting for schema information to complete", true); MigrationManager.waitUntilReadyForBootstrap(); } }
private void finishJoiningRing(boolean didBootstrap, Collection<Token> tokens) { // start participating in the ring. setMode(Mode.JOINING, "Finish joining ring", true); SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); executePreJoinTasks(didBootstrap); setTokens(tokens); assert tokenMetadata.sortedTokens().size() > 0; doAuthSetup(); }
private void finishJoiningRing(boolean didBootstrap, Collection<Token> tokens) { // start participating in the ring. setMode(Mode.JOINING, "Finish joining ring", true); SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); executePreJoinTasks(didBootstrap); setTokens(tokens); assert tokenMetadata.sortedTokens().size() > 0; doAuthSetup(); }
private void finishJoiningRing(boolean didBootstrap, Collection<Token> tokens) { // start participating in the ring. setMode(Mode.JOINING, "Finish joining ring", true); SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); executePreJoinTasks(didBootstrap); setTokens(tokens); assert tokenMetadata.sortedTokens().size() > 0; doAuthSetup(); }
public void waitForSchema(int delay) { // first sleep the delay to make sure we see all our peers for (int i = 0; i < delay; i += 1000) { // if we see schema, we can proceed to the next check directly if (!Schema.instance.getVersion().equals(SchemaConstants.emptyVersion)) { logger.debug("got schema: {}", Schema.instance.getVersion()); break; } Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); } // if our schema hasn't matched yet, wait until it has // we do this by waiting for all in-flight migration requests and responses to complete // (post CASSANDRA-1391 we don't expect this to be necessary very often, but it doesn't hurt to be careful) if (!MigrationManager.isReadyForBootstrap()) { setMode(Mode.JOINING, "waiting for schema information to complete", true); MigrationManager.waitUntilReadyForBootstrap(); } }
startLeaving(); long timeout = Math.max(RING_DELAY, BatchlogManager.instance.getBatchlogTimeout()); setMode(Mode.LEAVING, "sleeping " + timeout + " ms for batch processing and pending range setup", true); Thread.sleep(timeout);
public synchronized void initClient(int ringDelay) throws ConfigurationException { if (initialized) { if (!isClientMode) throw new UnsupportedOperationException("StorageService does not support switching modes."); return; } initialized = true; isClientMode = true; logger.info("Starting up client gossip"); setMode(Mode.CLIENT, false); Gossiper.instance.register(this); Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering. Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion()); if (!MessagingService.instance().isListening()) MessagingService.instance().listen(FBUtilities.getLocalAddress()); Uninterruptibles.sleepUninterruptibly(ringDelay, TimeUnit.MILLISECONDS); }
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); }