public void Handle(DisconnectedFromCluster req)
		{
		    if (FromOurTopology(req) == false)
		    {
		        _log.Info("Got a disconnection notification message outside my cluster topology (id: {0}), ignoring", req.ClusterTopologyId);
		        return;
		    }
			if (req.Term < Engine.PersistentState.CurrentTerm)
			{
				_log.Info("Got disconnection notification from an older term, ignoring");
				return;
			}
			if (req.From != Engine.CurrentLeader)
			{
				_log.Info("Got disconnection notification from {0}, who isn't the current leader, ignoring.",
					req.From);
				return;
			}
			_log.Warn("Got disconnection notification  from the leader, clearing topology and moving to idle follower state");
			var tcc = new TopologyChangeCommand
			{
				Requested = new Topology(req.ClusterTopologyId)
			};
			Engine.PersistentState.SetCurrentTopology(tcc.Requested, 0L);
			Engine.StartTopologyChange(tcc);
			Engine.CommitTopologyChange(tcc);
			Engine.SetState(RaftEngineState.Follower);
		}
Esempio n. 2
0
		public void Send(NodeConnectionInfo dest, DisconnectedFromCluster req)
		{
			_sender.Send(dest, req);
		}
Esempio n. 3
0
		public void Send(NodeConnectionInfo dest, DisconnectedFromCluster req)
		{
			HttpClient client;
			using (GetConnection(dest, out client))
			{
				LogStatus("disconnect " + dest, async () =>
				{
					var message = await client.GetAsync(string.Format("raft/disconnectFromCluster?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 sending disconnecton notification to {0}. Status: {1}\r\n{2}", dest.Name, message.StatusCode, message, reply);
						return;
					}
					SendToSelf(new NothingToDo());
				});
			}
		}