@Override
 public void addWaitee(final NodeID waitee, final TransactionID txnID) {
   final TransactionRecord record = getRecord(txnID);
   Assert.assertNotNull(record);
   final boolean added = record.addWaitee(waitee);
   Assert.eval(added);
 }
 @Override
 public boolean hasWaitees(final TransactionID txnID) {
   final TransactionRecord record = getRecord(txnID);
   if (record == null) {
     return false;
   }
   return !record.isEmpty();
 }
 @Override
 public boolean relayTransactionComplete(final TransactionID txnID) {
   final TransactionRecord transactionRecord = getRecord(txnID);
   if (transactionRecord.relayTransactionComplete()) {
     return removeTransaction(txnID);
   } else {
     return false;
   }
 }
 @Override
 public boolean processMetaDataCompleted(TransactionID requestID) {
   TransactionRecord transactionRecord = getRecord(requestID);
   if (transactionRecord.processMetaDataCompleted()) {
     return removeTransaction(requestID);
   } else {
     return false;
   }
 }
 @Override
 public boolean broadcastCompleted(final TransactionID txnID) {
   final TransactionRecord transactionRecord = getRecord(txnID);
   if (transactionRecord.broadcastCompleted()) {
     return removeTransaction(txnID);
   } else {
     return false;
   }
 }
 @Override
 public boolean applyCommitted(final TransactionID txnID) {
   final TransactionRecord transactionRecord = getRecord(txnID);
   if (transactionRecord.applyCommitted()) {
     return removeTransaction(txnID);
   } else {
     return false;
   }
 }
 @Override
 public Set requestersWaitingFor(final NodeID waitee) {
   final Set requesters = new HashSet();
   for (final TransactionID tid : getTransactions()) {
     final TransactionRecord record = (TransactionRecord) this.waitees.get(tid);
     if (record != null && record.contains(waitee)) {
       requesters.add(tid);
     }
   }
   return requesters;
 }
  /*
   * returns true if completed, false if not completed or if the client has sent a duplicate ACK.
   */
  @Override
  public boolean removeWaitee(final NodeID waitee, final TransactionID txnID) {
    final TransactionRecord transactionRecord = getRecord(txnID);

    if (transactionRecord == null) {
      return false;
    }
    if (transactionRecord.remove(waitee)) {
      return removeTransaction(txnID);
    } else {
      return false;
    }
  }
 @Override
 public void addObjectsSyncedTo(final NodeID to, final TransactionID txnID) {
   TransactionRecord tr = null;
   while (tr == null) {
     synchronized (this.waitees) {
       tr = this.waitees.get(txnID);
       if (tr == null) {
         tr = new TransactionRecord(to);
         createRecord(txnID, tr);
       } else if (!tr.addWaitee(to)) {
         /*  couldn't add the waitee, try again  */
         tr = null;
       }
     }
   }
 }
예제 #10
0
 void logComplete() {
   // inefficient use of space
   String[] logStrings = m_logBuffer.toString().split("\n");
   // Process the log output into transaction records
   for (int i = 0; i < logStrings.length; i++) {
     LogString next = new LogString(logStrings[i]);
     if (!next.isFuzz()) {
       continue;
     }
     TransactionRecord txn = null;
     if (next.isTxnStart()) {
       // create a new TransactionRecord
       assert (!m_txns.containsKey(next.getTxnId()));
       txn = new TransactionRecord(next);
       m_txns.put(next.getTxnId(), txn);
       m_txnInitOrder.add(txn);
     } else if (next.isRollback() || next.isTxnEnd()) {
       txn = m_txns.get(next.getTxnId());
       txn.updateRecord(next);
       if (next.isTxnEnd()) {
         m_txnCloseOrder.add(txn);
       }
     } else if (next.isSelfFault() || next.isOtherFault()) {
       // mark this fault in all open transactions
       // This is horribly inefficient, any number of smarter faster options
       // if it's too slow
       for (TransactionRecord txn1 : m_txns.values()) {
         if (!txn1.isClosed()) {
           txn1.updateRecord(next);
         }
       }
     } else {
       // Unknown log type
       assert (false);
     }
   }
 }
 @Override
 public void waitUntilCommitted(final TransactionID txnID) {
   TransactionRecord record = getRecord(txnID);
   checkArgument(record != null, "%s not found.", txnID);
   record.waitUntilCommit();
 }