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


Java Util.getRangeSlice方法代码示例

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


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

示例1: testCleanupWithNewToken

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testCleanupWithNewToken() throws ExecutionException, InterruptedException, UnknownHostException
{
    StorageService.instance.getTokenMetadata().clearUnsafe();

    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF2);

    List<Row> rows;

    // insert data and verify we get it back w/ range query
    fillCF(cfs, LOOPS);

    rows = Util.getRangeSlice(cfs);

    assertEquals(LOOPS, rows.size());
    TokenMetadata tmd = StorageService.instance.getTokenMetadata();

    byte[] tk1 = new byte[1], tk2 = new byte[1];
    tk1[0] = 2;
    tk2[0] = 1;
    tmd.updateNormalToken(new BytesToken(tk1), InetAddress.getByName("127.0.0.1"));
    tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
    CompactionManager.instance.performCleanup(cfs);

    rows = Util.getRangeSlice(cfs);
    assertEquals(0, rows.size());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:29,代码来源:CleanupTest.java

示例2: testTransferRangeTombstones

import org.apache.cassandra.Util; //导入方法依赖的package包/类
/**
 * Test to make sure RangeTombstones at column index boundary transferred correctly.
 */
@Test
public void testTransferRangeTombstones() throws Exception
{
    String ks = "Keyspace1";
    String cfname = "StandardInteger1";
    Keyspace keyspace = Keyspace.open(ks);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);

    String key = "key1";
    Mutation rm = new Mutation(ks, ByteBufferUtil.bytes(key));
    // add columns of size slightly less than column_index_size to force insert column index
    rm.add(cfname, cellname(1), ByteBuffer.wrap(new byte[DatabaseDescriptor.getColumnIndexSize() - 64]), 2);
    rm.add(cfname, cellname(6), ByteBuffer.wrap(new byte[DatabaseDescriptor.getColumnIndexSize()]), 2);
    ColumnFamily cf = rm.addOrGet(cfname);
    // add RangeTombstones
    cf.delete(new DeletionInfo(cellname(2), cellname(3), cf.getComparator(), 1, (int) (System.currentTimeMillis() / 1000)));
    cf.delete(new DeletionInfo(cellname(5), cellname(7), cf.getComparator(), 1, (int) (System.currentTimeMillis() / 1000)));
    rm.apply();
    cfs.forceBlockingFlush();

    SSTableReader sstable = cfs.getSSTables().iterator().next();
    cfs.clearUnsafe();
    transferSSTables(sstable);

    // confirm that a single SSTable was transferred and registered
    assertEquals(1, cfs.getSSTables().size());

    List<Row> rows = Util.getRangeSlice(cfs);
    assertEquals(1, rows.size());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:34,代码来源:StreamingTransferTest.java

示例3: testTransferRangeTombstones

import org.apache.cassandra.Util; //导入方法依赖的package包/类
/**
 * Test to make sure RangeTombstones at column index boundary transferred correctly.
 */
@Test
public void testTransferRangeTombstones() throws Exception
{
    String ks = "Keyspace1";
    String cfname = "StandardInteger1";
    Keyspace keyspace = Keyspace.open(ks);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);

    String key = "key1";
    RowMutation rm = new RowMutation(ks, ByteBufferUtil.bytes(key));
    // add columns of size slightly less than column_index_size to force insert column index
    rm.add(cfname, ByteBufferUtil.bytes(1), ByteBuffer.wrap(new byte[DatabaseDescriptor.getColumnIndexSize() - 64]), 2);
    rm.add(cfname, ByteBufferUtil.bytes(6), ByteBuffer.wrap(new byte[DatabaseDescriptor.getColumnIndexSize()]), 2);
    ColumnFamily cf = rm.addOrGet(cfname);
    // add RangeTombstones
    cf.delete(new DeletionInfo(ByteBufferUtil.bytes(2), ByteBufferUtil.bytes(3), cf.getComparator(), 1, (int) (System.currentTimeMillis() / 1000)));
    cf.delete(new DeletionInfo(ByteBufferUtil.bytes(5), ByteBufferUtil.bytes(7), cf.getComparator(), 1, (int) (System.currentTimeMillis() / 1000)));
    rm.apply();
    cfs.forceBlockingFlush();

    SSTableReader sstable = cfs.getSSTables().iterator().next();
    cfs.clearUnsafe();
    transferSSTables(sstable);

    // confirm that a single SSTable was transferred and registered
    assertEquals(1, cfs.getSSTables().size());

    List<Row> rows = Util.getRangeSlice(cfs);
    assertEquals(1, rows.size());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:34,代码来源:StreamingTransferTest.java

示例4: testTransferOfMultipleColumnFamilies

import org.apache.cassandra.Util; //导入方法依赖的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().getToken()));
    // the left hand side of the range is exclusive, so we transfer from the second-to-last token
    ranges.add(new Range<>(secondtolast.getKey().getToken(), p.getMinimumToken()));

    // Acquiring references, transferSSTables needs it
    Refs<SSTableReader> refs = Refs.tryRef(ssTableReaders);
    if (refs == null)
        throw new AssertionError();

    new StreamPlan("StreamingTransferTest").transferFiles(LOCAL, makeStreamingDetails(ranges, refs)).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:vcostet,项目名称:cassandra-kmean,代码行数:49,代码来源:StreamingTransferTest.java

示例5: testTransferOfMultipleColumnFamilies

import org.apache.cassandra.Util; //导入方法依赖的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.Util.getRangeSlice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。