Beispiel #1
0
  @Test
  public void testTtlString() throws Exception {
    ColumnPrefixDistributedRowLock<String> lock =
        new ColumnPrefixDistributedRowLock<String>(keyspace, LOCK_CF_STRING, "testTtl")
            .withTtl(2)
            .withConsistencyLevel(ConsistencyLevel.CL_ONE)
            .expireLockAfter(1, TimeUnit.SECONDS);

    try {
      lock.acquire();
      Assert.assertEquals(1, lock.readLockColumns().size());
      Thread.sleep(3000);
      Assert.assertEquals(0, lock.readLockColumns().size());
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    } finally {
      lock.release();
    }
    Assert.assertEquals(0, lock.readLockColumns().size());
  }