public override void ApplyCommand(ReplicatedTransaction replicatedTx, long commandIndex, System.Action <Result> callback) { lock (this) { if (commandIndex <= _lastCommittedIndex) { _log.debug("Ignoring transaction at log index %d since already committed up to %d", commandIndex, _lastCommittedIndex); return; } TransactionRepresentation tx; sbyte[] extraHeader = encodeLogIndexAsTxHeader(commandIndex); tx = ReplicatedTransactionFactory.ExtractTransactionRepresentation(replicatedTx, extraHeader); int currentTokenId = _lockTokenStateMachine.currentToken().id(); int txLockSessionId = tx.LockSessionId; if (currentTokenId != txLockSessionId && txLockSessionId != Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID) { callback(Result.of(new TransactionFailureException(LockSessionExpired, "The lock session in the cluster has changed: [current lock session id:%d, tx lock session id:%d]", currentTokenId, txLockSessionId))); } else { try { TransactionToApply transaction = new TransactionToApply(tx, _versionContextSupplier.VersionContext); transaction.OnClose(txId => { if (tx.LatestCommittedTxWhenStarted >= txId) { throw new System.InvalidOperationException(format("Out of order transaction. Expected that %d < %d", tx.LatestCommittedTxWhenStarted, txId)); } callback(Result.of(txId)); _commandIndexTracker.AppliedCommandIndex = commandIndex; }); _queue.queue(transaction); } catch (Exception e) { throw PanicException(e); } } } }
/// <summary> /// Queues a transaction for application. /// </summary> /// <param name="tx"> The transaction to be queued for application. </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void queue(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation tx) throws Exception public virtual void Queue(CommittedTransactionRepresentation tx) { long receivedTxId = tx.CommitEntry.TxId; long expectedTxId = _lastQueuedTxId + 1; if (receivedTxId != expectedTxId) { _log.warn("Out of order transaction. Received: %d Expected: %d", receivedTxId, expectedTxId); return; } _txQueue.queue(new TransactionToApply(tx.TransactionRepresentation, receivedTxId, _versionContextSupplier.VersionContext)); if (!_stopped) { _lastQueuedTxId = receivedTxId; _monitor.txPullResponse(receivedTxId); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public boolean visit(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation transaction) throws Exception public override bool Visit(CommittedTransactionRepresentation transaction) { _queue.queue(new TransactionToApplyAnonymousInnerClass(this, transaction.TransactionRepresentation, _versionContextSupplier.VersionContext)); return(false); }