• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RingPosition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.cassandra.dht.RingPosition的典型用法代码示例。如果您正苦于以下问题:Java RingPosition类的具体用法?Java RingPosition怎么用?Java RingPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getNaturalEndpoints

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
/**
 * get the (possibly cached) endpoints that should store the given Token.
 * Note that while the endpoints are conceptually a Set (no duplicates will be included),
 * we return a List to avoid an extra allocation when sorting by proximity later
 * @param searchPosition the position the natural endpoints are requested for
 * @return a copy of the natural endpoints for the given token
 */
public ArrayList<InetAddress> getNaturalEndpoints(RingPosition searchPosition)
{
    Token searchToken = searchPosition.getToken();
    Token keyToken = TokenMetadata.firstToken(tokenMetadata.sortedTokens(), searchToken);
    ArrayList<InetAddress> endpoints = getCachedEndpoints(keyToken);
    if (endpoints == null)
    {
        TokenMetadata tm = tokenMetadata.cachedOnlyTokenMap();
        // if our cache got invalidated, it's possible there is a new token to account for too
        keyToken = TokenMetadata.firstToken(tm.sortedTokens(), searchToken);
        endpoints = new ArrayList<InetAddress>(calculateNaturalEndpoints(searchToken, tm));
        cachedEndpoints.put(keyToken, endpoints);
    }

    return new ArrayList<InetAddress>(endpoints);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:AbstractReplicationStrategy.java


示例2: getNaturalEndpoints

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
/**
 * get the (possibly cached) endpoints that should store the given Token.
 * Note that while the endpoints are conceptually a Set (no duplicates will be included),
 * we return a List to avoid an extra allocation when sorting by proximity later
 * @param searchPosition the position the natural endpoints are requested for
 * @return a copy of the natural endpoints for the given token
 */
public ArrayList<InetAddress> getNaturalEndpoints(RingPosition searchPosition)
{
    Token searchToken = searchPosition.getToken();
    Token keyToken = TokenMetadata.firstToken(tokenMetadata.sortedTokens(), searchToken);
    ArrayList<InetAddress> endpoints = getCachedEndpoints(keyToken);
    if (endpoints == null)
    {
        TokenMetadata tokenMetadataClone = tokenMetadata.cloneOnlyTokenMap();
        keyToken = TokenMetadata.firstToken(tokenMetadataClone.sortedTokens(), searchToken);
        endpoints = new ArrayList<InetAddress>(calculateNaturalEndpoints(searchToken, tokenMetadataClone));
        cacheEndpoint(keyToken, endpoints);
    }

    return new ArrayList<InetAddress>(endpoints);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:23,代码来源:AbstractReplicationStrategy.java


示例3: getNaturalEndpoints

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
/**
 * We need to override this even if we override calculateNaturalEndpoints,
 * because the default implementation depends on token calculations but
 * LocalStrategy may be used before tokens are set up.
 */
@Override
public ArrayList<InetAddress> getNaturalEndpoints(RingPosition searchPosition)
{
    ArrayList<InetAddress> l = new ArrayList<InetAddress>(1);
    l.add(FBUtilities.getBroadcastAddress());
    return l;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:LocalStrategy.java


示例4: getLiveNaturalEndpoints

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
public List<InetAddress> getLiveNaturalEndpoints(Keyspace keyspace, RingPosition pos)
{
    List<InetAddress> endpoints = keyspace.getReplicationStrategy().getNaturalEndpoints(pos);
    List<InetAddress> liveEps = new ArrayList<>(endpoints.size());

    for (InetAddress endpoint : endpoints)
    {
        if (FailureDetector.instance.isAlive(endpoint))
            liveEps.add(endpoint);
    }

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


示例5: getLiveSortedEndpoints

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
private static List<InetAddress> getLiveSortedEndpoints(Keyspace keyspace, RingPosition pos)
{
    List<InetAddress> liveEndpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, pos);
    DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), liveEndpoints);
    return liveEndpoints;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:7,代码来源:StorageProxy.java


示例6: getRestrictedRanges

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
/**
 * Compute all ranges we're going to query, in sorted order. Nodes can be replica destinations for many ranges,
 * so we need to restrict each scan to the specific range we want, or else we'd get duplicate results.
 */
static <T extends RingPosition<T>> List<AbstractBounds<T>> getRestrictedRanges(final AbstractBounds<T> queryRange)
{
    // special case for bounds containing exactly 1 (non-minimum) token
    if (queryRange instanceof Bounds && queryRange.left.equals(queryRange.right) && !queryRange.left.isMinimum(StorageService.getPartitioner()))
    {
        return Collections.singletonList(queryRange);
    }

    TokenMetadata tokenMetadata = StorageService.instance.getTokenMetadata();

    List<AbstractBounds<T>> ranges = new ArrayList<AbstractBounds<T>>();
    // divide the queryRange into pieces delimited by the ring and minimum tokens
    Iterator<Token> ringIter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(), queryRange.left.getToken(), true);
    AbstractBounds<T> remainder = queryRange;
    while (ringIter.hasNext())
    {
        /*
         * remainder can be a range/bounds of token _or_ keys and we want to split it with a token:
         *   - if remainder is tokens, then we'll just split using the provided token.
         *   - if remainder is keys, we want to split using token.upperBoundKey. For instance, if remainder
         *     is [DK(10, 'foo'), DK(20, 'bar')], and we have 3 nodes with tokens 0, 15, 30. We want to
         *     split remainder to A=[DK(10, 'foo'), 15] and B=(15, DK(20, 'bar')]. But since we can't mix
         *     tokens and keys at the same time in a range, we uses 15.upperBoundKey() to have A include all
         *     keys having 15 as token and B include none of those (since that is what our node owns).
         * asSplitValue() abstracts that choice.
         */
        Token upperBoundToken = ringIter.next();
        T upperBound = (T)upperBoundToken.upperBound(queryRange.left.getClass());
        if (!remainder.left.equals(upperBound) && !remainder.contains(upperBound))
            // no more splits
            break;
        Pair<AbstractBounds<T>,AbstractBounds<T>> splits = remainder.split(upperBound);
        if (splits == null)
            continue;

        ranges.add(splits.left);
        remainder = splits.right;
    }
    ranges.add(remainder);

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


示例7: getRestrictedRanges

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
/**
 * Compute all ranges we're going to query, in sorted order. Nodes can be replica destinations for many ranges,
 * so we need to restrict each scan to the specific range we want, or else we'd get duplicate results.
 */
static <T extends RingPosition> List<AbstractBounds<T>> getRestrictedRanges(final AbstractBounds<T> queryRange)
{
    // special case for bounds containing exactly 1 (non-minimum) token
    if (queryRange instanceof Bounds && queryRange.left.equals(queryRange.right) && !queryRange.left.isMinimum(StorageService.getPartitioner()))
    {
        return Collections.singletonList(queryRange);
    }

    TokenMetadata tokenMetadata = StorageService.instance.getTokenMetadata();

    List<AbstractBounds<T>> ranges = new ArrayList<AbstractBounds<T>>();
    // divide the queryRange into pieces delimited by the ring and minimum tokens
    Iterator<Token> ringIter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(), queryRange.left.getToken(), true);
    AbstractBounds<T> remainder = queryRange;
    while (ringIter.hasNext())
    {
        /*
         * remainder can be a range/bounds of token _or_ keys and we want to split it with a token:
         *   - if remainder is tokens, then we'll just split using the provided token.
         *   - if remainder is keys, we want to split using token.upperBoundKey. For instance, if remainder
         *     is [DK(10, 'foo'), DK(20, 'bar')], and we have 3 nodes with tokens 0, 15, 30. We want to
         *     split remainder to A=[DK(10, 'foo'), 15] and B=(15, DK(20, 'bar')]. But since we can't mix
         *     tokens and keys at the same time in a range, we uses 15.upperBoundKey() to have A include all
         *     keys having 15 as token and B include none of those (since that is what our node owns).
         * asSplitValue() abstracts that choice.
         */
        Token upperBoundToken = ringIter.next();
        T upperBound = (T)upperBoundToken.upperBound(queryRange.left.getClass());
        if (!remainder.left.equals(upperBound) && !remainder.contains(upperBound))
            // no more splits
            break;
        Pair<AbstractBounds<T>,AbstractBounds<T>> splits = remainder.split(upperBound);
        if (splits == null)
            continue;

        ranges.add(splits.left);
        remainder = splits.right;
    }
    ranges.add(remainder);

    return ranges;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:47,代码来源:StorageProxy.java


示例8: getLiveSortedEndpoints

import org.apache.cassandra.dht.RingPosition; //导入依赖的package包/类
private static List<InetAddress> getLiveSortedEndpoints(Table table, RingPosition pos)
{
    List<InetAddress> liveEndpoints = StorageService.instance.getLiveNaturalEndpoints(table, pos);
    DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), liveEndpoints);
    return liveEndpoints;
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:7,代码来源:StorageProxy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TestDirHelper类代码示例发布时间:2022-05-22
下一篇:
Java SplitLineReader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap