当前位置: 首页>>代码示例>>Java>>正文


Java SystemKeyspace.updateTokens方法代码示例

本文整理汇总了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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:StorageService.java

示例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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:StorageService.java

示例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);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:30,代码来源:RelocateTest.java


注:本文中的org.apache.cassandra.db.SystemKeyspace.updateTokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。