Search in sources :

Example 1 with DropKeyspace

use of org.apache.cassandra.db.migration.DropKeyspace in project eiger by wlloyd.

the class DefsTest method dropKSUnflushed.

@Test
public void dropKSUnflushed() throws ConfigurationException, IOException, ExecutionException, InterruptedException {
    DecoratedKey dk = Util.dk("dropKs");
    // sanity
    final KSMetaData ks = Schema.instance.getTableDefinition("Keyspace3");
    assert ks != null;
    final CFMetaData cfm = ks.cfMetaData().get("Standard1");
    assert cfm != null;
    // write some data
    RowMutation rm = new RowMutation(ks.name, dk.key);
    for (int i = 0; i < 100; i++) rm.add(new QueryPath(cfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"), 1L);
    rm.apply();
    new DropKeyspace(ks.name).apply();
    assert Schema.instance.getTableDefinition(ks.name) == null;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) DropKeyspace(org.apache.cassandra.db.migration.DropKeyspace) Test(org.junit.Test)

Example 2 with DropKeyspace

use of org.apache.cassandra.db.migration.DropKeyspace in project eiger by wlloyd.

the class DefsTest method dropKS.

@Test
public void dropKS() throws ConfigurationException, IOException, ExecutionException, InterruptedException {
    DecoratedKey dk = Util.dk("dropKs");
    // sanity
    final KSMetaData ks = Schema.instance.getTableDefinition("Keyspace1");
    assert ks != null;
    final CFMetaData cfm = ks.cfMetaData().get("Standard2");
    assert cfm != null;
    // write some data, force a flush, then verify that files exist on disk.
    RowMutation rm = new RowMutation(ks.name, dk.key);
    for (int i = 0; i < 100; i++) rm.add(new QueryPath(cfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"), 1L);
    rm.apply();
    ColumnFamilyStore store = Table.open(cfm.ksName).getColumnFamilyStore(cfm.cfName);
    assert store != null;
    store.forceBlockingFlush();
    assert store.directories.sstableLister().list().size() > 0;
    new DropKeyspace(ks.name).apply();
    assert Schema.instance.getTableDefinition(ks.name) == null;
    // write should fail.
    rm = new RowMutation(ks.name, dk.key);
    boolean success = true;
    try {
        rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("col0")), ByteBufferUtil.bytes("value0"), 1L);
        rm.apply();
    } catch (Throwable th) {
        success = false;
    }
    assert !success : "This mutation should have failed since the CF no longer exists.";
    // reads should fail too.
    boolean threw = false;
    try {
        Table.open(ks.name);
    } catch (Throwable th) {
        threw = true;
    }
    assert threw;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) DropKeyspace(org.apache.cassandra.db.migration.DropKeyspace) Test(org.junit.Test)

Aggregations

QueryPath (org.apache.cassandra.db.filter.QueryPath)2 DropKeyspace (org.apache.cassandra.db.migration.DropKeyspace)2 Test (org.junit.Test)2