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


Java RingPosition.getToken方法代码示例

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


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


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