public ObservedClusterMembers(LogProvider logProvider, Cluster cluster, Heartbeat heartbeat, ClusterMemberEvents events, InstanceId me) { this._me = me; this._log = logProvider.getLog(this.GetType()); cluster.AddClusterListener(new HAMClusterListener(this)); heartbeat.AddHeartbeatListener(new HAMHeartbeatListener(this)); events.AddClusterMemberListener(new HAMClusterMemberListener(this)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void start() throws java.io.IOException public virtual void Start() { _broadcastSerializer = new AtomicBroadcastSerializer(new ObjectStreamFactory(), new ObjectStreamFactory()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.lifecycle.LifeSupport life = new org.neo4j.kernel.lifecycle.LifeSupport(); LifeSupport life = new LifeSupport(); try { MessageTimeoutStrategy timeoutStrategy = (new MessageTimeoutStrategy(new FixedTimeoutStrategy(5000))).timeout(HeartbeatMessage.sendHeartbeat, 200); Monitors monitors = new Monitors(); NetworkedServerFactory serverFactory = new NetworkedServerFactory(life, new MultiPaxosServerFactory(new ClusterConfiguration("default", NullLogProvider.Instance), NullLogProvider.Instance, monitors.NewMonitor(typeof(StateMachines.Monitor))), timeoutStrategy, NullLogProvider.Instance, new ObjectStreamFactory(), new ObjectStreamFactory(), monitors.NewMonitor(typeof(NetworkReceiver.Monitor)), monitors.NewMonitor(typeof(NetworkSender.Monitor)), monitors.NewMonitor(typeof(NamedThreadFactory.Monitor))); ServerIdElectionCredentialsProvider electionCredentialsProvider = new ServerIdElectionCredentialsProvider(); _server = serverFactory.NewNetworkedServer(Config.defaults(), new InMemoryAcceptorInstanceStore(), electionCredentialsProvider); _server.addBindingListener(electionCredentialsProvider); _server.addBindingListener(me => Console.WriteLine("Listening at:" + me)); Cluster = _server.newClient(typeof(Cluster)); Cluster.addClusterListener(new ClusterListenerAnonymousInnerClass(this)); Heartbeat heartbeat = _server.newClient(typeof(Heartbeat)); heartbeat.AddHeartbeatListener(new HeartbeatListenerAnonymousInnerClass(this)); Broadcast = _server.newClient(typeof(AtomicBroadcast)); Broadcast.addAtomicBroadcastListener(value => { try { Console.WriteLine(_broadcastSerializer.receive(value)); } catch (Exception e) when(e is IOException || e is ClassNotFoundException) { e.printStackTrace(); } }); life.Start(); string command; StreamReader reader = new StreamReader(System.in); while (!(command = reader.ReadLine()).Equals("quit")) { string[] arguments = command.Split(" ", true); System.Reflection.MethodInfo method = GetCommandMethod(arguments[0]); if (method != null) { string[] realArgs = new string[arguments.Length - 1]; Array.Copy(arguments, 1, realArgs, 0, realArgs.Length); try { method.invoke(this, ( object[] )realArgs); } catch (Exception e) when(e is IllegalAccessException || e is System.ArgumentException || e is InvocationTargetException) { e.printStackTrace(); } } } Cluster.leave(); } finally { life.Shutdown(); Console.WriteLine("Done"); } }