private void AddBackupAddressToBackupList(ICollection <BackupServerInfo> backups, ushort _port) { var _address = ClusterListener.ExtractSocketAddress(); Log.DebugFormat("adding new node with addres = {0}", _address); backups.Add(new BackupServerInfo() { address = _address, port = _port }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testElectionVersionIsResetWhenElectorChangesFromMeToOther() public virtual void TestElectionVersionIsResetWhenElectorChangesFromMeToOther() { const string coordinatorRole = "coordinator"; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId me = new org.neo4j.cluster.InstanceId(1); InstanceId me = new InstanceId(1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId winner = new org.neo4j.cluster.InstanceId(2); InstanceId winner = new InstanceId(2); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId elector = new org.neo4j.cluster.InstanceId(2); InstanceId elector = new InstanceId(2); HeartbeatContext heartbeatContext = mock(typeof(HeartbeatContext)); when(heartbeatContext.Failed).thenReturn(Collections.emptySet()); Config config = mock(typeof(Config)); when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10); MultiPaxosContext multiPaxosContext = new MultiPaxosContext(me, Iterables.iterable(new ElectionRole(coordinatorRole)), mock(typeof(ClusterConfiguration)), ThreadStart.run, NullLogProvider.Instance, mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(AcceptorInstanceStore)), mock(typeof(Timeouts)), mock(typeof(ElectionCredentialsProvider)), config); ClusterContext context = multiPaxosContext.ClusterContext; ElectionContext electionContext = multiPaxosContext.ElectionContext; ClusterListener listener = mock(typeof(ClusterListener)); context.LastElectorVersion = 5; context.LastElector = me; context.AddClusterListener(listener); long expectedVersion = electionContext.NewConfigurationStateChange().Version; context.Elected(coordinatorRole, winner, me, expectedVersion); verify(listener, times(1)).elected(coordinatorRole, winner, null); context.Elected(coordinatorRole, winner, elector, 2); verify(listener, times(2)).elected(coordinatorRole, winner, null); context.Elected(coordinatorRole, winner, elector, 3); verify(listener, times(3)).elected(coordinatorRole, winner, null); context.Elected(coordinatorRole, winner, elector, 2); verifyNoMoreInteractions(listener); }
public override void RemoveClusterListener(ClusterListener listener) { _clusterListeners.remove(listener); }
// Cluster API public override void AddClusterListener(ClusterListener listener) { _clusterListeners.add(listener); }