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


Java Util.assertEmpty方法代码示例

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


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

示例1: testGetRowNoColumns

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testGetRowNoColumns() throws Throwable
{
    String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))");

    execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", 0, 0);

    final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName);

    for (int round = 0; round < 2; round++)
    {
        // slice with limit 0
        Util.assertEmpty(Util.cmd(cfs, "0").columns("c").withLimit(0).build());

        // slice with nothing in between the bounds
        Util.assertEmpty(Util.cmd(cfs, "0").columns("c").fromIncl(1).toIncl(1).build());

        // fetch a non-existent name
        Util.assertEmpty(Util.cmd(cfs, "0").columns("c").includeRow(1).build());

        if (round == 0)
            cfs.forceBlockingFlush();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:KeyspaceTest.java

示例2: testExpiringColumnExpiration

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testExpiringColumnExpiration() throws IOException
{
    int ttl = 1;
    ColumnDefinition def = cfm.getColumnDefinition(new ColumnIdentifier("a", true));

    Cell cell = BufferCell.expiring(def, 0, ttl, nowInSeconds, ((AbstractType) def.cellValueType()).decompose("a1"));

    PartitionUpdate update = PartitionUpdate.singleRowUpdate(cfm, dk, BTreeRow.singleCellRow(cfm.comparator.make("c1"), cell));
    new Mutation(update).applyUnsafe();

    // when we read with a nowInSeconds before the cell has expired,
    // the PartitionIterator includes the row we just wrote
    Row row = Util.getOnlyRow(Util.cmd(cfs, dk).includeRow("c1").withNowInSeconds(nowInSeconds).build());
    assertEquals("a1", ByteBufferUtil.string(row.getCell(def).value()));

    // when we read with a nowInSeconds after the cell has expired, the row is filtered
    // so the PartitionIterator is empty
    Util.assertEmpty(Util.cmd(cfs, dk).includeRow("c1").withNowInSeconds(nowInSeconds + ttl + 1).build());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:RowTest.java

示例3: testTruncateWithoutSnapshotNonDurable

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testTruncateWithoutSnapshotNonDurable() throws IOException
{
    boolean originalState = DatabaseDescriptor.getAutoSnapshot();
    try
    {
        DatabaseDescriptor.setAutoSnapshot(false);
        Keyspace notDurableKs = Keyspace.open(KEYSPACE2);
        Assert.assertFalse(notDurableKs.getMetadata().params.durableWrites);

        ColumnFamilyStore cfs = notDurableKs.getColumnFamilyStore("Standard1");
        new RowUpdateBuilder(cfs.metadata, 0, "key1")
            .clustering("bytes").add("val", ByteBufferUtil.bytes("abcd"))
            .build()
            .applyUnsafe();

        assertTrue(Util.getOnlyRow(Util.cmd(cfs).columns("val").build())
                        .cells().iterator().next().value().equals(ByteBufferUtil.bytes("abcd")));

        cfs.truncateBlocking();

        Util.assertEmpty(Util.cmd(cfs).columns("val").build());
    }
    finally
    {
        DatabaseDescriptor.setAutoSnapshot(originalState);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:CommitLogTest.java

示例4: testCompactionPurgeOneFile

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testCompactionPurgeOneFile() throws ExecutionException, InterruptedException
{
    CompactionManager.instance.disableAutoCompaction();

    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    String cfName = "Standard2";
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);

    String key = "key1";

    // inserts
    for (int i = 0; i < 5; i++)
    {
        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 0, key);
        builder.clustering(String.valueOf(i))
               .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
               .build().applyUnsafe();
    }

    // deletes
    for (int i = 0; i < 5; i++)
    {
        RowUpdateBuilder.deleteRow(cfs.metadata, 1, key, String.valueOf(i)).applyUnsafe();
    }
    cfs.forceBlockingFlush();
    assertEquals(String.valueOf(cfs.getLiveSSTables()), 1, cfs.getLiveSSTables().size()); // inserts & deletes were in the same memtable -> only deletes in sstable

    // compact and test that the row is completely gone
    Util.compactAll(cfs, Integer.MAX_VALUE).get();
    assertTrue(cfs.getLiveSSTables().isEmpty());

    Util.assertEmpty(Util.cmd(cfs, key).build());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:35,代码来源:CompactionsPurgeTest.java

示例5: testCompactionPurgeCachedRow

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testCompactionPurgeCachedRow() throws ExecutionException, InterruptedException
{
    CompactionManager.instance.disableAutoCompaction();

    String keyspaceName = KEYSPACE_CACHED;
    String cfName = CF_CACHED;
    Keyspace keyspace = Keyspace.open(keyspaceName);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);

    String key = "key3";

    // inserts
    for (int i = 0; i < 10; i++)
    {
        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 0, key);
        builder.clustering(String.valueOf(i))
               .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
               .build().applyUnsafe();
    }

    // deletes partition
    Mutation rm = new Mutation(KEYSPACE_CACHED, dk(key));
    rm.add(PartitionUpdate.fullPartitionDelete(cfs.metadata, dk(key), 1, FBUtilities.nowInSeconds()));
    rm.applyUnsafe();

    // Adds another unrelated partition so that the sstable is not considered fully expired. We do not
    // invalidate the row cache in that latter case.
    new RowUpdateBuilder(cfs.metadata, 0, "key4").clustering("c").add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER).build().applyUnsafe();

    // move the key up in row cache (it should not be empty since we have the partition deletion info)
    assertFalse(Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build()).isEmpty());

    // flush and major compact
    cfs.forceBlockingFlush();
    Util.compactAll(cfs, Integer.MAX_VALUE).get();

    // Since we've force purging (by passing MAX_VALUE for gc_before), the row should have been invalidated and we should have no deletion info anymore
    Util.assertEmpty(Util.cmd(cfs, key).build());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:41,代码来源:CompactionsPurgeTest.java

