protected static synchronized ActiveTransactionsRecord makeSentinelRecord() { if (sentinelRecordCreated) { throw new Error("ActiveTransactionsRecord::makeSentinelRecord() invoked more than once!"); } sentinelRecordCreated = true; return new ActiveTransactionsRecord(); }
protected void assignCommitRecord(int txNumber, WriteSet writeSet) { setCommitTxRecord(new ActiveTransactionsRecord(txNumber, writeSet)); }
protected void initializeJvstmTxNumber() { int maxTx = getRepository().getMaxCommittedTxNumber(); if (maxTx >= 0) { logger.info("Setting the last committed TX number to {}", maxTx); Transaction.setMostRecentActiveRecord(new ActiveTransactionsRecord(maxTx, null)); } else { throw new Error("Couldn't determine the last transaction number"); } }
public static void initializeTxNumber(int maxTx) { logger.info("Setting the last committed TX number to {}", maxTx); ActiveTransactionsRecord initialRecord = new ActiveTransactionsRecord(maxTx, WriteSet.empty()); boolean success = Transaction.mostRecentCommittedRecord.trySetNext(initialRecord); if (!success) { throw new AssertionError("Impossible condition: Failed to initializeTxNumber."); } Transaction.setMostRecentCommittedRecord(initialRecord); }
public static void setupJVSTM() { jvstm.Transaction.setTransactionFactory(new jvstm.TransactionFactory() { @Override public jvstm.Transaction makeTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { return new TopLevelTransaction(record); } @Override public jvstm.Transaction makeReadOnlyTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { return new ReadOnlyTopLevelTransaction(record); } }); // initialize transaction system int maxTx = TransactionChangeLogs.initializeTransactionSystem(); if (maxTx >= 0) { logger.info("Setting the last committed TX number to {}", maxTx); Transaction.setMostRecentActiveRecord(new ActiveTransactionsRecord(maxTx, null)); } else { throw new Error("Couldn't determine the last transaction number"); } }
@Override protected void doCommit() { // the commit is already done, so create a new ActiveTransactionsRecord for (Map.Entry<PerTxBox, Object> entry : this.perTxValues.entrySet()) { entry.getKey().commit(entry.getValue()); } ActiveTransactionsRecord newRecord = new ActiveTransactionsRecord(getNumber(), WriteSet.empty()); newRecord.setCommitted(); setMostRecentCommittedRecord(newRecord); if (!this.activeTxRecord.trySetNext(newRecord)) { throw new Error("Unacceptable: UnsafeSingleThreadedTransaction in a concurrent environment"); } // we must update the activeRecords accordingly context().oldestRequiredVersion = newRecord; this.activeTxRecord = newRecord; }
ActiveTransactionsRecord newRecord = new ActiveTransactionsRecord(txNum, newBodies); Transaction.setMostRecentActiveRecord(newRecord);
private static void applyRemoteCommit(RemoteCommit remoteCommit) { int serverId = remoteCommit.getServerId(); int txNumber = remoteCommit.getTxNumber(); logger.debug("Applying remote commit: serverId={}, txNumber={}", serverId, txNumber); Cons<VBoxBody> newBodies = Cons.empty(); int size = remoteCommit.getIds().length; for (int i = 0; i < size; i++) { String vboxId = remoteCommit.getIds()[i]; JvstmClusterBackEnd backEnd = (JvstmClusterBackEnd) FenixFramework.getConfig().getBackEnd(); VBox vbox = backEnd.lookupCachedVBox(vboxId); /* if the vbox is not found (not cached or reachable from a domain object), we don't need to update its slots. If a concurrent access to this objects causes it to be allocated and its slots reloaded, the most recent values will be fetched from the repository */ if (vbox != null) { VBoxBody newBody = vbox.addNewVersion(txNumber); if (newBody != null) { newBodies = newBodies.cons(newBody); } } else { logger.debug("Ignoring remote commit for vbox not found in local memory: {}", vboxId); } } ActiveTransactionsRecord newRecord = new ActiveTransactionsRecord(txNumber, newBodies); Transaction.setMostRecentActiveRecord(newRecord); }