Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotIssueLocksOnNonLeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotIssueLocksOnNonLeader()
        {
            // given
            MemberId me     = member(0);
            MemberId leader = member(1);

            ReplicatedLockTokenStateMachine replicatedLockStateMachine = new ReplicatedLockTokenStateMachine(new InMemoryStateStorage(new ReplicatedLockTokenState()));
            DirectReplicator replicator = new DirectReplicator(replicatedLockStateMachine);

            LeaderLocator leaderLocator = mock(typeof(LeaderLocator));

            when(leaderLocator.Leader).thenReturn(leader);
            Locks locks = mock(typeof(Locks));

            Org.Neo4j.Kernel.impl.locking.Locks_Client client = mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client));
            when(locks.NewClient()).thenReturn(client);

            LeaderOnlyLockManager lockManager = new LeaderOnlyLockManager(me, replicator, leaderLocator, locks, replicatedLockStateMachine);

            // when
            Org.Neo4j.Kernel.impl.locking.Locks_Client lockClient = lockManager.NewClient();
            try
            {
                lockClient.AcquireExclusive(LockTracer.NONE, ResourceTypes.NODE, 0L);
                fail("Should have thrown exception");
            }
            catch (AcquireLockTimeoutException)
            {
                // expected
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIssueLocksOnLeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIssueLocksOnLeader()
        {
            // given
            MemberId me = member(0);

            ReplicatedLockTokenStateMachine replicatedLockStateMachine = new ReplicatedLockTokenStateMachine(new InMemoryStateStorage(new ReplicatedLockTokenState()));

            DirectReplicator replicator = new DirectReplicator(replicatedLockStateMachine);

            LeaderLocator leaderLocator = mock(typeof(LeaderLocator));

            when(leaderLocator.Leader).thenReturn(me);
            Locks locks = mock(typeof(Locks));

            Org.Neo4j.Kernel.impl.locking.Locks_Client client = mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client));
            when(locks.NewClient()).thenReturn(client);

            LeaderOnlyLockManager lockManager = new LeaderOnlyLockManager(me, replicator, leaderLocator, locks, replicatedLockStateMachine);

            // when
            lockManager.NewClient().acquireExclusive(LockTracer.NONE, ResourceTypes.NODE, 0L);

            // then
        }
Beispiel #3
0
 public CatchupAddressProvider_PrioritisingUpstreamStrategyBasedAddressProvider(LeaderLocator leaderLocator, TopologyService topologyService, UpstreamDatabaseStrategySelector strategySelector)
 {
     this.LeaderLocator   = leaderLocator;
     this.TopologyService = topologyService;
     this.SecondaryUpstreamStrategyAddressSupplier = new UpstreamStrategyAddressSupplier(strategySelector, topologyService);
 }