/* * This test ensures that an instance that cleanly leaves the cluster but is not the elector has no effect on * elector id and last version */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void nonElectorLeavingTheClusterMustNotAffectElectorInformation() public virtual void NonElectorLeavingTheClusterMustNotAffectElectorInformation() { // Given InstanceId me = new InstanceId(1); InstanceId elector = new InstanceId(2); InstanceId other = new InstanceId(3); ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration)); when(clusterConfiguration.GetUriForId(other)).thenReturn(URI.create("cluster://instance2")); CommonContextState commonContextState = mock(typeof(CommonContextState)); when(commonContextState.Configuration()).thenReturn(clusterConfiguration); ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.Instance, mock(typeof(Timeouts)), mock(typeof(Executor)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(ObjectInputStreamFactory)), mock(typeof(LearnerContext)), mock(typeof(HeartbeatContext)), mock(typeof(Config))); // This means instance 2 was the elector at version 8 context.LastElector = elector; context.LastElectorVersion = 8; // When context.Left(other); // Then assertEquals(context.LastElector, elector); assertEquals(context.LastElectorVersion, 8); }
// Cluster events /// <summary> /// Logged when the instance itself joins or rejoins a cluster /// </summary> /// <param name="clusterConfiguration"> </param> public override void EnteredCluster(ClusterConfiguration clusterConfiguration) { _myUri = clusterConfiguration.GetUriForId(_myId); _log.info("Instance %s entered the cluster", PrintId(_myId, _myUri)); }