Exemple #1
0
 public override void Run()
 {
     lock (this)
     {
         long nowNanos = _clock.nanos();
         ISet <KernelTransactionHandle> activeTransactions = _kernelTransactions.activeTransactions();
         CheckExpiredTransactions(activeTransactions, nowNanos);
     }
 }
Exemple #2
0
        public virtual Stream <QueryStatusResult> ListQueries()
        {
            SecurityContext.assertCredentialsNotExpired();

            EmbeddedProxySPI nodeManager = Resolver.resolveDependency(typeof(EmbeddedProxySPI));
            ZoneId           zoneId      = ConfiguredTimeZone;

            try
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
                return(KernelTransactions.activeTransactions().stream().flatMap(KernelTransactionHandle::executingQueries).filter(query => IsAdminOrSelf(query.username())).map(catchThrown(typeof(InvalidArgumentsException), query => new QueryStatusResult(query, nodeManager, zoneId))));
            }
            catch (UncaughtCheckedException uncaught)
            {
                throwIfPresent(uncaught.GetCauseIfOfType(typeof(InvalidArgumentsException)));
                throw uncaught;
            }
        }
Exemple #3
0
        private void MarkUnsafeTransactionsForTermination(TransactionToApply first, TransactionToApply last)
        {
            long firstCommittedTimestamp = first.TransactionRepresentation().TimeCommitted;
            long lastCommittedTimestamp  = last.TransactionRepresentation().TimeCommitted;
            long earliestSafeTimestamp   = lastCommittedTimestamp - _idReuseSafeZoneTime;

            foreach (KernelTransactionHandle txHandle in _kernelTransactions.activeTransactions())
            {
                long commitTimestamp = txHandle.LastTransactionTimestampWhenStarted();

                if (commitTimestamp != Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_COMMIT_TIMESTAMP && commitTimestamp < earliestSafeTimestamp)
                {
                    if (txHandle.MarkForTermination(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Outdated))
                    {
                        _log.info("Marking transaction for termination, " + "invalidated due to an upcoming batch of changes being applied:" + "\n" + "  Batch: firstCommittedTxId:" + first.TransactionId() + ", firstCommittedTimestamp:" + InformativeTimestamp(firstCommittedTimestamp) + ", lastCommittedTxId:" + last.TransactionId() + ", lastCommittedTimestamp:" + InformativeTimestamp(lastCommittedTimestamp) + ", batchTimeRange:" + InformativeDuration(lastCommittedTimestamp - firstCommittedTimestamp) + ", earliestSafeTimestamp:" + InformativeTimestamp(earliestSafeTimestamp) + ", safeZoneDuration:" + InformativeDuration(_idReuseSafeZoneTime) + "\n" + "  Transaction: lastCommittedTimestamp:" + InformativeTimestamp(txHandle.LastTransactionTimestampWhenStarted()) + ", lastCommittedTxId:" + txHandle.LastTransactionIdWhenStarted() + ", localStartTimestamp:" + InformativeTimestamp(txHandle.StartTime()));
                    }
                }
            }
        }
Exemple #4
0
        public virtual Stream <TransactionStatusResult> ListTransactions()
        {
            SecurityContext.assertCredentialsNotExpired();
            try
            {
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
                ISet <KernelTransactionHandle> handles = KernelTransactions.activeTransactions().Where(transaction => IsAdminOrSelf(transaction.subject().username())).collect(toSet());

                IDictionary <KernelTransactionHandle, IList <QuerySnapshot> > handleQuerySnapshotsMap = handles.ToDictionary(identity(), TransactionQueries);

                TransactionDependenciesResolver transactionBlockerResolvers = new TransactionDependenciesResolver(handleQuerySnapshotsMap);

                ZoneId zoneId = ConfiguredTimeZone;

                return(handles.Select(catchThrown(typeof(InvalidArgumentsException), tx => new TransactionStatusResult(tx, transactionBlockerResolvers, handleQuerySnapshotsMap, zoneId))));
            }
            catch (UncaughtCheckedException uncaught)
            {
                throwIfPresent(uncaught.GetCauseIfOfType(typeof(InvalidArgumentsException)));
                throw uncaught;
            }
        }