@Override public jvstm.Transaction makeTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { logger.debug("Creating a new top-level transaction"); return new LockFreeTransaction(record); }
protected void helpedTryCommit(CommitRequest myRequest) throws CommitException { // start by reading the current commit queue's head. This is to ensure that we don't miss our own commit request CommitRequest currentRequest = LockFreeClusterUtils.getCommitRequestAtHead(); UUID myRequestId = broadcastCommitRequest(myRequest); // the myRequest instance is different, because it was serialized and deserialized. So, just use its ID. tryCommit(currentRequest, myRequestId); }
@Override protected void tryCommit() { if (isWriteTransaction()) { checkConsistencyPredicates(); preValidateLocally(); logger.debug("Tx is locally valid"); CommitRequest myRequest = makeCommitRequest(); persistWriteSet(myRequest); helpedTryCommit(myRequest); upgradeTx(getCommitTxRecord()); // commitTxRecord was set by the helper LocalCommitOnlyTransaction
public LocalCommitOnlyTransaction(CommitRequest commitRequest, LockFreeTransaction tx) { super(tx.getActiveTxRecord(), commitRequest); this.decoratedTransaction = tx; // this.commitRequest = commitRequest; this.writeSet = this.decoratedTransaction.makeWriteSet(); }
private CommitRequest makeCommitRequest() { return new CommitRequest(DomainClassInfo.getServerId(), getNumber(), makeSimpleReadSet(), makeSimpleWriteSet()); }
@Override public ActiveTransactionsRecord getCommitTxRecord() { return this.decoratedTransaction.getCommitTxRecord(); }
@Override protected void doCommit() { if (isWriteTransaction()) { TransactionStatistics.STATISTICS.incWrites(this); } else { TransactionStatistics.STATISTICS.incReads(this); } if ((numBoxReads > NUM_READS_THRESHOLD) || (numBoxWrites > NUM_WRITES_THRESHOLD)) { logger.warn("Very-large transaction (reads = {}, writes = {})", numBoxReads, numBoxWrites); } // reset statistics counters numBoxReads = 0; numBoxWrites = 0; super.doCommit(); }
@Override protected void helpedTryCommit(CommitRequest myRequest) throws CommitException { this.existingVersion = JvstmLockFreeBackEnd.getInstance().getRepository().getMaxCommittedTxNumber(); super.helpedTryCommit(myRequest); }
@Override protected <T> T getValueFromBody(jvstm.VBox<T> vbox, VBoxBody<T> body) { if (body.value == VBox.NOT_LOADED_VALUE) { VBox<T> ffVBox = (VBox<T>) vbox; // logger.debug("Value for vbox {} is: NOT_LOADED_VALUE", ((VBox) vbox).getId()); ffVBox.reload(); // after the reload, the (new) body should have the required loaded value // if not, then something gone wrong and its better to abort // body = vbox.body.getBody(number); body = ffVBox.getBody(getNumber()); if (body.value == VBox.NOT_LOADED_VALUE) { logger.error("Couldn't load the VBox: {}", ffVBox.getId()); throw new VersionNotAvailableException(); } } // notice that body has changed if we went into the previous if logger.debug("Value for vbox {} is: '{}'", ((VBox) vbox).getId(), body.value); return super.getValueFromBody(vbox, body); }