當前位置: 首頁>>代碼示例>>Java>>正文


Java CTConnection類代碼示例

本文整理匯總了Java中com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection的典型用法代碼示例。如果您正苦於以下問題:Java CTConnection類的具體用法?Java CTConnection怎麽用?Java CTConnection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CTConnection類屬於com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool包,在下文中一共展示了CTConnection類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCassandraPartitioner

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public IPartitioner getCassandraPartitioner() throws BackendException {
    CTConnection conn = null;
    try {
        conn = pool.borrowObject(SYSTEM_KS);
        return FBUtilities.newPartitioner(conn.getClient().describe_partitioner());
    } catch (Exception e) {
        throw new TemporaryBackendException(e);
    } finally {
        pool.returnObjectUnsafe(SYSTEM_KS, conn);
    }
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:14,代碼來源:CassandraThriftStoreManager.java

示例2: getLocalKeyPartition

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的package包/類
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
    CTConnection conn = null;
    IPartitioner partitioner = getCassandraPartitioner();

    // DAVID CASSANDRA
    // if (!(partitioner instanceof AbstractByteOrderedPartitioner))
    if (!(partitioner instanceof ByteOrderedPartitioner))
        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,項目名稱:titan1withtp3.1,代碼行數:36,代碼來源:CassandraThriftStoreManager.java

示例3: getLocalKeyPartition

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的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

示例4: getCassandraPartitioner

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public IPartitioner<? extends Token<?>> getCassandraPartitioner() throws BackendException {
    CTConnection conn = null;
    try {
        conn = pool.borrowObject(SYSTEM_KS);
        return FBUtilities.newPartitioner(conn.getClient().describe_partitioner());
    } catch (Exception e) {
        throw new TemporaryBackendException(e);
    } finally {
        pool.returnObjectUnsafe(SYSTEM_KS, conn);
    }
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:14,代碼來源:CassandraThriftStoreManager.java

示例5: getLocalKeyPartition

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的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

示例6: getRangeSlices

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的package包/類
private List<KeySlice> getRangeSlices(org.apache.cassandra.thrift.KeyRange keyRange, @Nullable SliceQuery sliceQuery) throws BackendException {
    SliceRange sliceRange = new SliceRange();

    if (sliceQuery == null) {
        sliceRange.setStart(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setFinish(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setCount(5);
    } else {
        sliceRange.setStart(sliceQuery.getSliceStart().asByteBuffer())
                .setFinish(sliceQuery.getSliceEnd().asByteBuffer())
                .setCount((sliceQuery.hasLimit()) ? sliceQuery.getLimit() : Integer.MAX_VALUE);
    }


    CTConnection connection = null;
    try {
        connection = pool.borrowObject(keyspace);

        List<KeySlice> slices =
                connection.getClient().get_range_slices(new ColumnParent(columnFamily),
                        new SlicePredicate()
                                .setSlice_range(sliceRange),
                        keyRange,
                        ConsistencyLevel.QUORUM);

        for (KeySlice s : slices) {
            logger.debug("Key {}", ByteBufferUtil.toString(s.key, "-"));
        }

        /* Note: we need to fetch columns for each row as well to remove "range ghosts" */
        List<KeySlice> result = new ArrayList<>(slices.size());
        KeyIterationPredicate pred = new KeyIterationPredicate();
        for (KeySlice ks : slices)
            if (pred.apply(ks))
                result.add(ks);
        return result;
    } catch (Exception e) {
        throw convertException(e);
    } finally {
        if (connection != null)
            pool.returnObjectUnsafe(keyspace, connection);
    }
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:44,代碼來源:CassandraThriftKeyColumnValueStore.java

示例7: getRangeSlices

import com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection; //導入依賴的package包/類
private List<KeySlice> getRangeSlices(org.apache.cassandra.thrift.KeyRange keyRange, @Nullable SliceQuery sliceQuery) throws BackendException {
    SliceRange sliceRange = new SliceRange();

    if (sliceQuery == null) {
        sliceRange.setStart(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setFinish(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setCount(5);
    } else {
        sliceRange.setStart(sliceQuery.getSliceStart().asByteBuffer())
                .setFinish(sliceQuery.getSliceEnd().asByteBuffer())
                .setCount((sliceQuery.hasLimit()) ? sliceQuery.getLimit() : Integer.MAX_VALUE);
    }


    CTConnection connection = null;
    try {
        connection = pool.borrowObject(keyspace);

        List<KeySlice> slices =
                connection.getClient().get_range_slices(new ColumnParent(columnFamily),
                        new SlicePredicate()
                                .setSlice_range(sliceRange),
                        keyRange,
                        ConsistencyLevel.QUORUM);

        for (KeySlice s : slices) {
            logger.debug("Key {}", ByteBufferUtil.toString(s.key, "-"));
        }

        /* Note: we need to fetch columns for each row as well to remove "range ghosts" */
        List<KeySlice> result = new ArrayList<KeySlice>(slices.size());
        KeyIterationPredicate pred = new KeyIterationPredicate();
        for (KeySlice ks : slices)
            if (pred.apply(ks))
                result.add(ks);
        return result;
    } catch (Exception e) {
        throw convertException(e);
    } finally {
        if (connection != null)
            pool.returnObjectUnsafe(keyspace, connection);
    }
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:44,代碼來源:CassandraThriftKeyColumnValueStore.java


注:本文中的com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。