Exemplo n.º 1
0
  public void testTX() {
    TxMaker txMaker = DBMaker.newMemoryDB().makeTxMaker();

    DB db = txMaker.makeTx();
    System.out.println(db.getAtomicLong("counter").incrementAndGet());
    db.commit();
    db = txMaker.makeTx();
    System.out.println(db.getAtomicLong("counter").incrementAndGet());
    db.commit();
    db = txMaker.makeTx();
    System.out.println(db.getAtomicLong("counter").incrementAndGet());
    db.commit();
  }
Exemplo n.º 2
0
 public long incrementQuotaUsage(String username, long increment) {
   long val = db.getAtomicLong(username).addAndGet(increment);
   db.commit();
   return val;
 }
Exemplo n.º 3
0
  public long getQuotaUsage(String username) {
    if (!db.exists(username)) db.createAtomicLong(username, 0);

    return db.getAtomicLong(username).get();
  }
Exemplo n.º 4
0
 /** default constructed initializes to zero */
 public void testConstructor2() {
   Atomic.Long ai = db.getAtomicLong("test2");
   assertEquals(0, ai.get());
 }