本文整理汇总了Java中org.apache.cassandra.db.SystemKeyspace.updateTokens方法的典型用法代码示例。如果您正苦于以下问题:Java SystemKeyspace.updateTokens方法的具体用法?Java SystemKeyspace.updateTokens怎么用?Java SystemKeyspace.updateTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.db.SystemKeyspace
的用法示例。
在下文中一共展示了SystemKeyspace.updateTokens方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bootstrap
import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
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);
}
示例2: setTokens
import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
/** 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);
}
示例3: testRelocationSuccess
import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
/** Use STATUS changes to trigger membership update and validate results. */
@Test
public void testRelocationSuccess() throws UnknownHostException
{
createInitialRing(5);
// Node handling the relocation (dst), and the token being relocated (src).
InetAddress relocator = InetAddress.getByName("127.0.0.3");
Token relocatee = new BigIntegerToken(String.valueOf(TOKEN_STEP));
// Send RELOCATING and ensure token status
ss.onChange(relocator, ApplicationState.STATUS, vvFactory.relocating(Collections.singleton(relocatee)));
assertTrue(tmd.isRelocating(relocatee));
// Create a list of the endpoint's existing tokens, and add the relocatee to it.
List<Token> tokens = new ArrayList<Token>(tmd.getTokens(relocator));
SystemKeyspace.updateTokens(tokens);
tokens.add(relocatee);
// Send a normal status, then ensure all is copesetic.
Gossiper.instance.injectApplicationState(relocator, ApplicationState.TOKENS, vvFactory.tokens(tokens));
ss.onChange(relocator, ApplicationState.STATUS, vvFactory.normal(tokens));
// Relocating entries are removed after RING_DELAY
Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY + 10, TimeUnit.MILLISECONDS);
assertTrue(!tmd.isRelocating(relocatee));
assertEquals(tmd.getEndpoint(relocatee), relocator);
}