示例6: assertNoDataPresent

import org.apache.cassandra.Util; //导入方法依赖的package包/类
private void assertNoDataPresent(ColumnFamilyStore cfs, DecoratedKey key)
{
    Util.assertEmpty(Util.cmd(cfs, key).build());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:PaxosStateTest.java

示例7: testDeletes

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testDeletes() throws WriteTimeoutException
{
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF1);
    cfs.truncateBlocking();
    ColumnDefinition cOne = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("val"));
    ColumnDefinition cTwo = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("val2"));

    // Do the initial update (+1, -1)
    new CounterMutation(
        new RowUpdateBuilder(cfs.metadata, 5, "key1")
            .clustering("cc")
            .add("val", 1L)
            .add("val2", -1L)
            .build(),
        ConsistencyLevel.ONE).apply();

    Row row = Util.getOnlyRow(Util.cmd(cfs).includeRow("cc").columns("val", "val2").build());
    assertEquals(1L, CounterContext.instance().total(row.getCell(cOne).value()));
    assertEquals(-1L, CounterContext.instance().total(row.getCell(cTwo).value()));

    // Remove the first counter, increment the second counter
    new CounterMutation(
        new RowUpdateBuilder(cfs.metadata, 5, "key1")
            .clustering("cc")
            .delete(cOne)
            .add("val2", -5L)
            .build(),
        ConsistencyLevel.ONE).apply();

    row = Util.getOnlyRow(Util.cmd(cfs).includeRow("cc").columns("val", "val2").build());
    assertEquals(null, row.getCell(cOne));
    assertEquals(-6L, CounterContext.instance().total(row.getCell(cTwo).value()));

    // Increment the first counter, make sure it's still shadowed by the tombstone
    new CounterMutation(
        new RowUpdateBuilder(cfs.metadata, 5, "key1")
            .clustering("cc")
            .add("val", 1L)
            .build(),
        ConsistencyLevel.ONE).apply();
    row = Util.getOnlyRow(Util.cmd(cfs).includeRow("cc").columns("val", "val2").build());
    assertEquals(null, row.getCell(cOne));

    // Get rid of the complete partition
    RowUpdateBuilder.deleteRow(cfs.metadata, 6, "key1", "cc").applyUnsafe();
    Util.assertEmpty(Util.cmd(cfs).includeRow("cc").columns("val", "val2").build());

    // Increment both counters, ensure that both stay dead
    new CounterMutation(
        new RowUpdateBuilder(cfs.metadata, 6, "key1")
            .clustering("cc")
            .add("val", 1L)
            .add("val2", 1L)
            .build(),
        ConsistencyLevel.ONE).apply();
    Util.assertEmpty(Util.cmd(cfs).includeRow("cc").columns("val", "val2").build());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:59,代码来源:CounterMutationTest.java


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