示例#1
0
        public void Follower_as_a_single_node_becomes_leader_automatically()
        {
            var hub = new InMemoryTransportHub();
            var storageEnvironmentOptions = StorageEnvironmentOptions.CreateMemoryOnly();

            storageEnvironmentOptions.OwnsPagers = false;

            var raftEngineOptions = new RaftEngineOptions(
                new NodeConnectionInfo {
                Name = "node1"
            },
                storageEnvironmentOptions,
                hub.CreateTransportFor("node1"),
                new DictionaryStateMachine()
                )
            {
                ElectionTimeout  = 1000,
                HeartbeatTimeout = 1000 / 6
            };

            PersistentState.ClusterBootstrap(raftEngineOptions);
            storageEnvironmentOptions.OwnsPagers = true;

            using (var raftNode = new RaftEngine(raftEngineOptions))
            {
                Assert.Equal(RaftEngineState.Leader, raftNode.State);
            }
        }
示例#2
0
		public void Follower_as_a_single_node_becomes_leader_automatically()
		{
			var hub = new InMemoryTransportHub();
			var storageEnvironmentOptions = StorageEnvironmentOptions.CreateMemoryOnly();
			storageEnvironmentOptions.OwnsPagers = false;
			
			var raftEngineOptions = new RaftEngineOptions(
				new NodeConnectionInfo { Name = "node1" }, 
				storageEnvironmentOptions,
				hub.CreateTransportFor("node1"),
				new DictionaryStateMachine()
				)
			{
				ElectionTimeout = 1000,
				HeartbeatTimeout = 1000/6
			};

			PersistentState.ClusterBootstrap(raftEngineOptions);
			storageEnvironmentOptions.OwnsPagers = true;

			using (var raftNode = new RaftEngine(raftEngineOptions))
			{
				Assert.Equal(RaftEngineState.Leader, raftNode.State);
			}
		}
示例#3
0
		public RaftTestsBase()
		{
			_inMemoryTransportHub = new InMemoryTransportHub();
		}
示例#4
0
 public RaftTestsBase()
 {
     _inMemoryTransportHub = new InMemoryTransportHub();
 }