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


Java AbstractByteOrderedPartitioner类代码示例

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


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

示例1: getLocalKeyPartition

import org.apache.cassandra.dht.AbstractByteOrderedPartitioner; //导入依赖的package包/类
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    CTConnection conn = null;
    IPartitioner partitioner = getCassandraPartitioner();

    if (!(partitioner instanceof AbstractByteOrderedPartitioner))
        throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");

    Token.TokenFactory tokenFactory = partitioner.getTokenFactory();

    try {
        // Resist the temptation to describe SYSTEM_KS.  It has no ring.
        // Instead, we'll create our own keyspace (or check that it exists), then describe it.
        ensureKeyspaceExists(keySpaceName);

        conn = pool.borrowObject(keySpaceName);
        List<TokenRange> ranges  = conn.getClient().describe_ring(keySpaceName);
        List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());

        for (TokenRange range : ranges) {
            if (!NetworkUtil.hasLocalAddress(range.endpoints))
                continue;

            keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
        }

        return keyRanges;
    } catch (Exception e) {
        throw CassandraThriftKeyColumnValueStore.convertException(e);
    } finally {
        pool.returnObjectUnsafe(keySpaceName, conn);
    }
}
 
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:34,代码来源:CassandraThriftStoreManager.java

示例2: getLocalKeyPartition

import org.apache.cassandra.dht.AbstractByteOrderedPartitioner; //导入依赖的package包/类
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    CTConnection conn = null;
    IPartitioner<?> partitioner = getCassandraPartitioner();

    if (!(partitioner instanceof AbstractByteOrderedPartitioner))
        throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");

    Token.TokenFactory tokenFactory = partitioner.getTokenFactory();

    try {
        conn = pool.borrowObject(keySpaceName);
        List<TokenRange> ranges  = conn.getClient().describe_ring(keySpaceName);
        List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());

        for (TokenRange range : ranges) {
            if (!NetworkUtil.hasLocalAddress(range.endpoints))
                continue;

            keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
        }

        return keyRanges;
    } catch (Exception e) {
        throw CassandraThriftKeyColumnValueStore.convertException(e);
    } finally {
        pool.returnObjectUnsafe(keySpaceName, conn);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:30,代码来源:CassandraThriftStoreManager.java


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