當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。