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


Java SSTableReader.acquireReferences方法代码示例

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


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

示例1: complete

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
private void complete()
{
    if (!SSTableReader.acquireReferences(sstables))
        throw new AssertionError("We shouldn't fail acquiring a reference on a sstable that has just been transferred");
    try
    {
        Pair<String, String> kscf = Schema.instance.getCF(cfId);
        ColumnFamilyStore cfs = Keyspace.open(kscf.left).getColumnFamilyStore(kscf.right);
        // add sstables and build secondary indexes
        cfs.addSSTables(sstables);
        cfs.indexManager.maybeBuildSecondaryIndexes(sstables, cfs.indexManager.allIndexesNames());
    }
    finally
    {
        SSTableReader.releaseReferences(sstables);
    }

    session.taskCompleted(this);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:StreamReceiveTask.java

示例2: testTransferOfMultipleColumnFamilies

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
@Test
public void testTransferOfMultipleColumnFamilies() throws Exception
{
    String keyspace = "KeyCacheSpace";
    IPartitioner p = StorageService.getPartitioner();
    String[] columnFamilies = new String[] { "Standard1", "Standard2", "Standard3" };
    List<SSTableReader> ssTableReaders = new ArrayList<>();

    NavigableMap<DecoratedKey,String> keys = new TreeMap<>();
    for (String cf : columnFamilies)
    {
        Set<String> content = new HashSet<>();
        content.add("data-" + cf + "-1");
        content.add("data-" + cf + "-2");
        content.add("data-" + cf + "-3");
        SSTableUtils.Context context = SSTableUtils.prepare().ks(keyspace).cf(cf);
        ssTableReaders.add(context.write(content));

        // collect dks for each string key
        for (String str : content)
            keys.put(Util.dk(str), cf);
    }

    // transfer the first and last keys
    Map.Entry<DecoratedKey,String> first = keys.firstEntry();
    Map.Entry<DecoratedKey,String> last = keys.lastEntry();
    Map.Entry<DecoratedKey,String> secondtolast = keys.lowerEntry(last.getKey());
    List<Range<Token>> ranges = new ArrayList<>();
    ranges.add(new Range<>(p.getMinimumToken(), first.getKey().token));
    // the left hand side of the range is exclusive, so we transfer from the second-to-last token
    ranges.add(new Range<>(secondtolast.getKey().token, p.getMinimumToken()));

    // Acquiring references, transferSSTables needs it
    if (!SSTableReader.acquireReferences(ssTableReaders))
        throw new AssertionError();

    new StreamPlan("StreamingTransferTest").transferFiles(LOCAL, makeStreamingDetails(ranges, ssTableReaders)).execute().get();

    // check that only two keys were transferred
    for (Map.Entry<DecoratedKey,String> entry : Arrays.asList(first, last))
    {
        ColumnFamilyStore store = Keyspace.open(keyspace).getColumnFamilyStore(entry.getValue());
        List<Row> rows = Util.getRangeSlice(store);
        assertEquals(rows.toString(), 1, rows.size());
        assertEquals(entry.getKey(), rows.get(0).key);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:48,代码来源:StreamingTransferTest.java


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