internal override IList <ActiveLock> WaitingOnLocks() { IList <ActiveLock> locks = new List <ActiveLock>(); switch (_mode) { case Org.Neo4j.Kernel.impl.locking.ActiveLock_Fields.EXCLUSIVE_MODE: foreach (long resourceId in _resourceIds) { locks.Add(ActiveLock.exclusiveLock(_resourceType, resourceId)); } break; case Org.Neo4j.Kernel.impl.locking.ActiveLock_Fields.SHARED_MODE: foreach (long resourceId in _resourceIds) { locks.Add(ActiveLock.sharedLock(_resourceType, resourceId)); } break; default: throw new System.ArgumentException("Unsupported type of lock mode: " + _mode); } return(locks); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void detectBlockedTransactionsByExclusiveLock() public virtual void DetectBlockedTransactionsByExclusiveLock() { Dictionary <KernelTransactionHandle, IList <QuerySnapshot> > map = new Dictionary <KernelTransactionHandle, IList <QuerySnapshot> >(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 0, 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); 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 blockingChainDescriptionForChainedBlockedTransaction() public virtual void BlockingChainDescriptionForChainedBlockedTransaction() { Dictionary <KernelTransactionHandle, IList <QuerySnapshot> > map = new Dictionary <KernelTransactionHandle, IList <QuerySnapshot> >(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 4, singletonList(ActiveLock.exclusiveLock(ResourceTypes.NODE, 1))); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 5, singletonList(ActiveLock.sharedLock(ResourceTypes.NODE, 2))); TestKernelTransactionHandle handle3 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 6); map[handle1] = singletonList(CreateQuerySnapshot(1)); map[handle2] = singletonList(CreateQuerySnapshotWaitingForLock(2, false, ResourceTypes.NODE, 1)); map[handle3] = singletonList(CreateQuerySnapshotWaitingForLock(3, true, ResourceTypes.NODE, 2)); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map); assertThat(resolver.DescribeBlockingTransactions(handle1), EmptyString); assertEquals("[transaction-4]", resolver.DescribeBlockingTransactions(handle2)); assertEquals("[transaction-4, transaction-5]", resolver.DescribeBlockingTransactions(handle3)); }