//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCleanupNotUsedLocks() public virtual void ShouldCleanupNotUsedLocks() { // given LockResource node = new LockResource(ResourceTypes.NODE, 1L); LockTransaction lockTransaction = new LockTransaction(); LockManagerImpl lockManager = CreateLockManager(); lockManager.GetWriteLock(LockTracer.NONE, node, lockTransaction); // expect assertTrue(lockManager.TryReadLock(node, lockTransaction)); assertEquals(1, CountLocks(lockManager)); // and when lockManager.ReleaseWriteLock(node, lockTransaction); // expect to see one old reader assertEquals(1, CountLocks(lockManager)); // and when lockManager.ReleaseReadLock(node, lockTransaction); // no more locks left assertEquals(0, CountLocks(lockManager)); }
public CommunityLockClient(LockManagerImpl manager) { this._manager = manager; _readReleaser = (key, lockResource) => manager.releaseReadLock(lockResource, _lockTransaction); _writeReleaser = (key, lockResource) => manager.releaseWriteLock(lockResource, _lockTransaction); _typeReadReleaser = value => value.forEachKeyValue(_readReleaser); _typeWriteReleaser = value => value.forEachKeyValue(_writeReleaser); }
private int CountLocks(LockManagerImpl lockManager) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int[] counter = new int[1]; int[] counter = new int[1]; lockManager.Accept(element => { counter[0]++; return(false); }); return(counter[0]); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotBePossibleReleaseNotExistingLock() public virtual void ShouldNotBePossibleReleaseNotExistingLock() { // given LockResource node1 = new LockResource(ResourceTypes.NODE, 1L); LockTransaction lockTransaction = new LockTransaction(); LockManagerImpl lockManager = CreateLockManager(); // expect ExpectedException.expect(typeof(LockNotFoundException)); ExpectedException.expectMessage("Lock not found for: "); // when lockManager.ReleaseReadLock(node1, lockTransaction); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowGetReadWriteLocks() public virtual void ShouldAllowGetReadWriteLocks() { // given LockResource node1 = new LockResource(ResourceTypes.NODE, 1L); LockResource node2 = new LockResource(ResourceTypes.NODE, 2L); LockTransaction lockTransaction = new LockTransaction(); LockManagerImpl lockManager = CreateLockManager(); // expect assertTrue(lockManager.GetReadLock(LockTracer.NONE, node1, lockTransaction)); assertTrue(lockManager.GetReadLock(LockTracer.NONE, node2, lockTransaction)); assertTrue(lockManager.GetWriteLock(LockTracer.NONE, node2, lockTransaction)); lockManager.ReleaseReadLock(node1, lockTransaction); lockManager.ReleaseReadLock(node2, lockTransaction); lockManager.ReleaseWriteLock(node2, lockTransaction); int lockCount = CountLocks(lockManager); assertEquals(0, lockCount); }
public CommunityLockManger(Config config, Clock clock) { _manager = new LockManagerImpl(new RagManager(), config, clock); }