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


Java DatabaseDescriptor.getNumTokens方法代码示例

本文整理汇总了Java中org.apache.cassandra.config.DatabaseDescriptor.getNumTokens方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseDescriptor.getNumTokens方法的具体用法?Java DatabaseDescriptor.getNumTokens怎么用?Java DatabaseDescriptor.getNumTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.config.DatabaseDescriptor的用法示例。


在下文中一共展示了DatabaseDescriptor.getNumTokens方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBootstrapTokens

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * if initialtoken was specified, use that (split on comma).
 * otherwise, if allocationKeyspace is specified use the token allocation algorithm to generate suitable tokens
 * else choose num_tokens tokens at random
 */
public static Collection<Token> getBootstrapTokens(final TokenMetadata metadata, InetAddress address) throws ConfigurationException
{
    String allocationKeyspace = DatabaseDescriptor.getAllocateTokensForKeyspace();
    Collection<String> initialTokens = DatabaseDescriptor.getInitialTokens();
    if (initialTokens.size() > 0 && allocationKeyspace != null)
        logger.warn("manually specified tokens override automatic allocation");

    // if user specified tokens, use those
    if (initialTokens.size() > 0)
        return getSpecifiedTokens(metadata, initialTokens);

    int numTokens = DatabaseDescriptor.getNumTokens();
    if (numTokens < 1)
        throw new ConfigurationException("num_tokens must be >= 1");

    if (allocationKeyspace != null)
        return allocateTokens(metadata, address, allocationKeyspace, numTokens);

    if (numTokens == 1)
        logger.warn("Picking random token for a single vnode.  You should probably add more vnodes and/or use the automatic token allocation mechanism.");

    return getRandomTokens(metadata, numTokens);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:BootStrapper.java

示例2: getBootstrapTokens

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * if initialtoken was specified, use that (split on comma).
 * otherwise, if num_tokens == 1, pick a token to assume half the load of the most-loaded node.
 * else choose num_tokens tokens at random
 */
public static Collection<Token> getBootstrapTokens(final TokenMetadata metadata) throws ConfigurationException
{
    Collection<String> initialTokens = DatabaseDescriptor.getInitialTokens();
    // if user specified tokens, use those
    if (initialTokens.size() > 0)
    {
        logger.debug("tokens manually specified as {}",  initialTokens);
        List<Token> tokens = new ArrayList<Token>(initialTokens.size());
        for (String tokenString : initialTokens)
        {
            Token token = StorageService.getPartitioner().getTokenFactory().fromString(tokenString);
            if (metadata.getEndpoint(token) != null)
                throw new ConfigurationException("Bootstrapping to existing token " + tokenString + " is not allowed (decommission/removenode the old node first).");
            tokens.add(token);
        }
        return tokens;
    }

    int numTokens = DatabaseDescriptor.getNumTokens();
    if (numTokens < 1)
        throw new ConfigurationException("num_tokens must be >= 1");

    if (numTokens == 1)
        logger.warn("Picking random token for a single vnode.  You should probably add more vnodes; failing that, you should probably specify the token manually");

    return getRandomTokens(metadata, numTokens);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:33,代码来源:BootStrapper.java

示例3: estimateResultRowsPerRange

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * Estimate the number of result rows (either cql3 rows or storage rows, as called for by the command) per
 * range in the ring based on our local data.  This assumes that ranges are uniformly distributed across the cluster
 * and that the queried data is also uniformly distributed.
 */
private static float estimateResultRowsPerRange(AbstractRangeCommand command, Keyspace keyspace)
{
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(command.columnFamily);
    float resultRowsPerRange = Float.POSITIVE_INFINITY;
    if (command.rowFilter != null && !command.rowFilter.isEmpty())
    {
        List<SecondaryIndexSearcher> searchers = cfs.indexManager.getIndexSearchersForQuery(command.rowFilter);
        if (searchers.isEmpty())
        {
            resultRowsPerRange = calculateResultRowsUsingEstimatedKeys(cfs);
        }
        else
        {
            // Secondary index query (cql3 or otherwise).  Estimate result rows based on most selective 2ary index.
            for (SecondaryIndexSearcher searcher : searchers)
            {
                // use our own mean column count as our estimate for how many matching rows each node will have
                SecondaryIndex highestSelectivityIndex = searcher.highestSelectivityIndex(command.rowFilter);
                resultRowsPerRange = Math.min(resultRowsPerRange, highestSelectivityIndex.estimateResultRows());
            }
        }
    }
    else if (!command.countCQL3Rows())
    {
        // non-cql3 query
        resultRowsPerRange = cfs.estimateKeys();
    }
    else
    {
        resultRowsPerRange = calculateResultRowsUsingEstimatedKeys(cfs);
    }

    // adjust resultRowsPerRange by the number of tokens this node has and the replication factor for this ks
    return (resultRowsPerRange / DatabaseDescriptor.getNumTokens()) / keyspace.getReplicationStrategy().getReplicationFactor();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:41,代码来源:StorageProxy.java

示例4: getBootstrapTokens

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * if initialtoken was specified, use that (split on comma).
 * otherwise, if num_tokens == 1, pick a token to assume half the load of the most-loaded node.
 * else choose num_tokens tokens at random
 */
public static Collection<Token> getBootstrapTokens(final TokenMetadata metadata, Map<InetAddress, Double> load) throws ConfigurationException
{
    Collection<String> initialTokens = DatabaseDescriptor.getInitialTokens();
    // if user specified tokens, use those
    if (initialTokens.size() > 0)
    {
        logger.debug("tokens manually specified as {}",  initialTokens);
        List<Token> tokens = new ArrayList<Token>(initialTokens.size());
        for (String tokenString : initialTokens)
        {
            Token token = StorageService.getPartitioner().getTokenFactory().fromString(tokenString);
            if (metadata.getEndpoint(token) != null)
                throw new ConfigurationException("Bootstraping to existing token " + tokenString + " is not allowed (decommission/removetoken the old node first).");
            tokens.add(token);
        }
        return tokens;
    }

    int numTokens = DatabaseDescriptor.getNumTokens();
    if (numTokens < 1)
        throw new ConfigurationException("num_tokens must be >= 1");

    if (numTokens == 1)
        logger.warn("Picking random token for a single vnode.  You should probably add more vnodes; failing that, you should probably specify the token manually");

    return getRandomTokens(metadata, numTokens);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:33,代码来源:BootStrapper.java

示例5: setup

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void setup()
{
    if (DatabaseDescriptor.getNumTokens() == 1)
    {
        LOG.warn("Cannot start range transfer scheduler: endpoint is not virtual nodes-enabled");
        return;
    }

    scheduler = Executors.newSingleThreadScheduledExecutor(new RangeTransferThreadFactory());
    scheduler.scheduleWithFixedDelay(new RangeTransfer(), 0, INTERVAL, TimeUnit.SECONDS);
    LOG.info("Enabling scheduled transfers of token ranges");
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:13,代码来源:ScheduledRangeTransferExecutorService.java

示例6: isReady

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
private boolean isReady()
{
    int targetTokens = DatabaseDescriptor.getNumTokens();
    int highMark = (int)Math.ceil(targetTokens + (targetTokens * .10));
    int actualTokens = StorageService.instance.getTokens().size();

    if (actualTokens >= highMark)
    {
        LOG.warn("Pausing until token count stabilizes (target={}, actual={})", targetTokens, actualTokens);
        return false;
    }

    return true;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:15,代码来源:ScheduledRangeTransferExecutorService.java

示例7: estimateResultsPerRange

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * Estimate the number of result rows (either cql3 rows or "thrift" rows, as called for by the command) per
 * range in the ring based on our local data.  This assumes that ranges are uniformly distributed across the cluster
 * and that the queried data is also uniformly distributed.
 */
private static float estimateResultsPerRange(PartitionRangeReadCommand command, Keyspace keyspace)
{
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(command.metadata().cfId);
    Index index = command.getIndex(cfs);
    float maxExpectedResults = index == null
                             ? command.limits().estimateTotalResults(cfs)
                             : index.getEstimatedResultRows();

    // adjust maxExpectedResults by the number of tokens this node has and the replication factor for this ks
    return (maxExpectedResults / DatabaseDescriptor.getNumTokens()) / keyspace.getReplicationStrategy().getReplicationFactor();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:StorageProxy.java

示例8: allowSimultaneousMoves

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
private boolean allowSimultaneousMoves()
{
    return allowSimultaneousMoves && DatabaseDescriptor.getNumTokens() == 1;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:StorageService.java


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