@Test
  public void testRemoveColumnFamilyWithFlush1() {
    Keyspace keyspace = Keyspace.open("Keyspace1");
    ColumnFamilyStore store = keyspace.getColumnFamilyStore("Standard1");
    Mutation rm;
    DecoratedKey dk = Util.dk("key1");

    // add data
    rm = new Mutation("Keyspace1", dk.key);
    rm.add("Standard1", Util.cellname("Column1"), ByteBufferUtil.bytes("asdf"), 0);
    rm.add("Standard1", Util.cellname("Column2"), ByteBufferUtil.bytes("asdf"), 0);
    rm.apply();
    store.forceBlockingFlush();

    // remove
    rm = new Mutation("Keyspace1", dk.key);
    rm.delete("Standard1", 1);
    rm.apply();

    ColumnFamily retrieved =
        store.getColumnFamily(
            QueryFilter.getIdentityFilter(dk, "Standard1", System.currentTimeMillis()));
    assert retrieved.isMarkedForDelete();
    assertNull(retrieved.getColumn(Util.cellname("Column1")));
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
  }
Ejemplo n.º 2
0
    @VisibleForTesting
    synchronized <T> T mutate(OpStats stats, Mutation<T> mutation) {
      long start = System.nanoTime();
      if (writer == null) {
        writer = writerFactory.get();
      }
      try {
        return mutation.apply(writer);
      } catch (TimeoutException e) {
        stats.timeouts.getAndIncrement();
        throw new StreamAccessException("Timeout performing log " + stats.opName, e);
      } catch (Log.WriterFailedException e) {
        stats.failures.getAndIncrement();

        // We must throw away a writer on any write failure - this could be because of a coordinator
        // election in which case we must trigger a new election.
        writer = null;

        throw new StreamAccessException("Problem performing log" + stats.opName, e);
      } finally {
        stats.timing.accumulate(System.nanoTime() - start);
      }
    }
Ejemplo n.º 3
0
 private void insert(String key) {
   Mutation rm;
   rm = new Mutation(KEYSPACE, ByteBufferUtil.bytes(key));
   rm.add(CF, Util.cellname("column"), ByteBufferUtil.bytes("asdf"), 0);
   rm.apply();
 }