예제 #1
0
 @Override
 public void close() {
   commitLock.writeLock().lock();
   try {
     super.close();
   } finally {
     commitLock.writeLock().unlock();
   }
 }
예제 #2
0
 @Override
 public void rollback() {
   commitLock.writeLock().lock();
   try {
     cleanTxQueue();
     super.rollback();
     uncommitedData = false;
   } finally {
     commitLock.writeLock().unlock();
   }
 }
예제 #3
0
  protected Long preallocRecidTake() {
    assert (commitLock.isWriteLockedByCurrentThread());
    Long recid = preallocRecids.poll();
    if (recid != null) return recid;

    if (uncommitedData) throw new IllegalAccessError("uncommited data");

    for (int i = 0; i < PREALLOC_RECID_SIZE; i++) {
      preallocRecids.add(super.preallocate());
    }
    recid = super.preallocate();
    super.commit();
    uncommitedData = false;
    return recid;
  }
예제 #4
0
 @Override
 public <A> void delete(long recid, Serializer<A> serializer) {
   commitLock.readLock().lock();
   try {
     uncommitedData = true;
     Lock lock = locks[Store.lockPos(recid)].writeLock();
     lock.lock();
     try {
       Object old = get(recid, serializer);
       for (Reference<Tx> txr : txs) {
         Tx tx = txr.get();
         if (tx == null) continue;
         tx.old.putIfAbsent(recid, old);
       }
       super.delete(recid, serializer);
     } finally {
       lock.unlock();
     }
   } finally {
     commitLock.readLock().unlock();
   }
 }
예제 #5
0
 @Override
 public void preallocate(long[] recids) {
   commitLock.writeLock().lock();
   try {
     uncommitedData = true;
     super.preallocate(recids);
     for (long recid : recids) {
       Lock lock = locks[Store.lockPos(recid)].writeLock();
       lock.lock();
       try {
         for (Reference<Tx> txr : txs) {
           Tx tx = txr.get();
           if (tx == null) continue;
           tx.old.putIfAbsent(recid, TOMBSTONE);
         }
       } finally {
         lock.unlock();
       }
     }
   } finally {
     commitLock.writeLock().unlock();
   }
 }
예제 #6
0
 protected <A> void superDelete(long recid, Serializer<A> serializer) {
   assert (commitLock.isWriteLockedByCurrentThread());
   super.delete(recid, serializer);
 }
예제 #7
0
 protected <A> void superUpdate(long recid, A value, Serializer<A> serializer) {
   assert (commitLock.isWriteLockedByCurrentThread());
   super.update(recid, value, serializer);
 }
예제 #8
0
 protected void superCommit() {
   assert (commitLock.isWriteLockedByCurrentThread());
   super.commit();
 }