private void CreateServers(int numberOfServers) { _numberOfServers = numberOfServers; for (int i = 0; i < _numberOfServers; i++) { var peer = new NodePeer(); _peers.Add(peer); } for (int i = 0; i < _numberOfServers; i++) { StartServer(i); } }
private void AddNewServers(int count) { for (int i = 0; i < count; i++) { var peer = new NodePeer(); _peers.Add(peer); var log = new InMemoryLog(); var fsm = new InMemoryStateMachine(); var settings = new InMemorySettingsBuilder().WithMinTimeout(1000).WithMaxTimeout(3500).WithHeartbeatTimeout(50).Build(); var peersProvider = new InMemoryPeersProvider(_peers); var node = new Node(fsm, log, settings, peersProvider); var server = new Server(log, fsm, node); peer.SetNode(server.Node); var nextIndex = _servers.Count; _servers.TryAdd(nextIndex, server); node.Start(Guid.NewGuid().ToString()); } }
private void AddNewServers(int count) { for (int i = 0; i < count; i++) { var peer = new NodePeer(); _peers.Add(peer); var log = new InMemoryLog(); var fsm = new InMemoryStateMachine(); var settings = new InMemorySettingsBuilder().WithMinTimeout(1000).WithMaxTimeout(3500).WithHeartbeatTimeout(50).Build(); var peersProvider = new InMemoryPeersProvider(_peers); var logger = new Mock <ILogger>(); var loggerFactory = new Mock <ILoggerFactory>(); loggerFactory.Setup(x => x.CreateLogger(It.IsAny <string>())).Returns(logger.Object); var node = new Node(fsm, log, settings, peersProvider, loggerFactory.Object); var server = new Server(log, fsm, node); peer.SetNode(server.Node); var nextIndex = _servers.Count; _servers.TryAdd(nextIndex, server); node.Start(new NodeId(Guid.NewGuid().ToString())); } }