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 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"); } }
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); }