Beispiel #1
0
        public virtual IDictionary <string, object> DescribeBlockingLocks(KernelTransactionHandle handle)
        {
            IList <QuerySnapshot> querySnapshots = _handleSnapshotsMap[handle];

            if (querySnapshots.Count > 0)
            {
                return(querySnapshots[0].ResourceInformation());
            }
            return(Collections.emptyMap());
        }
Beispiel #2
0
        private IDictionary <KernelTransactionHandle, ISet <KernelTransactionHandle> > InitDirectDependencies()
        {
            IDictionary <KernelTransactionHandle, ISet <KernelTransactionHandle> > directDependencies = new Dictionary <KernelTransactionHandle, ISet <KernelTransactionHandle> >();

            IDictionary <KernelTransactionHandle, IList <ActiveLock> > transactionLocksMap = _handleSnapshotsMap.Keys.ToDictionary(identity(), TransactionLocks);

            foreach (KeyValuePair <KernelTransactionHandle, IList <QuerySnapshot> > entry in _handleSnapshotsMap.SetOfKeyValuePairs())
            {
                IList <QuerySnapshot> querySnapshots = entry.Value;
                if (querySnapshots.Count > 0)
                {
                    KernelTransactionHandle txHandle = entry.Key;
                    EvaluateDirectDependencies(directDependencies, transactionLocksMap, txHandle, querySnapshots[0]);
                }
            }
            return(directDependencies);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public TransactionStatusResult(org.neo4j.kernel.api.KernelTransactionHandle transaction, TransactionDependenciesResolver transactionDependenciesResolver, java.util.Map<org.neo4j.kernel.api.KernelTransactionHandle,java.util.List<org.neo4j.kernel.api.query.QuerySnapshot>> handleSnapshotsMap, java.time.ZoneId zoneId) throws org.neo4j.kernel.api.exceptions.InvalidArgumentsException
        public TransactionStatusResult(KernelTransactionHandle transaction, TransactionDependenciesResolver transactionDependenciesResolver, IDictionary <KernelTransactionHandle, IList <QuerySnapshot> > handleSnapshotsMap, ZoneId zoneId)
        {
            this.TransactionId = transaction.UserTransactionName;
            this.Username      = transaction.Subject().username();
            this.StartTime     = ProceduresTimeFormatHelper.FormatTime(transaction.StartTime(), zoneId);
            Optional <Status> terminationReason = transaction.TerminationReason();

            this.ActiveLockCount = transaction.ActiveLocks().count();
            IList <QuerySnapshot>         querySnapshots = handleSnapshotsMap[transaction];
            TransactionExecutionStatistic statistic      = transaction.TransactionStatistic();

            ElapsedTimeMillis    = statistic.ElapsedTimeMillis;
            CpuTimeMillis        = statistic.CpuTimeMillis;
            AllocatedBytes       = statistic.HeapAllocatedBytes;
            AllocatedDirectBytes = statistic.DirectAllocatedBytes;
            WaitTimeMillis       = statistic.WaitTimeMillis;
            IdleTimeMillis       = statistic.IdleTimeMillis;
            PageHits             = statistic.PageHits;
            PageFaults           = statistic.PageFaults;

            if (querySnapshots.Count > 0)
            {
                QuerySnapshot        snapshot             = querySnapshots[0];
                ClientConnectionInfo clientConnectionInfo = snapshot.ClientConnection();
                this.CurrentQueryId = ofInternalId(snapshot.InternalQueryId()).ToString();
                this.CurrentQuery   = snapshot.QueryText();
                this.Protocol       = clientConnectionInfo.Protocol();
                this.ClientAddress  = clientConnectionInfo.ClientAddress();
                this.RequestUri     = clientConnectionInfo.RequestURI();
                this.ConnectionId   = clientConnectionInfo.ConnectionId();
            }
            else
            {
                this.CurrentQueryId = StringUtils.EMPTY;
                this.CurrentQuery   = StringUtils.EMPTY;
                this.Protocol       = StringUtils.EMPTY;
                this.ClientAddress  = StringUtils.EMPTY;
                this.RequestUri     = StringUtils.EMPTY;
                this.ConnectionId   = StringUtils.EMPTY;
            }
            this.ResourceInformation = transactionDependenciesResolver.DescribeBlockingLocks(transaction);
            this.Status   = GetStatus(transaction, terminationReason, transactionDependenciesResolver);
            this.MetaData = transaction.MetaData;
        }
Beispiel #4
0
        private void EvaluateDirectDependencies(IDictionary <KernelTransactionHandle, ISet <KernelTransactionHandle> > directDependencies, IDictionary <KernelTransactionHandle, IList <ActiveLock> > handleLocksMap, KernelTransactionHandle txHandle, QuerySnapshot querySnapshot)
        {
            IList <ActiveLock> waitingOnLocks = querySnapshot.WaitingLocks();

            foreach (ActiveLock activeLock in waitingOnLocks)
            {
                foreach (KeyValuePair <KernelTransactionHandle, IList <ActiveLock> > handleListEntry in handleLocksMap.SetOfKeyValuePairs())
                {
                    KernelTransactionHandle kernelTransactionHandle = handleListEntry.Key;
                    if (!kernelTransactionHandle.Equals(txHandle))
                    {
                        if (IsBlocked(activeLock, handleListEntry.Value))
                        {
                            ISet <KernelTransactionHandle> kernelTransactionHandles = directDependencies.computeIfAbsent(txHandle, handle => new HashSet <KernelTransactionHandle>());
                            kernelTransactionHandles.Add(kernelTransactionHandle);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public virtual string DescribeBlockingTransactions(KernelTransactionHandle handle)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            ISet <KernelTransactionHandle> allBlockers = new SortedSet <KernelTransactionHandle>(System.Collections.IComparer.comparingLong(KernelTransactionHandle::getUserTransactionId));
            ISet <KernelTransactionHandle> handles     = _directDependencies[handle];

            if (handles != null)
            {
                Deque <KernelTransactionHandle> blockerQueue = new LinkedList <KernelTransactionHandle>(handles);
                while (!blockerQueue.Empty)
                {
                    KernelTransactionHandle transactionHandle = blockerQueue.pop();
                    if (allBlockers.Add(transactionHandle))
                    {
                        ISet <KernelTransactionHandle> transactionHandleSet = _directDependencies[transactionHandle];
                        if (transactionHandleSet != null)
                        {
                            blockerQueue.addAll(transactionHandleSet);
                        }
                    }
                }
            }
            return(Describe(allBlockers));
        }
Beispiel #6
0
 private static bool IsTransactionExpired(KernelTransactionHandle activeTransaction, long nowNanos, long transactionTimeoutMillis)
 {
     return(nowNanos - activeTransaction.StartTimeNanos() > TimeUnit.MILLISECONDS.toNanos(transactionTimeoutMillis));
 }
 internal Tx(KernelTransactionHandle tx)
 {
     this.Transaction = tx;
 }
Beispiel #8
0
 private static Stream <ExecutingQuery> ExecutingQueriesWithId(long id, KernelTransactionHandle txHandle)
 {
     return(txHandle.ExecutingQueries().filter(q => q.internalQueryId() == id));
 }
Beispiel #9
0
 private static Stream <ExecutingQuery> ExecutingQueriesWithIds(ISet <long> ids, KernelTransactionHandle txHandle)
 {
     return(txHandle.ExecutingQueries().filter(q => ids.Contains(q.internalQueryId())));
 }
Beispiel #10
0
 private string GetExecutingStatus(KernelTransactionHandle handle, TransactionDependenciesResolver transactionDependenciesResolver)
 {
     return(transactionDependenciesResolver.IsBlocked(handle) ? "Blocked by: " + transactionDependenciesResolver.DescribeBlockingTransactions(handle) : RUNNING_STATE);
 }
Beispiel #11
0
 private string GetStatus(KernelTransactionHandle handle, Optional <Status> terminationReason, TransactionDependenciesResolver transactionDependenciesResolver)
 {
     return(terminationReason.map(reason => format(TERMINATED_STATE, reason.code())).orElseGet(() => GetExecutingStatus(handle, transactionDependenciesResolver)));
 }
Beispiel #12
0
 public virtual bool IsBlocked(KernelTransactionHandle handle)
 {
     return(_directDependencies[handle] != null);
 }