Exemple #1
0
        @Override
        public void run() {
          try {
            LOGGER.info("inside run of onCommit");
            WriteSet writeSet = WriteSet.getLocal();
            ReadSet readSet = ReadSet.getLocal();
            VersionClock.setWriteStamp();
            long writeVersion = VersionClock.getWriteStamp();

            for (Map.Entry<LockObject<?>, Object> entry : writeSet.getList()) {
              LockObject<?> key = entry.getKey();
              Copyable<?> destination = null;
              try {
                destination = key.openRead();
              } catch (AbortedException | PanicException e) {
                e.printStackTrace();
              }
              Copyable<Copyable<?>> source = (Copyable<Copyable<?>>) entry.getValue();
              source.copyTo(destination);
              key.stamp = writeVersion;
            }
            writeSet.unlock();
            writeSet.clear();
            readSet.clear();
            Transaction.getLocal().clearKarma();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
Exemple #2
0
 @Override
 public Boolean call() throws Exception {
   WriteSet writeSet = WriteSet.getLocal();
   ReadSet readSet = ReadSet.getLocal();
   if (!writeSet.tryLock(TIMEOUT, TimeUnit.MILLISECONDS)) {
     LOGGER.info("writeSet try lock returned false");
     return false;
   }
   for (LockObject<?> x : readSet.getList()) {
     if (x.lock.isLocked() && !x.lock.isHeldByCurrentThread()) {
       /*
       try {
       	LOGGER.info("Resolving contention at time of read consistency check");
       	ContentionManager.getLocal().resolve(Transaction.getLocal(), x.locker);
       }
       catch (AbortedException e) {
       	return false;
       }
       */
       return false;
     }
     if (x.stamp > VersionClock.getReadStamp()) {
       LOGGER.info("Inconsistent version error: Stamp > Version CLOCK");
       return false;
     }
   }
   return true;
 }
Exemple #3
0
 @Override
 public void run() {
   WriteSet.getLocal().unlock();
   WriteSet.getLocal().clear();
   ReadSet.getLocal().clear();
 }