//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void detectBlockedTransactionsBySharedLock() public virtual void DetectBlockedTransactionsBySharedLock() { Dictionary <KernelTransactionHandle, IList <QuerySnapshot> > map = new Dictionary <KernelTransactionHandle, IList <QuerySnapshot> >(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 0, singletonList(ActiveLock.sharedLock(ResourceTypes.NODE, 1))); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction()); map[handle1] = singletonList(CreateQuerySnapshot(1)); map[handle2] = singletonList(CreateQuerySnapshotWaitingForLock(2, true, ResourceTypes.NODE, 1)); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map); assertFalse(resolver.IsBlocked(handle1)); assertTrue(resolver.IsBlocked(handle2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void blockingChainDescriptionForDirectlyBlockedTransaction() public virtual void BlockingChainDescriptionForDirectlyBlockedTransaction() { Dictionary <KernelTransactionHandle, IList <QuerySnapshot> > map = new Dictionary <KernelTransactionHandle, IList <QuerySnapshot> >(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 3, singletonList(ActiveLock.exclusiveLock(ResourceTypes.NODE, 1))); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction()); map[handle1] = singletonList(CreateQuerySnapshot(1)); map[handle2] = singletonList(CreateQuerySnapshotWaitingForLock(2, false, ResourceTypes.NODE, 1)); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map); assertThat(resolver.DescribeBlockingTransactions(handle1), EmptyString); assertEquals("[transaction-3]", resolver.DescribeBlockingTransactions(handle2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void detectIndependentTransactionsAsNotBlocked() public virtual void DetectIndependentTransactionsAsNotBlocked() { Dictionary <KernelTransactionHandle, IList <QuerySnapshot> > map = new Dictionary <KernelTransactionHandle, IList <QuerySnapshot> >(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction()); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction()); map[handle1] = singletonList(CreateQuerySnapshot(1)); map[handle2] = singletonList(CreateQuerySnapshot(2)); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map); assertFalse(resolver.IsBlocked(handle1)); assertFalse(resolver.IsBlocked(handle2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void blockingChainDescriptionForIndependentTransactionsIsEmpty() public virtual void BlockingChainDescriptionForIndependentTransactionsIsEmpty() { Dictionary <KernelTransactionHandle, IList <QuerySnapshot> > map = new Dictionary <KernelTransactionHandle, IList <QuerySnapshot> >(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction()); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction()); map[handle1] = singletonList(CreateQuerySnapshot(1)); map[handle2] = singletonList(CreateQuerySnapshot(2)); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map); assertThat(resolver.DescribeBlockingTransactions(handle1), EmptyString); assertThat(resolver.DescribeBlockingTransactions(handle2), EmptyString); }
//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; }
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; } }
private string GetExecutingStatus(KernelTransactionHandle handle, TransactionDependenciesResolver transactionDependenciesResolver) { return(transactionDependenciesResolver.IsBlocked(handle) ? "Blocked by: " + transactionDependenciesResolver.DescribeBlockingTransactions(handle) : RUNNING_STATE); }
private string GetStatus(KernelTransactionHandle handle, Optional <Status> terminationReason, TransactionDependenciesResolver transactionDependenciesResolver) { return(terminationReason.map(reason => format(TERMINATED_STATE, reason.code())).orElseGet(() => GetExecutingStatus(handle, transactionDependenciesResolver))); }