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


Java AbstractReplicationStrategy.getRangeAddresses方法代码示例

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


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

示例1: getAllRangesWithSourcesFor

import org.apache.cassandra.locator.AbstractReplicationStrategy; //导入方法依赖的package包/类
/**
 * Get a map of all ranges and their respective sources that are candidates for streaming the given ranges
 * to us. For each range, the list of sources is sorted by proximity relative to the given destAddress.
 */
private Multimap<Range<Token>, InetAddress> getAllRangesWithSourcesFor(String keyspaceName, Collection<Range<Token>> desiredRanges)
{
    AbstractReplicationStrategy strat = Keyspace.open(keyspaceName).getReplicationStrategy();
    Multimap<Range<Token>, InetAddress> rangeAddresses = strat.getRangeAddresses(metadata.cloneOnlyTokenMap());

    Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create();
    for (Range<Token> desiredRange : desiredRanges)
    {
        for (Range<Token> range : rangeAddresses.keySet())
        {
            if (range.contains(desiredRange))
            {
                List<InetAddress> preferred = DatabaseDescriptor.getEndpointSnitch().getSortedListByProximity(address, rangeAddresses.get(range));
                rangeSources.putAll(desiredRange, preferred);
                break;
            }
        }

        if (!rangeSources.keySet().contains(desiredRange))
            throw new IllegalStateException("No sources found for " + desiredRange);
    }

    return rangeSources;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:29,代码来源:RangeStreamer.java

示例2: getAllRangesWithSourcesFor

import org.apache.cassandra.locator.AbstractReplicationStrategy; //导入方法依赖的package包/类
/**
 * Get a map of all ranges and their respective sources that are candidates for streaming the given ranges
 * to us. For each range, the list of sources is sorted by proximity relative to the given destAddress.
 *
 * @throws java.lang.IllegalStateException when there is no source to get data streamed
 */
private Multimap<Range<Token>, InetAddress> getAllRangesWithSourcesFor(String keyspaceName, Collection<Range<Token>> desiredRanges)
{
    AbstractReplicationStrategy strat = Keyspace.open(keyspaceName).getReplicationStrategy();
    Multimap<Range<Token>, InetAddress> rangeAddresses = strat.getRangeAddresses(metadata.cloneOnlyTokenMap());

    Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create();
    for (Range<Token> desiredRange : desiredRanges)
    {
        for (Range<Token> range : rangeAddresses.keySet())
        {
            if (range.contains(desiredRange))
            {
                List<InetAddress> preferred = snitch.getSortedListByProximity(address, rangeAddresses.get(range));
                rangeSources.putAll(desiredRange, preferred);
                break;
            }
        }

        if (!rangeSources.keySet().contains(desiredRange))
            throw new IllegalStateException("No sources found for " + desiredRange);
    }

    return rangeSources;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:31,代码来源:RangeStreamer.java

示例3: getAllRangesWithSourcesFor

import org.apache.cassandra.locator.AbstractReplicationStrategy; //导入方法依赖的package包/类
/**
 * Get a map of all ranges and their respective sources that are candidates for streaming the given ranges
 * to us. For each range, the list of sources is sorted by proximity relative to the given destAddress.
 */
private Multimap<Range<Token>, InetAddress> getAllRangesWithSourcesFor(String table, Collection<Range<Token>> desiredRanges)
{
    AbstractReplicationStrategy strat = Table.open(table).getReplicationStrategy();
    Multimap<Range<Token>, InetAddress> rangeAddresses = strat.getRangeAddresses(metadata.cloneOnlyTokenMap());

    Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create();
    for (Range<Token> desiredRange : desiredRanges)
    {
        for (Range<Token> range : rangeAddresses.keySet())
        {
            if (range.contains(desiredRange))
            {
                List<InetAddress> preferred = DatabaseDescriptor.getEndpointSnitch().getSortedListByProximity(address, rangeAddresses.get(range));
                rangeSources.putAll(desiredRange, preferred);
                break;
            }
        }

        if (!rangeSources.keySet().contains(desiredRange))
            throw new IllegalStateException("No sources found for " + desiredRange);
    }

    return rangeSources;
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:29,代码来源:RangeStreamer.java


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