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


Java IEndpointSnitch.getSortedListByProximity方法代码示例

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


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

示例1: getNewSourceRanges

import org.apache.cassandra.locator.IEndpointSnitch; //导入方法依赖的package包/类
/**
 * Finds living endpoints responsible for the given ranges
 *
 * @param keyspaceName the keyspace ranges belong to
 * @param ranges the ranges to find sources for
 * @return multimap of addresses to ranges the address is responsible for
 */
private Multimap<InetAddress, Range<Token>> getNewSourceRanges(String keyspaceName, Set<Range<Token>> ranges)
{
    InetAddress myAddress = FBUtilities.getBroadcastAddress();
    Multimap<Range<Token>, InetAddress> rangeAddresses = Keyspace.open(keyspaceName).getReplicationStrategy().getRangeAddresses(tokenMetadata.cloneOnlyTokenMap());
    Multimap<InetAddress, Range<Token>> sourceRanges = HashMultimap.create();
    IFailureDetector failureDetector = FailureDetector.instance;

    // find alive sources for our new ranges
    for (Range<Token> range : ranges)
    {
        Collection<InetAddress> possibleRanges = rangeAddresses.get(range);
        IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
        List<InetAddress> sources = snitch.getSortedListByProximity(myAddress, possibleRanges);

        assert (!sources.contains(myAddress));

        for (InetAddress source : sources)
        {
            if (failureDetector.isAlive(source))
            {
                sourceRanges.put(source, range);
                break;
            }
        }
    }
    return sourceRanges;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:35,代码来源:StorageService.java

示例2: getNewSourceRanges

import org.apache.cassandra.locator.IEndpointSnitch; //导入方法依赖的package包/类
/**
 * Finds living endpoints responsible for the given ranges
 *
 * @param table the table ranges belong to
 * @param ranges the ranges to find sources for
 * @return multimap of addresses to ranges the address is responsible for
 */
private Multimap<InetAddress, Range> getNewSourceRanges(String table, Set<Range> ranges) 
{
    InetAddress myAddress = FBUtilities.getLocalAddress();
    Multimap<Range, InetAddress> rangeAddresses = Table.open(table).getReplicationStrategy().getRangeAddresses(tokenMetadata_);
    Multimap<InetAddress, Range> sourceRanges = HashMultimap.create();
    IFailureDetector failureDetector = FailureDetector.instance;

    // find alive sources for our new ranges
    for (Range range : ranges)
    {
        Collection<InetAddress> possibleRanges = rangeAddresses.get(range);
        IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
        List<InetAddress> sources = snitch.getSortedListByProximity(myAddress, possibleRanges);

        assert (!sources.contains(myAddress));

        for (InetAddress source : sources)
        {
            if (failureDetector.isAlive(source))
            {
                sourceRanges.put(source, range);
                break;
            }
        } 
    }
    return sourceRanges;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:35,代码来源:StorageService.java


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