public void Handle(TimeoutNowRequest req)
		{
            if (FromOurTopology(req) == false)
            {
                _log.Info("Got a timeout request message outside my cluster topology (id: {0}), ignoring", req.ClusterTopologyId);
                return;
            }
            if (req.Term < Engine.PersistentState.CurrentTerm)
			{
				_log.Info("Got timeout now request from an older term, ignoring");
				return;
			}
			if (req.From != Engine.CurrentLeader)
			{
				_log.Info("Got timeout now request from {0}, who isn't the current leader, ignoring.",
					req.From);
				return;
			}

			_log.Info("Got timeout now request from the leader, timing out and forcing immediate election");
			Engine.SetState(RaftEngineState.CandidateByRequest);
		}
示例#2
0
		public void Send(NodeConnectionInfo dest, TimeoutNowRequest req)
		{
			_sender.Send(dest, req);
		}
示例#3
0
		public void Send(NodeConnectionInfo dest, TimeoutNowRequest req)
		{
			HttpClient client;
			using (GetConnection(dest, out client))
			{
				LogStatus("timeout to " + dest, async () =>
				{
					var message = await client.GetAsync(string.Format("raft/timeoutNow?term={0}&from={1}&clusterTopologyId={2}", req.Term, req.From, req.ClusterTopologyId));
					var reply = await message.Content.ReadAsStringAsync();
					if (message.IsSuccessStatusCode == false)
					{
						_log.Warn("Error appending entries to {0}. Status: {1}\r\n{2}", dest.Name, message.StatusCode, message, reply);
						return;
					}
					SendToSelf(new NothingToDo());
				});
			}
		}