//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public TransactionHandle terminate(long id) throws org.neo4j.server.rest.transactional.error.TransactionLifecycleException public override TransactionHandle Terminate(long id) { TransactionMarker marker = _registry[id]; if (null == marker) { throw new InvalidTransactionId(); } TransactionTerminationHandle handle = marker.ActiveTransaction.TerminationHandle; handle.Terminate(); try { SuspendedTransaction transaction = marker.SuspendedTransaction; if (_registry.replace(id, marker, marker.ActiveTransaction)) { return(transaction.TransactionHandle); } } catch (InvalidConcurrentTransactionAccess) { // We could not acquire the transaction. Let the other request clean up. } return(null); }
public override void Forget(long id) { TransactionMarker marker = _registry[id]; if (null == marker) { throw new System.InvalidOperationException("Could not finish unregistered transaction"); } if (marker.Suspended) { throw new System.InvalidOperationException("Cannot finish suspended registered transaction"); } if (!_registry.Remove(id, marker)) { throw new System.InvalidOperationException("Trying to finish transaction that has been concurrently finished or suspended"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public TransactionHandle acquire(long id) throws org.neo4j.server.rest.transactional.error.TransactionLifecycleException public override TransactionHandle Acquire(long id) { TransactionMarker marker = _registry[id]; if (null == marker) { throw new InvalidTransactionId(); } SuspendedTransaction transaction = marker.SuspendedTransaction; if (_registry.replace(id, marker, marker.ActiveTransaction)) { return(transaction.TransactionHandle); } else { throw new InvalidConcurrentTransactionAccess(); } }
private void RollbackSuspended(System.Predicate <TransactionMarker> predicate) { ISet <long> candidateTransactionIdsToRollback = new HashSet <long>(); foreach (KeyValuePair <long, TransactionMarker> entry in _registry.SetOfKeyValuePairs()) { TransactionMarker marker = entry.Value; if (marker.Suspended && predicate(marker)) { candidateTransactionIdsToRollback.Add(entry.Key); } } foreach (long id in candidateTransactionIdsToRollback) { TransactionHandle handle; try { handle = Acquire(id); } catch (TransactionLifecycleException) { // Allow this - someone snatched the transaction from under our feet, continue; } try { handle.ForceRollback(); _log.info(format("Transaction with id %d has been automatically rolled back due to transaction timeout.", id)); } catch (Exception e) { _log.error(format("Transaction with id %d failed to roll back.", id), e); } finally { Forget(id); } } }
public override long Release(long id, TransactionHandle transactionHandle) { TransactionMarker marker = _registry[id]; if (null == marker) { throw new System.InvalidOperationException("Trying to suspend unregistered transaction"); } if (marker.Suspended) { throw new System.InvalidOperationException("Trying to suspend transaction that was already suspended"); } SuspendedTransaction suspendedTx = new SuspendedTransaction(this, marker.ActiveTransaction, transactionHandle); if (!_registry.replace(id, marker, suspendedTx)) { throw new System.InvalidOperationException("Trying to suspend transaction that has been concurrently suspended"); } return(ComputeNewExpiryTime(suspendedTx.LastActiveTimestamp)); }