Пример #1
0
        private int LockCount()
        {
            LockCountVisitor lockVisitor = new LockCountVisitor();

            Locks.accept(lockVisitor);
            return(lockVisitor.LockCount);
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void releaseTryLocksOnClose()
        public virtual void ReleaseTryLocksOnClose()
        {
            assertTrue(ClientA.trySharedLock(ResourceTypes.Node, 1L));
            assertTrue(ClientB.tryExclusiveLock(ResourceTypes.Node, 2L));

            ClientA.close();
            ClientB.close();

            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(0, lockCountVisitor.LockCount);
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReleaseUnpreparedLocksOnStop()
        public virtual void MustReleaseUnpreparedLocksOnStop()
        {
            // Given
            ClientA.acquireShared(_tracer, NODE, 1L);
            ClientA.acquireExclusive(_tracer, NODE, 2L);

            // When
            ClientA.stop();

            // The client was stopped before it could enter the prepare phase, so all of its locks are released
            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(0, lockCountVisitor.LockCount);
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void prepareMustAllowAcquiringNewLocksAfterStop()
        public virtual void PrepareMustAllowAcquiringNewLocksAfterStop()
        {
            // Given
            ClientA.prepare();
            ClientA.stop();

            // When
            ClientA.acquireShared(_tracer, NODE, 1);
            ClientA.acquireExclusive(_tracer, NODE, 2);

            // Stopped essentially has no effect when it comes after the client has entered the prepare phase
            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(2, lockCountVisitor.LockCount);
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustNotReleaseLocksAfterPrepareOnStop()
        public virtual void MustNotReleaseLocksAfterPrepareOnStop()
        {
            // Given
            ClientA.acquireShared(_tracer, NODE, 1L);
            ClientA.acquireExclusive(_tracer, NODE, 2L);
            ClientA.prepare();

            // When
            ClientA.stop();

            // The client entered the prepare phase, so it gets to keep its locks
            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(2, lockCountVisitor.LockCount);
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReleaseReadLockWaitersOnStop()
        public virtual void MustReleaseReadLockWaitersOnStop()
        {
            // Given
            ClientA.acquireExclusive(_tracer, NODE, 1L);
            ClientB.acquireExclusive(_tracer, NODE, 2L);
            AcquireShared(ClientB, _tracer, NODE, 1L).callAndAssertWaiting();

            // When
            ClientB.stop();
            ClientA.stop();

            // All locks clients should be stopped at this point, and all all locks should be released because none of the
            // clients entered the prepare phase
            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(0, lockCountVisitor.LockCount);
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void closeShouldWaitAllOperationToFinish()
        public virtual void CloseShouldWaitAllOperationToFinish()
        {
            // given
            ClientA.acquireShared(LockTracer.NONE, NODE, 1L);
            ClientA.acquireShared(LockTracer.NONE, NODE, 3L);
            ClientB.acquireShared(LockTracer.NONE, NODE, 1L);
            AcquireShared(ClientC, LockTracer.NONE, NODE, 2L);
            AcquireExclusive(ClientB, LockTracer.NONE, NODE, 1L).callAndAssertWaiting();
            AcquireExclusive(ClientC, LockTracer.NONE, NODE, 1L).callAndAssertWaiting();

            // when
            ClientB.close();
            ClientC.close();
            ClientA.close();

            // all locks should be closed at this point regardless of
            // reader/writer waiter in any threads
            // those should be gracefully finish and client should be closed

            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(0, lockCountVisitor.LockCount);
        }