//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void whenInToSlaveStateLosingQuorumShouldPutInPending() public virtual void WhenInToSlaveStateLosingQuorumShouldPutInPending() { // Given InstanceId me = new InstanceId(1); InstanceId other = new InstanceId(2); HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, false); AvailabilityGuard guard = mock(typeof(DatabaseAvailabilityGuard)); ObservedClusterMembers members = MockClusterMembers(me, emptyList(), singletonList(other)); ClusterMemberEvents events = mock(typeof(ClusterMemberEvents)); ClusterMemberListenerContainer memberListenerContainer = MockAddClusterMemberListener(events); HighAvailabilityMemberStateMachine stateMachine = BuildMockedStateMachine(context, events, members, guard); stateMachine.Init(); ClusterMemberListener memberListener = memberListenerContainer.Get(); HAStateChangeListener probe = new HAStateChangeListener(); stateMachine.AddHighAvailabilityMemberListener(probe); // Send it to MASTER memberListener.MemberIsAvailable(MASTER, other, URI.create("ha://whatever"), StoreId.DEFAULT); assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.ToSlave)); // When memberListener.MemberIsFailed(new InstanceId(2)); // Then assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Pending)); assertThat(probe.InstanceStopsConflict, @is(false)); assertThat(probe.InstanceDetachedConflict, @is(true)); verify(guard, times(1)).require(any(typeof(AvailabilityRequirement))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void whenInSlaveStateLosingOtherSlaveShouldNotPutInPending() public virtual void WhenInSlaveStateLosingOtherSlaveShouldNotPutInPending() { // Given InstanceId me = new InstanceId(1); InstanceId master = new InstanceId(2); InstanceId otherSlave = new InstanceId(3); HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, false); AvailabilityGuard guard = mock(typeof(DatabaseAvailabilityGuard)); ObservedClusterMembers members = MockClusterMembers(me, singletonList(master), singletonList(otherSlave)); ClusterMemberEvents events = mock(typeof(ClusterMemberEvents)); ClusterMemberListenerContainer memberListenerContainer = MockAddClusterMemberListener(events); HighAvailabilityMemberStateMachine stateMachine = BuildMockedStateMachine(context, events, members, guard); stateMachine.Init(); ClusterMemberListener memberListener = memberListenerContainer.Get(); HAStateChangeListener probe = new HAStateChangeListener(); stateMachine.AddHighAvailabilityMemberListener(probe); // Send it to MASTER memberListener.MemberIsAvailable(MASTER, master, URI.create("ha://whatever"), StoreId.DEFAULT); memberListener.MemberIsAvailable(SLAVE, me, URI.create("ha://whatever3"), StoreId.DEFAULT); memberListener.MemberIsAvailable(SLAVE, otherSlave, URI.create("ha://whatever2"), StoreId.DEFAULT); assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Slave)); // When memberListener.MemberIsFailed(otherSlave); // Then assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Slave)); assertThat(probe.InstanceStopsConflict, @is(false)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void whenInMasterStateLosingQuorumFromTwoInstancesShouldRemainMaster() public virtual void WhenInMasterStateLosingQuorumFromTwoInstancesShouldRemainMaster() { // Given InstanceId me = new InstanceId(1); InstanceId other = new InstanceId(2); HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, false); AvailabilityGuard guard = mock(typeof(DatabaseAvailabilityGuard)); ObservedClusterMembers members = MockClusterMembers(me, emptyList(), singletonList(other)); ClusterMemberEvents events = mock(typeof(ClusterMemberEvents)); ClusterMemberListenerContainer memberListenerContainer = MockAddClusterMemberListener(events); HighAvailabilityMemberStateMachine stateMachine = BuildMockedStateMachine(context, events, members, guard); stateMachine.Init(); ClusterMemberListener memberListener = memberListenerContainer.Get(); HAStateChangeListener probe = new HAStateChangeListener(); stateMachine.AddHighAvailabilityMemberListener(probe); // Send it to MASTER memberListener.CoordinatorIsElected(me); memberListener.MemberIsAvailable(MASTER, me, URI.create("ha://whatever"), StoreId.DEFAULT); assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Master)); // When memberListener.MemberIsFailed(new InstanceId(2)); // Then assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Master)); assertThat(probe.InstanceStopsConflict, @is(false)); assertThat(probe.InstanceDetachedConflict, @is(false)); }
public virtual void Set(ClusterMemberListener clusterMemberListener) { if (this.ClusterMemberListener != null) { throw new System.InvalidOperationException("Expected to have only 1 listener, but have more. " + "Defined listener: " + this.ClusterMemberListener + ". Newly added listener:" + clusterMemberListener); } this.ClusterMemberListener = clusterMemberListener; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemainToPendingOnMasterElectedForSomeoneElse() public virtual void ShouldRemainToPendingOnMasterElectedForSomeoneElse() { // Given InstanceId me = new InstanceId(1); HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, false); ClusterMemberEvents events = mock(typeof(ClusterMemberEvents)); ClusterMemberListenerContainer memberListenerContainer = MockAddClusterMemberListener(events); HighAvailabilityMemberStateMachine stateMachine = BuildMockedStateMachine(context, events); stateMachine.Init(); ClusterMemberListener memberListener = memberListenerContainer.Get(); // When memberListener.CoordinatorIsElected(new InstanceId(2)); // Then assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Pending)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void whenSlaveOnlyIsElectedStayInPending() public virtual void WhenSlaveOnlyIsElectedStayInPending() { // Given InstanceId me = new InstanceId(1); HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, true); ClusterMemberEvents events = mock(typeof(ClusterMemberEvents)); ClusterMemberListenerContainer memberListenerContainer = MockAddClusterMemberListener(events); HighAvailabilityMemberStateMachine stateMachine = BuildMockedStateMachine(context, events); stateMachine.Init(); ClusterMemberListener memberListener = memberListenerContainer.Get(); // When memberListener.CoordinatorIsElected(me); // Then assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.Pending)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSwitchToToSlaveOnMasterAvailableForSomeoneElse() public virtual void ShouldSwitchToToSlaveOnMasterAvailableForSomeoneElse() { // Given InstanceId me = new InstanceId(1); HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, false); ClusterMemberEvents events = mock(typeof(ClusterMemberEvents)); ClusterMemberListenerContainer memberListenerContainer = MockAddClusterMemberListener(events); HighAvailabilityMemberStateMachine stateMachine = BuildMockedStateMachine(context, events); stateMachine.Init(); ClusterMemberListener memberListener = memberListenerContainer.Get(); HAStateChangeListener probe = new HAStateChangeListener(); stateMachine.AddHighAvailabilityMemberListener(probe); // When memberListener.MemberIsAvailable(MASTER, new InstanceId(2), URI.create("ha://whatever"), StoreId.DEFAULT); // Then assertThat(stateMachine.CurrentState, equalTo(HighAvailabilityMemberState.ToSlave)); assertThat(probe.MasterIsAvailableConflict, @is(true)); }
public override void AddClusterMemberListener(ClusterMemberListener listener) { Listeners.add(listener); }
public override void RemoveClusterMemberListener(ClusterMemberListener listener) { Listeners.remove(listener); }
public override void RemoveClusterMemberListener(ClusterMemberListener listener) { }
public override void AddClusterMemberListener(ClusterMemberListener listener) { this.Listener = listener; }